Skip to content

Instantly share code, notes, and snippets.

@nmicic
Last active March 13, 2020 11:30
Show Gist options
  • Select an option

  • Save nmicic/c04a9400ef39576e2d284aacf68bf99b to your computer and use it in GitHub Desktop.

Select an option

Save nmicic/c04a9400ef39576e2d284aacf68bf99b to your computer and use it in GitHub Desktop.
i40e_dump.sh
#!/bin/sh
### nmicic@cisco.com
### https://gist.github.com/nmicic/c04a9400ef39576e2d284aacf68bf99b ###
function help_message {
echo
echo "NOTE1: Script may cause kernel panic or reboot of the host! High risk running in production!"
echo "NOTE2: Script will clear dmesg. Please be aware! "man dmesg" for more info!"
echo "NOTE3: To run script execute: $0 run"
echo
}
if [ $# -eq 0 ];then
help_message >&2
exit 0
fi
if [ $1 == "run" ];then
echo "***** Aware of the risks! Executing script ****"
else
help_message >&2
fi
DEBUG=0
test $DEBUG -ne 0 && set -vx
SLEEPFLAG=1
SLEEPVAL=0.1
DATE=`date +%Y_%m_%d__%H_%M_%S___%s`
date +%Y_%m_%d__%H_%M_%S___%s
TARDIR=dump_i40e_"$DATE"
DIR=/tmp/"$TARDIR"
mkdir -p "$DIR"
cd "$DIR"
TESTpwd=`pwd | grep dump_i40e_ | wc -l`
test $TESTpwd -ne 1 && echo "ERROR not in /tmp/dump_i40e_ directory:" `pwd` && exit
dmesg -T > pre_dmesg_T__"$DATE".txt
dmesg -c > pre_dmesg__"$DATE".txt
ip -s link show > ip_-s_link_show.txt
ip link show > ip__link_show.txt
COMMAND=( $( find /sys/kernel/debug/i40e/ -name command ))
function run_ethtool {
ethtoolCLI=("ethtool" "ethtool -S" "ethtool -i" "ethtool -k" "ethtool -g" "ethtool -a" "ethtool -l" "ethtool -x" "ethtool -d" "ethtool -T" "ethtool -c")
for ethCMD in "${ethtoolCLI[@]}";do
echo $ethCMD $NICname
ethFile=`echo $ethCMD $NICname | sed -e "s/[^[:alnum:]]/_/g"`
$ethCMD $NICname > "$FILE_PREFIX"__"$ethFile"__`date +%s`.txt
test $SLEEPFLAG -ne 0 && sleep $SLEEPVAL
done
}
function run_dumCLI {
dumpCLI=("dump capabilities" "dump resources" "dump port" "dump filters" "dump desc aq" "dump switch")
for dumpCMD in "${dumpCLI[@]}";do
echo $dumpCMD > $CMD
dumpFile=`echo $dumpCMD | sed -e "s/[^[:alnum:]]/_/g"`
dmesg -Tc > "$FILE_PREFIX"__"$dumpFile"__`date +%s`.txt
test $SLEEPFLAG -ne 0 && sleep $SLEEPVAL
done
}
function run_VsiRings {
echo "dump switch" > $CMD
dmesg -Tc > "$FILE_PREFIX"__dump_switch.txt
export CMD
unixTime=`date +%s`
SeidVSI=( $( grep $NIC "$FILE_PREFIX"__dump_switch.txt | grep seid | grep -v ^$ | awk -Fseid= '{print $2}' | awk '{print $1}'))
for SEID in "${SeidVSI[@]}";do
echo === $NIC === $SEID ===
echo dump vsi "$SEID" > "$CMD"
FileSEID="$FILE_PREFIX"__dump_vsi__"$SEID"__seid__"$unixTime".txt
dmesg -cT > $FileSEID
TXRINGS=( $(grep tx_rings $FileSEID | awk -Ftx_rings '{print $2}' | awk '{print $1}' | sed -e "s/[^[:alnum:]]//g" | sort -n | uniq))
for RING in "${TXRINGS[@]}";do
echo === $NIC === $SEID === $RING ===
echo dump desc tx $SEID $RING > $CMD
dmesg -cT >"$FILE_PREFIX"__dump_desc_tx__"$SEID"__"$RING"__`date +%s`.txt
test $SLEEPFLAG -ne 0 && sleep $SLEEPVAL
done;
RXRINGS=( $(grep rx_rings $FileSEID | awk -Frx_rings '{print $2}' | awk '{print $1}' | sed -e "s/[^[:alnum:]]//g" | sort -n | uniq))
for RING in "${RXRINGS[@]}";do
echo === $NIC === $SEID === $RING ===
echo dump desc rx $SEID $RING > $CMD
dmesg -cT >"$FILE_PREFIX"__dump_desc_rx__"$SEID"__"$RING"__`date +%s`.txt
test $SLEEPFLAG -ne 0 && sleep $SLEEPVAL
done;
done
}
for CMD in "${COMMAND[@]}";do
echo === $CMD ===
NIC=`echo $CMD | awk -F/ '{print $6}'`
NICfile=`echo $NIC | sed -e "s/[^[:alnum:]]/_/g"`
NICname=`find /sys/class/net/ -type l -ls | grep pci | grep $NIC | awk -F/ '{print $NF}' | head -1`
echo === $NIC === $NICname ===
FILE_PREFIX=dump_i40e__"$NICfile"
echo $CMD
run_ethtool
run_dumCLI
run_VsiRings
echo "Sleep 1 second. Please wait..."
sleep 1
run_ethtool
run_dumCLI
run_VsiRings
done
cd /tmp
tar zcf "$TARDIR".tar.gz "$TARDIR"
rm -rf $DIR
echo
echo "Please upload file: "$DIR".tar.gz"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment