From 40cc8e11582e40fdf35f105b771a9a28ea7c65d9 Mon Sep 17 00:00:00 2001 From: LimorAmit <101063411+LimorAmit@users.noreply.github.com> Date: Mon, 31 Oct 2022 08:56:08 +0200 Subject: [PATCH] [scripts/generate_dump] add information to tech-support file (#2357) #### What I did I added/extended some commands of the generate_dump script to collect more information about the system and processes. In addition, I removed some errors when trying to remove files that don't exist. #### How I did it create new function and add new calls for commands to get more information. Regarding the error messages - I checked before removing the files and remove with force parameter. #### How to verify it verified that the new files and information are part of the dump --- scripts/generate_dump | 66 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/scripts/generate_dump b/scripts/generate_dump index ac7feb4932..57bc6460e8 100755 --- a/scripts/generate_dump +++ b/scripts/generate_dump @@ -658,6 +658,7 @@ save_ip_info() { save_ip "route show table all" "route" save_ip "neigh" "neigh" save_ip "-s neigh show nud noarp" "neigh.noarp" + save_ip "-s link" "link.stats" } ############################################################################### @@ -773,6 +774,59 @@ save_proc() { $RM $V -rf $TARDIR/proc } +############################################################################### +# Dump io stats for processes +# Globals: +# V +# TARDIR +# MKDIR +# CP +# DUMPDIR +# TAR +# RM +# BASE +# TARFILE +# NOOP +# Arguments: +# None +# Returns: +# None +############################################################################### +save_proc_stats() { + trap 'handle_error $? $LINENO' ERR + $MKDIR $V -p $TARDIR/proc_stats + + local stats_file=/tmp/stats + echo > $stats_file + for pid in /proc/[[:digit:]]* + do + pid_num=${pid//[!0-9]/} + cmdline=`eval ps -p $pid_num -o args --no-headers` + if test -n "$cmdline"; then + echo pid $pid + echo cmdline: $cmdline + cat $pid/io; echo + else + #Dump also internal kernel processes if they perform writes + write_bytes=$(cat $pid/io | grep -w write_bytes: | cut -b 14-) + if [ "$write_bytes" != "0" ]; then + echo pid $pid - `cat $pid/comm`: + cat $pid/io; echo + fi + fi + done >> $stats_file 2>&1 + + if $NOOP; then + echo "$CP $V -r $stats_file $TARDIR/proc_stats" + else + ( $CP $V -r $stats_file $TARDIR/proc_stats ) || echo "$stats_file error" > $TARDIR/$stats_file + fi + + $TAR $V -rhf $TARFILE -C $DUMPDIR --mode=+rw $BASE/proc_stats + $RM $V -rf $TARDIR/proc_stats + $RM -rf $stats_file +} + ############################################################################### # Dumps all fields and values from given Redis DB. # Arguments: @@ -830,7 +884,7 @@ save_platform_info() { if [[ ! $PLATFORM =~ .*(mlnx|nvidia).*simx.* ]]; then save_cmd "show platform syseeprom" "syseeprom" save_cmd "show platform psustatus" "psustatus" - save_cmd "show platform ssdhealth" "ssdhealth" + save_cmd "show platform ssdhealth --vendor" "ssdhealth" save_cmd "show platform temperature" "temperature" save_cmd "show platform fan" "fan" fi @@ -1412,6 +1466,7 @@ main() { /proc/uptime /proc/version /proc/vmallocinfo /proc/vmstat \ /proc/zoneinfo \ || abort "${EXT_PROCFS_SAVE_FAILED}" "Proc saving operation failed. Aborting for safety." + save_proc_stats end_t=$(date +%s%3N) echo "[ Capture Proc State ] : $(($end_t-$start_t)) msec" >> $TECHSUPPORT_TIME_INFO @@ -1435,6 +1490,7 @@ main() { save_cmd "show version" "version" save_cmd "show platform summary" "platform.summary" save_cmd "cat /host/machine.conf" "machine.conf" + save_cmd "cat /boot/config-$(uname -r)" "boot.conf" save_cmd "docker stats --no-stream" "docker.stats" save_cmd "sensors" "sensors" @@ -1498,6 +1554,12 @@ main() { done fi + save_cmd "dpkg -l" "dpkg" + save_cmd "who -a" "who" + save_cmd "swapon -s" "swapon" + save_cmd "hdparm -i /dev/sda" "hdparm" + save_cmd "ps -AwwL -o user,pid,lwp,ppid,nlwp,pcpu,pri,nice,vsize,rss,tty,stat,wchan:12,start,bsdtime,command" "ps.extended" + save_saidump if [ "$asic" = "barefoot" ]; then @@ -1527,7 +1589,7 @@ main() { rm_list=$(find -L $TARDIR/etc -maxdepth 5 -type l) if [ ! -z "$rm_list" ] then - rm $rm_list + rm -f $rm_list fi # Remove secret from /etc files before tar