Skip to content

Instantly share code, notes, and snippets.

@niedbalski
Last active December 3, 2019 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niedbalski/9a8648490f7633d48f20776014b2ced8 to your computer and use it in GitHub Desktop.
Save niedbalski/9a8648490f7633d48f20776014b2ced8 to your computer and use it in GitHub Desktop.
sockstats-report.sh
#!/bin/bash
# gather metrics about sockstat and buffer size.
currdate=$(date +"%m-%d-%Y")
timeout=${1:-600}
every=${2:-1}
basepath=${3:-./sockstat-report-${currdate}/}
function watch_it() {
timeout $1 watch -t -n $2 "cat $3 | tee -a ${basepath}$(basename ${3})_${currdate}.log" &>/dev/null &
}
function main() {
test -d $basepath || mkdir ${basepath}
for f in $(ls /proc/sys/net/ipv4/tcp*mem /proc/net/sockstat); do
watch_it $1 $2 $f
done
timeout $1 watch -t -n $2 "ss -m --info -t4 | tee -a ${basepath}ss_${currdate}.log" &>/dev/null &
timeout $1 sar -n EDEV -n SOCK 1 | tee -a ${basepath}sar_edev_${currdate}.log &>/dev/null &
}
main ${timeout} ${every}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment