Skip to content

Instantly share code, notes, and snippets.

@aclemmensen
Created November 10, 2016 09:51
Show Gist options
  • Save aclemmensen/9cb8d11da0d7f07f663ebe5c71f4ec29 to your computer and use it in GitHub Desktop.
Save aclemmensen/9cb8d11da0d7f07f663ebe5c71f4ec29 to your computer and use it in GitHub Desktop.
Put squid stats into Statsd
#!/bin/bash
i=0
while true; do
echo "Sending batch $i"
i=$(($i+1))
/opt/si-squid/bin/squidclient cache_object://localhost/counters \
| awk '
BEGIN { p=0 }
/^sample_time/ { p=1 }
{
if(p > 1) printf("sistats.squid.%s:%d|g\n", $1, $3)
if(p > 0) p = p+1
}' \
| nc -C -u -w1 127.0.0.1 8125
sleep 30
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment