diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-11-07 12:22:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-11-07 12:22:44 +0000 |
commit | 1e6c93250172946eeb38e94a92a1fd12c9d3011e (patch) | |
tree | 8ca5e16dfc7ad6b3bf2738ca0a48408a950f8f7e /collectors/charts.d.plugin/squid/squid.chart.sh | |
parent | Update watch file (diff) | |
download | netdata-1e6c93250172946eeb38e94a92a1fd12c9d3011e.tar.xz netdata-1e6c93250172946eeb38e94a92a1fd12c9d3011e.zip |
Merging upstream version 1.11.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | collectors/charts.d.plugin/squid/squid.chart.sh (renamed from charts.d/squid.chart.sh) | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/charts.d/squid.chart.sh b/collectors/charts.d.plugin/squid/squid.chart.sh index 2c19c35d5..cf5d1d78a 100644 --- a/charts.d/squid.chart.sh +++ b/collectors/charts.d.plugin/squid/squid.chart.sh @@ -1,21 +1,21 @@ +# shellcheck shell=bash disable=SC2154 # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # squid_host= squid_port= squid_url= -squid_timeout=2 squid_update_every=2 squid_priority=60000 squid_get_stats_internal() { local host="$1" port="$2" url="$3" - run squidclient -h $host -p $port $url + run squidclient -h "$host" -p "$port" "$url" } squid_get_stats() { @@ -31,7 +31,7 @@ squid_autodetect() { do x=$(squid_get_stats_internal "$host" "$port" "$url" | grep client_http.requests) if [ ! -z "$x" ] - then + then squid_host="$host" squid_port="$port" squid_url="$url" @@ -50,14 +50,16 @@ squid_check() { require_cmd sed || return 1 require_cmd egrep || return 1 - if [ -z "$squid_host" -o -z "$squid_port" -o -z "$squid_url" ] - then + if [ -z "$squid_host" ] || [ -z "$squid_port" ] || [ -z "$squid_url" ] + then squid_autodetect || return 1 fi # check once if the url works - local x="$(squid_get_stats | grep client_http.requests)" - if [ ! $? -eq 0 -o -z "$x" ] + local x + x="$(squid_get_stats | grep client_http.requests)" + # shellcheck disable=SC2181 + if [ ! $? -eq 0 ] || [ -z "$x" ] then error "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" return 1 @@ -111,9 +113,10 @@ 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 + # shellcheck disable=SC1117 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]+$")" + grep -E "^local squid_(client_http|server_all)_[a-z0-9_]+=[0-9]+$")" # write the result of the work. cat <<VALUESEOF |