Skip to content

Instantly share code, notes, and snippets.

@johnl
Created November 20, 2020 23:08
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 johnl/9e7b39f87baa3b240d6a09b1e517007d to your computer and use it in GitHub Desktop.
Save johnl/9e7b39f87baa3b240d6a09b1e517007d to your computer and use it in GitHub Desktop.
collectd script to report ipt hashtable sizes
<Plugin exec>
Exec "nobody" "/usr/local/bin/collectd_ipt_hashtable.sh"
</Plugin>
#!/bin/sh
HOSTNAME="${COLLECTD_HOSTNAME:-localhost}"
INTERVAL="${COLLECTD_INTERVAL:-60}"
cd /proc/net
while sleep "$INTERVAL"; do
wc -l ip{6t,t}_hashlimit/* 2>/dev/null | while read count filename ; do
metric=""
case "$filename" in
total)
continue
;;
ip6*)
metric="ipv6-${filename##*/}"
;;
ipt*)
metric="ipv4-${filename##*/}"
;;
esac
echo "PUTVAL \"$HOSTNAME/ipt_hashlimit_count/gauge-$metric\" interval=$INTERVAL N:$count"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment