@cryptotaxi247 / netdata-1 / commits / bf25cf6ec

more HTTP compliance

Costa Tsaousis (ktsaou) committed Feb 24, 2015 at 15:12 UTC bf25cf6ece3683c17c265cf2647a8d668b9f3d3f
1 file changed +6 -3
charts.d/squid.chart.sh
+6 -3
@@ -8,13 +8,16 @@ squid_update_every=5
8 squid_get_stats() {
9 nc $squid_host $squid_port <<EOF
10 GET $squid_url HTTP/1.0
11 +Host: $squid_host:$squid_port
12 +Accept: */*
13 +User-Agent: netdata (charts.d/squid.chart.sh)
14
15 EOF
16 }
17
18 squid_check() {
19 # check once if the url works
17 - local x=`squid_get_stats | grep client_http.requests`
20 + local x="$(squid_get_stats | grep client_http.requests)"
21 if [ ! $? -eq 0 -o -z "$x" ]
22 then
23 echo >&2 "squid: cannot fetch URL '$squid_url' by connecting to $squid_host:$squid_port. Please set squid_url='url' and squid_host='host' and squid_port='port' in $confd/squid.conf"
@@ -69,9 +72,9 @@ squid_update() {
72 # prepare the script and always grep at the end the lines that are usefull, so that
73 # even if something goes wrong, no other code can be executed
74
72 - eval "`squid_get_stats |\
75 + eval "$(squid_get_stats |\
76 sed -e "s/ \+/ /g" -e "s/\./_/g" -e "s/^\([a-z0-9_]\+\) *= *\([0-9]\+\)$/local squid_\1=\2/g" |\
74 - egrep "^local squid_(client_http|server_all)_[a-z0-9_]+=[0-9]+$"`"
77 + egrep "^local squid_(client_http|server_all)_[a-z0-9_]+=[0-9]+$")"
78
79 # write the result of the work.
80 cat <<VALUESEOF