]> arthur.barton.de Git - netdata.git/blob - charts.d/squid.chart.sh
minor fixes
[netdata.git] / charts.d / squid.chart.sh
1 #!/bin/sh
2
3 squid_url="http://127.0.0.1:8080/squid-internal-mgr/counters"
4
5 squid_check() {
6         # check once if the url works
7         wget 2>/dev/null -O /dev/null "$squid_url"
8         if [ ! $? -eq 0 ]
9         then
10                 echo >&2 "squid: cannot fetch the url: $squid_url. Please set squid_url='url' in $confd/squid.conf"
11                 return 1
12         fi
13
14         return 0
15 }
16
17 squid_create() {
18         # create the charts
19         cat <<EOF
20 CHART squid.clients_net '' "Squid Client Bandwidth" "kilobits/s" squid '' area 20001 $update_every
21 DIMENSION client_http_kbytes_in in incremental 8 1
22 DIMENSION client_http_kbytes_out out incremental -8 1
23 DIMENSION client_http_hit_kbytes_out hits incremental -8 1
24
25 CHART squid.clients_requests '' "Squid Client Requests" "requests/s" squid '' line 20003 $update_every
26 DIMENSION client_http_requests requests incremental 1 1
27 DIMENSION client_http_hits hits incremental 1 1
28 DIMENSION client_http_errors errors incremental -1 1
29
30 CHART squid.servers_net '' "Squid Server Bandwidth" "kilobits/s" squid '' area 20002 $update_every
31 DIMENSION server_all_kbytes_in in incremental 8 1
32 DIMENSION server_all_kbytes_out out incremental -8 1
33
34 CHART squid.servers_requests '' "Squid Server Requests" "requests/s" squid '' line 20004 $update_every
35 DIMENSION server_all_requests requests incremental 1 1
36 DIMENSION server_all_errors errors incremental -1 1
37 EOF
38         
39         return 0
40 }
41
42
43 squid_update() {
44         # do all the work to collect / calculate the values
45         # for each dimension
46
47         # get the values from squid
48         eval `wget 2>/dev/null -O - "$squid_url" | sed -e "s/\./_/g" -e "s/ = /=/g" | egrep "(^client_http_|^server_all_)"`
49
50         # write the result of the work.
51         cat <<VALUESEOF
52 BEGIN squid.clients_net
53 SET client_http_kbytes_in = $client_http_kbytes_in
54 SET client_http_kbytes_out = $client_http_kbytes_out
55 SET client_http_hit_kbytes_out = $client_http_hit_kbytes_out
56 END
57
58 BEGIN squid.clients_requests
59 SET client_http_requests = $client_http_requests
60 SET client_http_hits = $client_http_hits
61 SET client_http_errors = $client_http_errors
62 END
63
64 BEGIN squid.servers_net
65 SET server_all_kbytes_in = $server_all_kbytes_in
66 SET server_all_kbytes_out = $server_all_kbytes_out
67 END
68
69 BEGIN squid.servers_requests
70 SET server_all_requests = $server_all_requests
71 SET server_all_errors = $server_all_errors
72 END
73 VALUESEOF
74
75         return 0
76 }
77