Skip to content

Commit 28e645f

Browse files
authored
[show_tech] Filter out a list of commands in generate_dump script which are not applicable to Supervisor (sonic-net#3646)
hat I did On 202205 branch, execute "show techsupport " on Supervisor. It hung in the scripts which call "show queue counters". This PR filters out a list of command which are not applicable to Supervisor. Fixes Nokia-ION/ndk#60 How I did it Modify generate_dump script by adding code to check if IS_SUPERVISOR, not to executes the "show queue counters". And also return at the beginning of the following functions which are not applicable on Supervisor: save_bfd_info() save_bgp_info() save_evpn_info() save_frr_info() Also fix some of the failure which are shown during the show techsupport. a) check if file /etc//cron.d/logrote exists before access it in function disable_logrotate() and enable_logrotate() b) check if directory /var/log/sai_failure_dump/ exists before using this directory. Add "show reboot-cause history" to the generate_dump Check if output of "show vrf" is empty, don't access the empty list with "awk" command How to verify it "show techsupport" shoudl work fine on Supervisor as well as on LC Signed-off-by: mlok <[email protected]>
1 parent b767cb8 commit 28e645f

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

scripts/generate_dump

+41-4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ SAVE_STDERR=true
5151
RETURN_CODE=$EXT_SUCCESS
5252
DEBUG_DUMP=false
5353
ROUTE_TAB_LIMIT_DIRECT_ITERATION=24000
54+
IS_SUPERVISOR=false
5455

5556
# lock dirs/files
5657
LOCKDIR="/tmp/techsupport-lock"
@@ -532,8 +533,11 @@ save_bgp_neighbor() {
532533
save_cmd "vtysh $ns -c \"show bgp ipv6 neighbors $word advertised-routes\"" "ipv6.bgp.neighbor.$word.adv$asic_id"
533534
save_cmd "vtysh $ns -c \"show bgp ipv6 neighbors $word routes\"" "ipv6.bgp.neighbor.$word.rcv$asic_id"
534535
done
535-
536-
vrf_list=`${timeout_cmd} bash -c "vtysh $ns -c 'show vrf' | awk -F" " '{print \$2}'"`
536+
vrf_list=""
537+
vrf_output=$(${timeout_cmd} bash -c "vtysh $ns -c 'show vrf'")
538+
if [ ! -z $vrf_output]; then
539+
vrf_list= echo $vrf_output | awk -F" " '{print $2}'
540+
fi
537541
for vrf in $vrf_list; do
538542
neighbor_list=`${timeout_cmd} bash -c "vtysh $ns -c 'show ip bgp vrf $vrf neighbors' | grep 'BGP neighbor is' | awk -F '[, ]' '{print \$4}'"`
539543
for word in $neighbor_list; do
@@ -651,6 +655,9 @@ save_nat_info() {
651655
###############################################################################
652656
save_bfd_info() {
653657
trap 'handle_error $? $LINENO' ERR
658+
if $IS_SUPERVISOR; then
659+
return
660+
fi
654661
save_vtysh "show bfd peers" "frr.bfd.peers"
655662
save_vtysh "show bfd peers counters" "frr.bfd.peers.counters"
656663
save_vtysh "show bfd peers json" "frr.bfd.peers.json"
@@ -688,6 +695,9 @@ save_ip_info() {
688695
###############################################################################
689696
save_bgp_info() {
690697
trap 'handle_error $? $LINENO' ERR
698+
if $IS_SUPERVISOR; then
699+
return
700+
fi
691701
save_vtysh "show ip bgp summary" "bgp.summary"
692702
save_vtysh "show ip bgp neighbors" "bgp.neighbors"
693703
save_vtysh "show ip bgp" "bgp.table"
@@ -725,6 +735,9 @@ save_bgp_info() {
725735
###############################################################################
726736
save_evpn_info() {
727737
trap 'handle_error $? $LINENO' ERR
738+
if $IS_SUPERVISOR; then
739+
return
740+
fi
728741
save_vtysh "show bgp l2vpn evpn" "bgp.l2vpn.evpn"
729742
save_vtysh "show bgp l2vpn evpn summary json" "bgp.evpn.summary.json"
730743
save_vtysh "show bgp l2vpn evpn route" "bgp.evpn.route"
@@ -758,6 +771,9 @@ save_evpn_info() {
758771
###############################################################################
759772
save_frr_info() {
760773
trap 'handle_error $? $LINENO' ERR
774+
if $IS_SUPERVISOR; then
775+
return
776+
fi
761777
save_vtysh "show running-config" "frr.running_config"
762778
save_vtysh "show ip route vrf all nexthop-group" "frr.ip_route.nhg"
763779
save_vtysh "show ipv6 route vrf all nexthop-group" "frr.ip6_route.nhg"
@@ -1141,6 +1157,9 @@ find_files() {
11411157
# None
11421158
###############################################################################
11431159
disable_logrotate() {
1160+
if [ ! -f "/etc/cron.d/logrotate" ]; then
1161+
return
1162+
fi
11441163
sed -i '/\/usr\/sbin\/logrotate/s/^/#/g' /etc/cron.d/logrotate
11451164
}
11461165

@@ -1154,6 +1173,9 @@ disable_logrotate() {
11541173
# None
11551174
###############################################################################
11561175
enable_logrotate() {
1176+
if [ ! -f "/etc/cron.d/logrotate" ]; then
1177+
return
1178+
fi
11571179
sed -i '/\/usr\/sbin\/logrotate/s/^#*//g' /etc/cron.d/logrotate
11581180
}
11591181

@@ -1860,6 +1882,9 @@ save_crash_files() {
18601882
# None
18611883
###############################################################################
18621884
save_sai_failure_dump(){
1885+
if [ ! -d "/var/log/sai_failure_dump/" ]; then
1886+
return
1887+
fi
18631888
for file in $(find_files "/var/log/sai_failure_dump/"); do
18641889
if $TAR -tf $TARFILE | grep $BASE/log/$(basename $file); then
18651890
# if the files are already collected under the log/ dir
@@ -1919,7 +1944,9 @@ save_counter_snapshot() {
19191944

19201945
save_cmd "echo $counter_t" "date.counter_$idx"
19211946
save_cmd "show interface counters" "interface.counters_$idx"
1922-
save_cmd_all_ns "show queue counters" "queue.counters_$idx"
1947+
if ! $IS_SUPERVISOR; then
1948+
save_cmd_all_ns "show queue counters" "queue.counters_$idx"
1949+
fi
19231950
save_redis "COUNTERS_DB" "COUNTERS_DB_$idx"
19241951

19251952
if [ "$asic_name" = "broadcom" ]; then
@@ -2028,6 +2055,7 @@ main() {
20282055

20292056
# Save reboot cause information
20302057
save_cmd "show reboot-cause" reboot.cause &
2058+
save_cmd "show reboot-cause history" "reboot.cause.history" &
20312059
wait
20322060

20332061
local asic="$(/usr/local/bin/sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)"
@@ -2458,7 +2486,16 @@ fi
24582486
##
24592487
## Attempt Locking
24602488
##
2461-
2489+
platform_name=$(show platform summary --json | python -c 'import sys, json; print(json.load(sys.stdin)["platform"])')
2490+
supervisor=0
2491+
PLATFORM_ENV_CONF=/usr/share/sonic/device/${platform_name}/platform_env.conf
2492+
if [ -f "$PLATFORM_ENV_CONF" ]; then
2493+
source $PLATFORM_ENV_CONF
2494+
fi
2495+
if [[ x"$supervisor" == x"1" ]]; then
2496+
IS_SUPERVISOR=true
2497+
fi
2498+
24622499
if $MKDIR "${LOCKDIR}" &>/dev/null; then
24632500
trap 'handle_exit' EXIT
24642501
echo "$$" > "${PIDFILE}"

0 commit comments

Comments
 (0)