Skip to content

Instantly share code, notes, and snippets.

@noahcampbell
Created April 14, 2011 00:01
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save noahcampbell/918684 to your computer and use it in GitHub Desktop.
Save noahcampbell/918684 to your computer and use it in GitHub Desktop.
Collectd script for squid
# 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
@shish
Copy link

shish commented Mar 24, 2015

COLLETD_INTERVAL - should be COLLECTD_INTERVAL?

@Neurobion
Copy link

I did exactly same as you provide and it doesn't work. Respectively I'm getting some incorrect data. Did you also customize types.db?

rrdtool dump counter-client_http_requests.rrd > test.xml

Couple of lines:

                    <!-- 2016-03-22 12:20:30 CET / 1458645630 --> <row><v>1.0000000000e-01</v></row>
                    <!-- 2016-03-22 12:20:40 CET / 1458645640 --> <row><v>1.0000000000e-01</v></row>
                    <!-- 2016-03-22 12:20:50 CET / 1458645650 --> <row><v>9.5454545455e-02</v></row>
                    <!-- 2016-03-22 12:21:00 CET / 1458645660 --> <row><v>9.4545454545e-02</v></row>

Output from CLI is correct:

PUTVAL xx/squid/counter-client_http_requests interval= N:49749

@wrzasa
Copy link

wrzasa commented Jul 8, 2016

No, it is not correct. Fix the typo mentioned by @shish and it will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment