Skip to content

Instantly share code, notes, and snippets.

@hostmaster
Forked from noahcampbell/squid.bash
Created October 18, 2013 10:09
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 hostmaster/7039411 to your computer and use it in GitHub Desktop.
Save hostmaster/7039411 to your computer and use it in GitHub Desktop.
# Steps for turning on squid monitoring (until I have an rpm)
cat > /etc/collectd.d/squid << EOF
LoadPlugin exec
<Plugin exec>
Exec deploy "/var/lib/releng/monitoring/squid"
</Plugin>
EOF
mkdir -p /var/lib/releng/monitoring
cat > /var/lib/releng/monitoring/squid << EOF
#!/bin/sh
INTERVAL=${COLLETD_INTERVAL:-10}
HOSTNAME=`</etc/rightscale.d/booted`
while sleep $INTERVAL; do
squidclient -p 80 cache_object://localhost/counters | awk -v interval=${INTERVAL} -v host=${HOSTNAME} -F ' = ' '/client_http..*/ { gsub("\\.", "_", $1); print "PUTVAL", host"/squid/counter-"$1, "interval="interval, "N:"$2 }'
done
EOF
chmod a+x /var/lib/releng/monitoring/squid
/etc/init.d/collectd restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment