From 26e700a86748e979cc17967f1f818db7f0a2ce7e Mon Sep 17 00:00:00 2001 From: Vivek Reddy Date: Tue, 7 Sep 2021 14:35:38 -0700 Subject: [PATCH] [debug dump util] Techsupport addition (#1669) What I did HLD for Dump Utility: HLD. For More info on Tech Support Addition: TechSupport How I did it Module Names are retrieved by parsing the output of dump state --show command. --- scripts/generate_dump | 38 +++++++++++++++++++++++++++++++++++++- show/main.py | 7 ++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/scripts/generate_dump b/scripts/generate_dump index bc33c0bcc858..91d632c49e54 100755 --- a/scripts/generate_dump +++ b/scripts/generate_dump @@ -38,6 +38,7 @@ HOME=${HOME:-/root} USER=${USER:-root} TIMEOUT_MIN="5" SKIP_BCMCMD=0 +DEBUG_DUMP=false handle_signal() { @@ -1018,6 +1019,31 @@ save_counter_snapshot() { save_cmd_all_ns "ifconfig -a" "ifconfig.counters_$idx" } +############################################################################### +# save the debug dump output +############################################################################### +save_dump_state_all_ns() { + MODULES="$(dump state -s | sed '1d;2d' | awk '{print $1}')" + local UVDUMP="unified_view_dump" + echo "DEBUG DUMP: Modules Available to Generate Debug Dump Output" + echo $MODULES + $MKDIR $V -p $LOGDIR/$UVDUMP + + for addr in $MODULES; + do + save_cmd "dump state $addr all --key-map" "$UVDUMP/$addr" + if [[ ( "$NUM_ASICS" > 1 ) ]] ; then + for (( i=0; i<$NUM_ASICS; i++ )) + do + local cmd="dump state $addr all --key-map --namespace asic$i" + local file="$UVDUMP/$addr.asic$i" + save_cmd "$cmd" "$file" + done + fi + done +} + + ############################################################################### # Main generate_dump routine # Globals: @@ -1130,6 +1156,11 @@ main() { save_bfd_info save_redis_info + if $DEBUG_DUMP + then + save_dump_state_all_ns + fi + save_cmd "docker ps -a" "docker.ps" save_cmd "docker top pmon" "docker.pmon" @@ -1265,11 +1296,13 @@ OPTIONS "24 March", "yesterday", etc. -t TIMEOUT_MINS Command level timeout in minutes + -d + Collect the output of debug dump cli EOF } -while getopts ":xnvhzas:t:" opt; do +while getopts ":xnvhzas:t:d" opt; do case $opt in x) # enable bash debugging @@ -1311,6 +1344,9 @@ while getopts ":xnvhzas:t:" opt; do t) TIMEOUT_MIN="${OPTARG}" ;; + d) + DEBUG_DUMP=true + ;; /?) echo "Invalid option: -$OPTARG" >&2 exit 1 diff --git a/show/main.py b/show/main.py index 2a6bf73692b4..68a291939a9b 100755 --- a/show/main.py +++ b/show/main.py @@ -1066,7 +1066,8 @@ def users(verbose): @click.option('--verbose', is_flag=True, help="Enable verbose output") @click.option('--allow-process-stop', is_flag=True, help="Dump additional data which may require system interruption") @click.option('--silent', is_flag=True, help="Run techsupport in silent mode") -def techsupport(since, global_timeout, cmd_timeout, verbose, allow_process_stop, silent): +@click.option('--debug-dump', is_flag=True, help="Collect Debug Dump Output") +def techsupport(since, global_timeout, cmd_timeout, verbose, allow_process_stop, silent, debug_dump): """Gather information for troubleshooting""" cmd = "sudo timeout -s SIGTERM --foreground {}m".format(global_timeout) @@ -1081,6 +1082,10 @@ def techsupport(since, global_timeout, cmd_timeout, verbose, allow_process_stop, if since: cmd += " -s '{}'".format(since) + + if debug_dump: + cmd += " -d " + cmd += " -t {}".format(cmd_timeout) run_command(cmd, display_cmd=verbose)