Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[generate_dump] allow to extend dump with plugin scripts. #1335

Merged
merged 3 commits into from
Feb 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions scripts/generate_dump
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ DUMPDIR=/var/dump
TARDIR=$DUMPDIR/$BASE
TARFILE=$DUMPDIR/$BASE.tar
LOGDIR=$DUMPDIR/$BASE/dump
PLUGINS_DIR=/usr/local/bin/debug-dump
NUM_ASICS=1
HOME=${HOME:-/root}
USER=${USER:-root}
Expand Down Expand Up @@ -138,6 +139,7 @@ save_bcmcmd_all_ns() {
# cmd: The command to run. Make sure that arguments with spaces have quotes
# filename: the filename to save the output as in $BASE/dump
# do_gzip: (OPTIONAL) true or false. Should the output be gzipped
# save_stderr: (OPTIONAL) true or false. Should the stderr output be saved
# Returns:
# None
###############################################################################
Expand All @@ -148,10 +150,17 @@ save_cmd() {
local filename=$2
local filepath="${LOGDIR}/$filename"
local do_gzip=${3:-false}
local save_stderr=${4:-true}
local tarpath="${BASE}/dump/$filename"
local timeout_cmd="timeout --foreground ${TIMEOUT_MIN}m"
local redirect="&>"
[ ! -d $LOGDIR ] && $MKDIR $V -p $LOGDIR

if ! $save_stderr
then
redirect=">"
fi

# eval required here to re-evaluate the $cmd properly at runtime
# This is required if $cmd has quoted strings that should be bunched
# as one argument, e.g. vtysh -c "COMMAND HERE" needs to have
Expand All @@ -171,9 +180,9 @@ save_cmd() {
fi
else
if $NOOP; then
echo "${timeout_cmd} $cmd &> '$filepath'"
echo "${timeout_cmd} $cmd $redirect '$filepath'"
else
eval "${timeout_cmd} $cmd" &> "$filepath"
eval "${timeout_cmd} $cmd" "$redirect" "$filepath"
if [ $? -ne 0 ]; then
echo "Command: $cmd timedout after ${TIMEOUT_MIN} minutes."
fi
Expand Down Expand Up @@ -302,7 +311,7 @@ save_bridge() {
}

###############################################################################
# Dump the bridge L2 information
# Dump the bridge L2 information
# Globals:
# None
# Arguments:
Expand Down Expand Up @@ -509,8 +518,8 @@ save_proc() {
###############################################################################
# Dumps all fields and values from given Redis DB.
# Arguments:
# DB name: DB name
# Filename: Destination filename, if not given then filename would be DB name
# DB name: DB name
# Filename: Destination filename, if not given then filename would be DB name
# Returns:
# None
###############################################################################
Expand Down Expand Up @@ -1077,6 +1086,12 @@ main() {
save_cmd "docker ps -a" "docker.ps"
save_cmd "docker top pmon" "docker.pmon"

local -r dump_plugins="$(find ${PLUGINS_DIR} -type f -executable)"
for plugin in $dump_plugins; do
# save stdout output of plugin and gzip it
save_cmd "$plugin" "$(basename $plugin)" true false
done

save_saidump

if [[ "$asic" = "mellanox" ]]; then
Expand Down