3 url="http://127.0.0.1:8080/squid-internal-mgr/counters"
5 # report our PID back to netdata
6 # this is required for netdata to kill this process when it exits
9 # default sleep function
13 # if found and included, this file overwrites loopsleepms()
14 # with a high resolution timer function for precise looping.
15 . "`dirname $0`/loopsleepms.sh.inc"
17 # netdata passes the requested update frequency as the first argument
19 update_every=$(( update_every + 1 - 1)) # makes sure it is a number
20 test $update_every -eq 0 && update_every=1 # if it is zero, make it 1
22 # we accept a url as the second argument
28 # check once if the url works
29 wget 2>/dev/null -O /dev/null "$url"
32 # it does not work - disable the plugin
39 CHART squid.client_bandwidth '' "Squid Client Bandwidth" "kilobits/s" squid squid area 1 $update_every
40 DIMENSION client_http_kbytes_in in incremental 8 1
41 DIMENSION client_http_kbytes_out out incremental -8 1
42 DIMENSION client_http_hit_kbytes_out hits incremental -8 1
44 CHART squid.client_requests '' "Squid Client Requests" "requests/s" squid squid line 3 $update_every
45 DIMENSION client_http_requests requests incremental 1 1
46 DIMENSION client_http_hits hits incremental 1 1
47 DIMENSION client_http_errors errors incremental -1 1
49 CHART squid.server_bandwidth '' "Squid Server Bandwidth" "kilobits/s" squid squid area 2 $update_every
50 DIMENSION server_all_kbytes_in in incremental 8 1
51 DIMENSION server_all_kbytes_out out incremental -8 1
53 CHART squid.server_requests '' "Squid Server Requests" "requests/s" squid squid line 4 $update_every
54 DIMENSION server_all_requests requests incremental 1 1
55 DIMENSION server_all_errors errors incremental -1 1
58 # You can create more charts if you like.
59 # Just add more chart definitions.
64 # do all the work to collect / calculate the values
67 # get the values from squid
68 eval `wget 2>/dev/null -O - "$url" | sed -e "s/\./_/g" -e "s/ = /=/g" | egrep "(^client_http_|^server_all_)"`
70 # write the result of the work.
72 BEGIN squid.client_bandwidth
73 SET client_http_kbytes_in = $client_http_kbytes_in
74 SET client_http_kbytes_out = $client_http_kbytes_out
75 SET client_http_hit_kbytes_out = $client_http_hit_kbytes_out
78 BEGIN squid.client_requests
79 SET client_http_requests = $client_http_requests
80 SET client_http_hits = $client_http_hits
81 SET client_http_errors = $client_http_errors
84 BEGIN squid.server_bandwidth
85 SET server_all_kbytes_in = $server_all_kbytes_in
86 SET server_all_kbytes_out = $server_all_kbytes_out
89 BEGIN squid.server_requests
90 SET server_all_requests = $server_all_requests
91 SET server_all_errors = $server_all_errors
95 # wait the time you are required to
96 loopsleepms $update_every