diff options
author | Paweł Krupa <pawel@krupa.net.pl> | 2018-09-13 00:25:07 +0200 |
---|---|---|
committer | Costa Tsaousis <costa@tsaousis.gr> | 2018-09-13 01:25:07 +0300 |
commit | f722c9d567457920c6884ece8f7608ce1e77d270 (patch) | |
tree | 3a3df57c6a18e4e9d0e6cdaf1809f06a2acd9686 /charts.d | |
parent | c592cea960f46a37fabd63bce657eeed55c31840 (diff) |
shellcheck bash scripts starting on A; disable shebang checking in all (#4159)
scripts; set shell without shebang
Diffstat (limited to 'charts.d')
-rw-r--r-- | charts.d/ap.chart.sh | 7 | ||||
-rw-r--r-- | charts.d/apache.chart.sh | 47 | ||||
-rw-r--r-- | charts.d/apcupsd.chart.sh | 5 | ||||
-rw-r--r-- | charts.d/cpu_apps.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/cpufreq.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/example.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/exim.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/hddtemp.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/libreswan.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/load_average.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/mem_apps.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/mysql.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/nginx.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/nut.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/opensips.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/phpfpm.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/postfix.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/sensors.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/squid.chart.sh | 1 | ||||
-rw-r--r-- | charts.d/tomcat.chart.sh | 1 |
20 files changed, 49 insertions, 27 deletions
diff --git a/charts.d/ap.chart.sh b/charts.d/ap.chart.sh index 9730a80540..ac8785ba90 100644 --- a/charts.d/ap.chart.sh +++ b/charts.d/ap.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ @@ -16,8 +17,8 @@ declare -A ap_devs=() # _check is called once, to find out if this chart should be enabled or not ap_check() { require_cmd iw || return 1 - - local ev=$(run iw dev | awk ' + local ev + ev=$(run iw dev | awk ' BEGIN { i = ""; ssid = ""; @@ -102,7 +103,7 @@ ap_update() { do echo echo "DEVICE ${dev}" - iw ${dev} station dump + iw "${dev}" station dump done | awk " function zero_data() { dev = \"\"; diff --git a/charts.d/apache.chart.sh b/charts.d/apache.chart.sh index 7b272652dd..779a4026a0 100644 --- a/charts.d/apache.chart.sh +++ b/charts.d/apache.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ @@ -82,12 +83,11 @@ apache_detect() { [ -z "${apache_key_idleworkers}" ] && error "missing 'IdleWorkers' from apache server: ${*}" && return 1 [ -z "${apache_key_scoreboard}" ] && error "missing 'Scoreboard' from apache server: ${*}" && return 1 - if [ ! -z "${apache_key_connstotal}" \ - -a ! -z "${apache_key_connsasyncwriting}" \ - -a ! -z "${apache_key_connsasynckeepalive}" \ - -a ! -z "${apache_key_connsasyncclosing}" \ - ] - then + if [ ! -z "${apache_key_connstotal}" ] && \ + [ ! -z "${apache_key_connsasyncwriting}" ] && \ + [ ! -z "${apache_key_connsasynckeepalive}" ] && \ + [ ! -z "${apache_key_connsasyncclosing}" ] + then apache_has_conns=1 else apache_has_conns=0 @@ -98,16 +98,17 @@ apache_detect() { apache_get() { local oIFS="${IFS}" ret + # shellcheck disable=2207 IFS=$':\n' apache_response=($(run curl -Ss ${apache_curl_opts} "${apache_url}")) ret=$? IFS="${oIFS}" - [ $ret -ne 0 -o "${#apache_response[@]}" -eq 0 ] && return 1 + ([ $ret -ne 0 ] || [ "${#apache_response[@]}" -eq 0 ]) && return 1 # the last line on the apache output is "Scoreboard" # we use this label to detect that the output has a new word count - if [ ${apache_keys_detected} -eq 0 -o "${apache_response[${apache_key_scoreboard}]}" != "Scoreboard" ] - then + if [ ${apache_keys_detected} -eq 0 ] || [ "${apache_response[${apache_key_scoreboard}]}" != "Scoreboard" ] + then apache_detect "${apache_response[@]}" || return 1 apache_keys_detected=1 fi @@ -127,21 +128,20 @@ apache_get() { apache_busyworkers="${apache_response[${apache_key_busyworkers}]}" apache_idleworkers="${apache_response[${apache_key_idleworkers}]}" - if [ -z "${apache_accesses}" \ - -o -z "${apache_kbytes}" \ - -o -z "${apache_reqpersec}" \ - -o -z "${apache_bytespersec}" \ - -o -z "${apache_bytesperreq}" \ - -o -z "${apache_busyworkers}" \ - -o -z "${apache_idleworkers}" \ - ] - then + if [ -z "${apache_accesses}" ] || \ + [ -z "${apache_kbytes}" ] || \ + [ -z "${apache_reqpersec}" ] || \ + [ -z "${apache_bytespersec}" ] || \ + [ -z "${apache_bytesperreq}" ] || \ + [ -z "${apache_busyworkers}" ] + [ -z "${apache_idleworkers}" ] + then error "empty values got from apache server: ${apache_response[*]}" return 1 fi if [ ${apache_has_conns} -eq 1 ] - then + then apache_connstotal="${apache_response[${apache_key_connstotal}]}" apache_connsasyncwriting="${apache_response[${apache_key_connsasyncwriting}]}" apache_connsasynckeepalive="${apache_response[${apache_key_connsasynckeepalive}]}" @@ -155,8 +155,10 @@ apache_get() { apache_check() { apache_get + # shellcheck disable=2181 if [ $? -ne 0 ] - then + then + # shellcheck disable=2154 error "cannot find stub_status on URL '${apache_url}'. Please set apache_url='http://apache.server:80/server-status?auto' in $confd/apache.conf" return 1 fi @@ -187,7 +189,7 @@ DIMENSION sent '' incremental 8 1 EOF if [ ${apache_has_conns} -eq 1 ] - then + then cat <<EOF2 CHART apache_local.connections '' "apache Connections" "connections" connections apache.connections line $((apache_priority + 2)) $apache_update_every DIMENSION connections '' absolute 1 1 @@ -203,7 +205,6 @@ EOF2 # _update is called continuously, to collect the values apache_update() { - local reqs net # the first argument to this function is the microseconds since last update # pass this parameter to the BEGIN statement (see bellow). @@ -237,7 +238,7 @@ END VALUESEOF if [ ${apache_has_conns} -eq 1 ] - then + then cat <<VALUESEOF2 BEGIN apache_local.connections $1 SET connections = $((apache_connstotal)) diff --git a/charts.d/apcupsd.chart.sh b/charts.d/apcupsd.chart.sh index 9749b7193f..a061bd0253 100644 --- a/charts.d/apcupsd.chart.sh +++ b/charts.d/apcupsd.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ @@ -43,11 +44,12 @@ apcupsd_check() { for host in "${!apcupsd_sources[@]}" do run apcupsd_get "${apcupsd_sources[${host}]}" >/dev/null + # shellcheck disable=2181 if [ $? -ne 0 ] then error "cannot get information for apcupsd server ${host} on ${apcupsd_sources[${host}]}." failed=$((failed + 1)) - elif [ $(apcupsd_get "${apcupsd_sources[${host}]}" | awk '/^STATUS.*/{ print $3 }') != "ONLINE" ] + elif [ "$(apcupsd_get "${apcupsd_sources[${host}]}" | awk '/^STATUS.*/{ print $3 }')" != "ONLINE" ] then error "APC UPS ${host} on ${apcupsd_sources[${host}]} is not online." failed=$((failed + 1)) @@ -183,6 +185,7 @@ END { print \"SET time = \" time; print \"END\" }" + # shellcheck disable=SC2181 if [ $? -ne 0 ] then failed=$((failed + 1)) diff --git a/charts.d/cpu_apps.chart.sh b/charts.d/cpu_apps.chart.sh index a624555269..f287dba431 100644 --- a/charts.d/cpu_apps.chart.sh +++ b/charts.d/cpu_apps.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/cpufreq.chart.sh b/charts.d/cpufreq.chart.sh index 38dff574db..8613a000ea 100644 --- a/charts.d/cpufreq.chart.sh +++ b/charts.d/cpufreq.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/example.chart.sh b/charts.d/example.chart.sh index 32aaffd0c7..8602ad914e 100644 --- a/charts.d/example.chart.sh +++ b/charts.d/example.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/exim.chart.sh b/charts.d/exim.chart.sh index 9891eb0b89..996934630b 100644 --- a/charts.d/exim.chart.sh +++ b/charts.d/exim.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/hddtemp.chart.sh b/charts.d/hddtemp.chart.sh index 135b6abe0d..0795db8467 100644 --- a/charts.d/hddtemp.chart.sh +++ b/charts.d/hddtemp.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/libreswan.chart.sh b/charts.d/libreswan.chart.sh index 8078d855c5..f2c4b210e5 100644 --- a/charts.d/libreswan.chart.sh +++ b/charts.d/libreswan.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/load_average.chart.sh b/charts.d/load_average.chart.sh index f7e3fdee8f..41c5c22f13 100644 --- a/charts.d/load_average.chart.sh +++ b/charts.d/load_average.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/mem_apps.chart.sh b/charts.d/mem_apps.chart.sh index 511c208c98..9157ba1f79 100644 --- a/charts.d/mem_apps.chart.sh +++ b/charts.d/mem_apps.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/mysql.chart.sh b/charts.d/mysql.chart.sh index f44eebfd08..3b64d696a9 100644 --- a/charts.d/mysql.chart.sh +++ b/charts.d/mysql.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/nginx.chart.sh b/charts.d/nginx.chart.sh index 07860f868c..b626be7e6c 100644 --- a/charts.d/nginx.chart.sh +++ b/charts.d/nginx.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/nut.chart.sh b/charts.d/nut.chart.sh index 19dd641b5d..07f571bdc0 100644 --- a/charts.d/nut.chart.sh +++ b/charts.d/nut.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/opensips.chart.sh b/charts.d/opensips.chart.sh index 3898584599..ed04044def 100644 --- a/charts.d/opensips.chart.sh +++ b/charts.d/opensips.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/phpfpm.chart.sh b/charts.d/phpfpm.chart.sh index 6e18822866..b169856b2f 100644 --- a/charts.d/phpfpm.chart.sh +++ b/charts.d/phpfpm.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/postfix.chart.sh b/charts.d/postfix.chart.sh index daf91ecf1e..524f1b2533 100644 --- a/charts.d/postfix.chart.sh +++ b/charts.d/postfix.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/sensors.chart.sh b/charts.d/sensors.chart.sh index 4ffff6db37..1a7a8f71c5 100644 --- a/charts.d/sensors.chart.sh +++ b/charts.d/sensors.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/squid.chart.sh b/charts.d/squid.chart.sh index c28f586802..7a3a4f7941 100644 --- a/charts.d/squid.chart.sh +++ b/charts.d/squid.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ diff --git a/charts.d/tomcat.chart.sh b/charts.d/tomcat.chart.sh index b788d29b67..aaa6332e00 100644 --- a/charts.d/tomcat.chart.sh +++ b/charts.d/tomcat.chart.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin # SPDX-License-Identifier: GPL-3.0+ |