From c0b2416abdb02f880ec0f900fb601ed1866bfd4e Mon Sep 17 00:00:00 2001 From: shlomibitton <60430976+shlomibitton@users.noreply.github.com> Date: Mon, 13 Apr 2020 07:40:12 +0300 Subject: [PATCH] Add platform options to 'show techsupport' command (#865) Signed-off-by: Shlomi Bitton --- scripts/generate_dump | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/scripts/generate_dump b/scripts/generate_dump index 105247e0238e..7d6ce5f55a27 100755 --- a/scripts/generate_dump +++ b/scripts/generate_dump @@ -199,6 +199,37 @@ save_redis() { save_cmd "sonic-db-dump -n '$db_name' -y" "$db_name.json" } +############################################################################### +# Runs a 'show platform' command, append the output to 'filename' and add to the incrementally built tar. +# Globals: +# LOGDIR +# BASE +# MKDIR +# TAR +# TARFILE +# DUMPDIR +# V +# RM +# Arguments: +# type: the type of platform information +# filename: the filename to save the output as in $BASE/dump +# Returns: +# None +############################################################################### +save_platform() { + local type="$1" + local filename=$2 + local filepath="${LOGDIR}/$filename" + local tarpath="${BASE}/dump/$filename" + [ ! -d $LOGDIR ] && $MKDIR $V -p $LOGDIR + + eval "show platform $type" &>> "$filepath" + echo $'\r' >> "$filepath" + + ($TAR $V -uhf $TARFILE -C $DUMPDIR "$tarpath" \ + || abort "${ERROR_TAR_FAILED}" "tar append operation failed. Aborting to prevent data loss.") +} + ############################################################################### # Runs a comamnd and saves its output to the incrementally built tar. # Globals: @@ -327,17 +358,20 @@ main() { /proc/zoneinfo \ || abort "${ERROR_PROCFS_SAVE_FAILED}" "Proc saving operation failed. Aborting for safety." + save_platform "syseeprom" "platform" + save_platform "psustatus" "platform" + save_platform "ssdhealth" "platform" + save_platform "temperature" "platform" + save_platform "fan" "platform" + save_cmd "show version" "version" save_cmd "show platform summary" "platform.summary" - save_cmd "show platform syseeprom" "platform.syseeprom" save_cmd "cat /host/machine.conf" "machine.conf" save_cmd "docker stats --no-stream" "docker.stats" save_cmd "sensors" "sensors" - save_cmd "show platform psustatus" "platform.psustatus" save_cmd "lspci -vvv -xx" "lspci" save_cmd "lsusb -v" "lsusb" - save_cmd "sysctl -a" "sysctl" save_ip "link" "link" save_ip "addr" "addr"