summaryrefslogtreecommitdiffstats
path: root/charts.d/squid.chart.sh
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2014-12-23 00:06:30 +0200
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2014-12-23 00:06:30 +0200
commit9a5715d759a00571c0d146aa2cdfc591082ded57 (patch)
tree4207e9bcc8831fd7d0fe7df95d000862bbc0c2a9 /charts.d/squid.chart.sh
parent34f3851488fe475373b27807eaf66930300f7f4e (diff)
now it queries cache_object with nc, instead of wget
Diffstat (limited to 'charts.d/squid.chart.sh')
-rwxr-xr-xcharts.d/squid.chart.sh20
1 files changed, 14 insertions, 6 deletions
diff --git a/charts.d/squid.chart.sh b/charts.d/squid.chart.sh
index e59a9c58da..7b3434e2b3 100755
--- a/charts.d/squid.chart.sh
+++ b/charts.d/squid.chart.sh
@@ -1,14 +1,22 @@
#!/bin/sh
-squid_url="http://127.0.0.1:8080/squid-internal-mgr/counters"
+squid_host="127.0.0.1"
+squid_port="3128"
squid_update_every=5
+squid_get_stats() {
+nc $squid_host $squid_port <<EOF
+GET cache_object://$squid_host:$squid_port/counters HTTP/1.0
+
+EOF
+}
+
squid_check() {
# check once if the url works
- wget 2>/dev/null -O /dev/null "$squid_url"
- if [ ! $? -eq 0 ]
+ local x=`squid_get_stats | grep client_http.requests`
+ if [ ! $? -eq 0 -o -z "$x" ]
then
- echo >&2 "squid: cannot fetch the counters url: $squid_url. Please set squid_url='url' in $confd/squid.conf"
+ echo >&2 "squid: cannot fetch the counters from $squid_host:$squid_port. Please set squid_host='host' and squid_port='port' in $confd/squid.conf"
return 1
fi
@@ -60,8 +68,8 @@ squid_update() {
# prepare the script and always grep at the end the lines that are usefull, so that
# even if something goes wrong, no other code can be executed
- eval "`wget 2>/dev/null -O - "$squid_url" |\
- sed -e "s/ \+/ /g" -e "s/\./_/g" -e "s/ = /=/g" -e "s/^/local squid_/g" |\
+ eval "`squid_get_stats |\
+ sed -e "s/ \+/ /g" -e "s/\./_/g" -e "s/^\([a-z0-9_]\+\) *= *\([0-9]\+\)$/local squid_\1=\2/g" |\
egrep "^local squid_(client_http|server_all)_[a-z0-9_]+=[0-9]+$"`"
# write the result of the work.