Skip to content

Commit 0430083

Browse files
[generate_dump] allow to extend dump with plugin scripts. (#1335)
- What I did Added support for tech support extension scripts. - How I did it It looks at /usr/bin/debug-dump for scripts, if it finds one it will execute them and save the output to dump/ folder. - How to verify it Write a simple scripts that outputs something and place it under /usr/bin/debug-dump/ Signed-off-by: Stepan Blyshchak <[email protected]>
1 parent f0ac6e0 commit 0430083

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

scripts/generate_dump

+17-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ DUMPDIR=/var/dump
3232
TARDIR=$DUMPDIR/$BASE
3333
TARFILE=$DUMPDIR/$BASE.tar
3434
LOGDIR=$DUMPDIR/$BASE/dump
35+
PLUGINS_DIR=/usr/local/bin/debug-dump
3536
NUM_ASICS=1
3637
HOME=${HOME:-/root}
3738
USER=${USER:-root}
@@ -138,6 +139,7 @@ save_bcmcmd_all_ns() {
138139
# cmd: The command to run. Make sure that arguments with spaces have quotes
139140
# filename: the filename to save the output as in $BASE/dump
140141
# do_gzip: (OPTIONAL) true or false. Should the output be gzipped
142+
# save_stderr: (OPTIONAL) true or false. Should the stderr output be saved
141143
# Returns:
142144
# None
143145
###############################################################################
@@ -148,10 +150,17 @@ save_cmd() {
148150
local filename=$2
149151
local filepath="${LOGDIR}/$filename"
150152
local do_gzip=${3:-false}
153+
local save_stderr=${4:-true}
151154
local tarpath="${BASE}/dump/$filename"
152155
local timeout_cmd="timeout --foreground ${TIMEOUT_MIN}m"
156+
local redirect="&>"
153157
[ ! -d $LOGDIR ] && $MKDIR $V -p $LOGDIR
154158

159+
if ! $save_stderr
160+
then
161+
redirect=">"
162+
fi
163+
155164
# eval required here to re-evaluate the $cmd properly at runtime
156165
# This is required if $cmd has quoted strings that should be bunched
157166
# as one argument, e.g. vtysh -c "COMMAND HERE" needs to have
@@ -171,9 +180,9 @@ save_cmd() {
171180
fi
172181
else
173182
if $NOOP; then
174-
echo "${timeout_cmd} $cmd &> '$filepath'"
183+
echo "${timeout_cmd} $cmd $redirect '$filepath'"
175184
else
176-
eval "${timeout_cmd} $cmd" &> "$filepath"
185+
eval "${timeout_cmd} $cmd" "$redirect" "$filepath"
177186
if [ $? -ne 0 ]; then
178187
echo "Command: $cmd timedout after ${TIMEOUT_MIN} minutes."
179188
fi
@@ -1076,6 +1085,12 @@ main() {
10761085
save_cmd "docker ps -a" "docker.ps"
10771086
save_cmd "docker top pmon" "docker.pmon"
10781087

1088+
local -r dump_plugins="$(find ${PLUGINS_DIR} -type f -executable)"
1089+
for plugin in $dump_plugins; do
1090+
# save stdout output of plugin and gzip it
1091+
save_cmd "$plugin" "$(basename $plugin)" true false
1092+
done
1093+
10791094
save_saidump
10801095

10811096
if [[ "$asic" = "mellanox" ]]; then

0 commit comments

Comments
 (0)