summaryrefslogtreecommitdiffstats
path: root/charts.d/squid.chart.sh
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2015-02-24 15:12:37 +0200
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2015-02-24 15:12:37 +0200
commitbf25cf6ece3683c17c265cf2647a8d668b9f3d3f (patch)
tree1ffb9568cbd0923116b22a9f165bf1b02c0cf9cc /charts.d/squid.chart.sh
parent539947e1d9dd51c37dc2142f5626b885b9ef2e6c (diff)
more HTTP compliance
Diffstat (limited to 'charts.d/squid.chart.sh')
-rwxr-xr-xcharts.d/squid.chart.sh9
1 files changed, 6 insertions, 3 deletions
diff --git a/charts.d/squid.chart.sh b/charts.d/squid.chart.sh
index 564ba4f212..64ab4783b4 100755
--- a/charts.d/squid.chart.sh
+++ b/charts.d/squid.chart.sh
@@ -8,13 +8,16 @@ squid_update_every=5
squid_get_stats() {
nc $squid_host $squid_port <<EOF
GET $squid_url HTTP/1.0
+Host: $squid_host:$squid_port
+Accept: */*
+User-Agent: netdata (charts.d/squid.chart.sh)
EOF
}
squid_check() {
# check once if the url works
- local x=`squid_get_stats | grep client_http.requests`
+ local x="$(squid_get_stats | grep client_http.requests)"
if [ ! $? -eq 0 -o -z "$x" ]
then
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() {
# 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 "`squid_get_stats |\
+ 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]+$"`"
+ egrep "^local squid_(client_http|server_all)_[a-z0-9_]+=[0-9]+$")"
# write the result of the work.
cat <<VALUESEOF