Skip to content

Commit

Permalink
[show_tech] Filter out a list of commands in generate_dump script whi…
Browse files Browse the repository at this point in the history
…ch 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]>
  • Loading branch information
mlok-nokia authored Dec 5, 2024
1 parent b767cb8 commit 28e645f
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions scripts/generate_dump
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ SAVE_STDERR=true
RETURN_CODE=$EXT_SUCCESS
DEBUG_DUMP=false
ROUTE_TAB_LIMIT_DIRECT_ITERATION=24000
IS_SUPERVISOR=false

# lock dirs/files
LOCKDIR="/tmp/techsupport-lock"
Expand Down Expand Up @@ -532,8 +533,11 @@ save_bgp_neighbor() {
save_cmd "vtysh $ns -c \"show bgp ipv6 neighbors $word advertised-routes\"" "ipv6.bgp.neighbor.$word.adv$asic_id"
save_cmd "vtysh $ns -c \"show bgp ipv6 neighbors $word routes\"" "ipv6.bgp.neighbor.$word.rcv$asic_id"
done

vrf_list=`${timeout_cmd} bash -c "vtysh $ns -c 'show vrf' | awk -F" " '{print \$2}'"`
vrf_list=""
vrf_output=$(${timeout_cmd} bash -c "vtysh $ns -c 'show vrf'")
if [ ! -z $vrf_output]; then
vrf_list= echo $vrf_output | awk -F" " '{print $2}'
fi
for vrf in $vrf_list; do
neighbor_list=`${timeout_cmd} bash -c "vtysh $ns -c 'show ip bgp vrf $vrf neighbors' | grep 'BGP neighbor is' | awk -F '[, ]' '{print \$4}'"`
for word in $neighbor_list; do
Expand Down Expand Up @@ -651,6 +655,9 @@ save_nat_info() {
###############################################################################
save_bfd_info() {
trap 'handle_error $? $LINENO' ERR
if $IS_SUPERVISOR; then
return
fi
save_vtysh "show bfd peers" "frr.bfd.peers"
save_vtysh "show bfd peers counters" "frr.bfd.peers.counters"
save_vtysh "show bfd peers json" "frr.bfd.peers.json"
Expand Down Expand Up @@ -688,6 +695,9 @@ save_ip_info() {
###############################################################################
save_bgp_info() {
trap 'handle_error $? $LINENO' ERR
if $IS_SUPERVISOR; then
return
fi
save_vtysh "show ip bgp summary" "bgp.summary"
save_vtysh "show ip bgp neighbors" "bgp.neighbors"
save_vtysh "show ip bgp" "bgp.table"
Expand Down Expand Up @@ -725,6 +735,9 @@ save_bgp_info() {
###############################################################################
save_evpn_info() {
trap 'handle_error $? $LINENO' ERR
if $IS_SUPERVISOR; then
return
fi
save_vtysh "show bgp l2vpn evpn" "bgp.l2vpn.evpn"
save_vtysh "show bgp l2vpn evpn summary json" "bgp.evpn.summary.json"
save_vtysh "show bgp l2vpn evpn route" "bgp.evpn.route"
Expand Down Expand Up @@ -758,6 +771,9 @@ save_evpn_info() {
###############################################################################
save_frr_info() {
trap 'handle_error $? $LINENO' ERR
if $IS_SUPERVISOR; then
return
fi
save_vtysh "show running-config" "frr.running_config"
save_vtysh "show ip route vrf all nexthop-group" "frr.ip_route.nhg"
save_vtysh "show ipv6 route vrf all nexthop-group" "frr.ip6_route.nhg"
Expand Down Expand Up @@ -1141,6 +1157,9 @@ find_files() {
# None
###############################################################################
disable_logrotate() {
if [ ! -f "/etc/cron.d/logrotate" ]; then
return
fi
sed -i '/\/usr\/sbin\/logrotate/s/^/#/g' /etc/cron.d/logrotate
}

Expand All @@ -1154,6 +1173,9 @@ disable_logrotate() {
# None
###############################################################################
enable_logrotate() {
if [ ! -f "/etc/cron.d/logrotate" ]; then
return
fi
sed -i '/\/usr\/sbin\/logrotate/s/^#*//g' /etc/cron.d/logrotate
}

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

save_cmd "echo $counter_t" "date.counter_$idx"
save_cmd "show interface counters" "interface.counters_$idx"
save_cmd_all_ns "show queue counters" "queue.counters_$idx"
if ! $IS_SUPERVISOR; then
save_cmd_all_ns "show queue counters" "queue.counters_$idx"
fi
save_redis "COUNTERS_DB" "COUNTERS_DB_$idx"

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

# Save reboot cause information
save_cmd "show reboot-cause" reboot.cause &
save_cmd "show reboot-cause history" "reboot.cause.history" &
wait

local asic="$(/usr/local/bin/sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)"
Expand Down Expand Up @@ -2458,7 +2486,16 @@ fi
##
## Attempt Locking
##

platform_name=$(show platform summary --json | python -c 'import sys, json; print(json.load(sys.stdin)["platform"])')
supervisor=0
PLATFORM_ENV_CONF=/usr/share/sonic/device/${platform_name}/platform_env.conf
if [ -f "$PLATFORM_ENV_CONF" ]; then
source $PLATFORM_ENV_CONF
fi
if [[ x"$supervisor" == x"1" ]]; then
IS_SUPERVISOR=true
fi

if $MKDIR "${LOCKDIR}" &>/dev/null; then
trap 'handle_exit' EXIT
echo "$$" > "${PIDFILE}"
Expand Down

0 comments on commit 28e645f

Please sign in to comment.