Skip to content

Instantly share code, notes, and snippets.

@niedbalski
Created December 3, 2019 17:26
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/4b4273bf5ab4f56eac5ac450ea167b7b to your computer and use it in GitHub Desktop.
Save niedbalski/4b4273bf5ab4f56eac5ac450ea167b7b to your computer and use it in GitHub Desktop.
check-sockstats.sh
#!/bin/bash
#
# gather metrics about sockstat and buffer size.
#
timeout=${1:-600}
every=${2:-1}
function watch_it() {
timeout $1 watch -t -n $2 "cat $3 | tee -a $(basename ${3})_$(date +"%m-%d-%Y").log" &>/dev/null &
}
function main() {
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 ss_$(date +"%m-%d-%Y").log" &>/dev/null &
timeout $1 sar -n EDEV -n SOCK 1 > sar_edev_$(date +"%m-%d-%Y").log &>/dev/null &
}
main ${timeout} ${every}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment