summaryrefslogtreecommitdiffstats
path: root/charts.d
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2016-10-20 22:04:28 +0300
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2016-10-20 22:04:28 +0300
commitaddb52bb18ba356fc1cb5888b1fe5b809137346d (patch)
tree61f3294473d70f9f96e2e302837ff844a70e3207 /charts.d
parentc6d3138cc7ddb21bac33df2fc9f16c6e76ff1426 (diff)
better log management for charts.d.plugin - fixes #1144
Diffstat (limited to 'charts.d')
-rwxr-xr-xcharts.d/ap.chart.sh5
-rwxr-xr-xcharts.d/apache.chart.sh22
-rwxr-xr-xcharts.d/apcupsd.chart.sh10
-rwxr-xr-xcharts.d/cpu_apps.chart.sh2
-rwxr-xr-xcharts.d/cpufreq.chart.sh3
-rwxr-xr-xcharts.d/example.chart.sh3
-rw-r--r--charts.d/exim.chart.sh40
-rwxr-xr-xcharts.d/hddtemp.chart.sh3
-rwxr-xr-xcharts.d/mem_apps.chart.sh2
-rwxr-xr-xcharts.d/mysql.chart.sh16
-rwxr-xr-xcharts.d/nginx.chart.sh8
-rwxr-xr-xcharts.d/nut.chart.sh12
-rwxr-xr-xcharts.d/opensips.chart.sh6
-rwxr-xr-xcharts.d/phpfpm.chart.sh10
-rwxr-xr-xcharts.d/postfix.chart.sh18
-rwxr-xr-xcharts.d/sensors.chart.sh9
-rwxr-xr-xcharts.d/squid.chart.sh8
-rwxr-xr-xcharts.d/tomcat.chart.sh13
18 files changed, 81 insertions, 109 deletions
diff --git a/charts.d/ap.chart.sh b/charts.d/ap.chart.sh
index 7b4f690bb4..477d414859 100755
--- a/charts.d/ap.chart.sh
+++ b/charts.d/ap.chart.sh
@@ -7,13 +7,11 @@ ap_priority=6900
declare -A ap_devs=()
-export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
-
# _check is called once, to find out if this chart should be enabled or not
ap_check() {
require_cmd iw || return 1
- local ev=$(iw dev | awk '
+ local ev=$(run iw dev | awk '
BEGIN {
i = "";
ssid = "";
@@ -43,6 +41,7 @@ ap_check() {
# - 1 to disable the chart
[ ${#ap_devs[@]} -gt 0 ] && return 0
+ error "no devices found in AP mode, with 'iw dev'"
return 1
}
diff --git a/charts.d/apache.chart.sh b/charts.d/apache.chart.sh
index 2d68d43b27..d59f86ebc4 100755
--- a/charts.d/apache.chart.sh
+++ b/charts.d/apache.chart.sh
@@ -67,14 +67,14 @@ apache_detect() {
# we will not check of the Conns*
# keys, since these are apache 2.4 specific
- [ -z "${apache_key_accesses}" ] && echo >&2 "apache: missing 'Total Accesses' from apache server: ${*}" && return 1
- [ -z "${apache_key_kbytes}" ] && echo >&2 "apache: missing 'Total kBytes' from apache server: ${*}" && return 1
- [ -z "${apache_key_reqpersec}" ] && echo >&2 "apache: missing 'ReqPerSec' from apache server: ${*}" && return 1
- [ -z "${apache_key_bytespersec}" ] && echo >&2 "apache: missing 'BytesPerSec' from apache server: ${*}" && return 1
- [ -z "${apache_key_bytesperreq}" ] && echo >&2 "apache: missing 'BytesPerReq' from apache server: ${*}" && return 1
- [ -z "${apache_key_busyworkers}" ] && echo >&2 "apache: missing 'BusyWorkers' from apache server: ${*}" && return 1
- [ -z "${apache_key_idleworkers}" ] && echo >&2 "apache: missing 'IdleWorkers' from apache server: ${*}" && return 1
- [ -z "${apache_key_scoreboard}" ] && echo >&2 "apache: missing 'Scoreboard' from apache server: ${*}" && return 1
+ [ -z "${apache_key_accesses}" ] && error "missing 'Total Accesses' from apache server: ${*}" && return 1
+ [ -z "${apache_key_kbytes}" ] && error "missing 'Total kBytes' from apache server: ${*}" && return 1
+ [ -z "${apache_key_reqpersec}" ] && error "missing 'ReqPerSec' from apache server: ${*}" && return 1
+ [ -z "${apache_key_bytespersec}" ] && error "missing 'BytesPerSec' from apache server: ${*}" && return 1
+ [ -z "${apache_key_bytesperreq}" ] && error "missing 'BytesPerReq' from apache server: ${*}" && return 1
+ [ -z "${apache_key_busyworkers}" ] && error "missing 'BusyWorkers' from apache server: ${*}" && return 1
+ [ -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}" \
@@ -92,7 +92,7 @@ apache_detect() {
apache_get() {
local oIFS="${IFS}" ret
- IFS=$':\n' apache_response=($(curl -Ss ${apache_curl_opts} "${apache_url}"))
+ IFS=$':\n' apache_response=($(run curl -Ss ${apache_curl_opts} "${apache_url}"))
ret=$?
IFS="${oIFS}"
@@ -130,7 +130,7 @@ apache_get() {
-o -z "${apache_idleworkers}" \
]
then
- echo >&2 "apache: empty values got from apache server: ${apache_response[*]}"
+ error "empty values got from apache server: ${apache_response[*]}"
return 1
fi
@@ -151,7 +151,7 @@ apache_check() {
apache_get
if [ $? -ne 0 ]
then
- echo >&2 "apache: cannot find stub_status on URL '${apache_url}'. Please set apache_url='http://apache.server:80/server-status?auto' in $confd/apache.conf"
+ 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
diff --git a/charts.d/apcupsd.chart.sh b/charts.d/apcupsd.chart.sh
index df18aaa2e8..41cb39f9cd 100755
--- a/charts.d/apcupsd.chart.sh
+++ b/charts.d/apcupsd.chart.sh
@@ -12,7 +12,7 @@ apcupsd_timeout=3
apcupsd_priority=90000
apcupsd_get() {
- timeout $apcupsd_timeout apcaccess status "$1:$2"
+ run -t $apcupsd_timeout apcaccess status "$1:$2"
}
apcupsd_check() {
@@ -23,14 +23,14 @@ apcupsd_check() {
require_cmd apcaccess || return 1
- apcupsd_get $apcupsd_ip $apcupsd_port >/dev/null
+ run apcupsd_get $apcupsd_ip $apcupsd_port >/dev/null
if [ $? -ne 0 ]
then
- echo >&2 "apcupsd: ERROR: Cannot get information for apcupsd server."
+ error "cannot get information for apcupsd server."
return 1
elif [ $(apcupsd_get $apcupsd_ip $apcupsd_port | awk '/^STATUS.*/{ print $3 }') != "ONLINE" ]
then
- echo >&2 "apcupsd: ERROR: UPS not online."
+ error "APC UPS not online."
return 1
fi
@@ -146,7 +146,7 @@ END {
print \"SET time = \" time;
print \"END\"
}"
- [ $? -ne 0 ] && echo >&2 "apcupsd: failed to get values" && return 1
+ [ $? -ne 0 ] && error "failed to get values" && return 1
return 0
}
diff --git a/charts.d/cpu_apps.chart.sh b/charts.d/cpu_apps.chart.sh
index 6b2513dcf0..8893b5220f 100755
--- a/charts.d/cpu_apps.chart.sh
+++ b/charts.d/cpu_apps.chart.sh
@@ -19,7 +19,7 @@ cpu_apps_check() {
if [ -z "$cpu_apps_apps" ]
then
- echo >&2 "$PROGRAM_NAME: cpu_apps: Please set cpu_apps_apps='command1 command2 ...' in $confd/cpu_apps_apps.conf"
+ error "manual configuration required: please set cpu_apps_apps='command1 command2 ...' in $confd/cpu_apps_apps.conf"
return 1
fi
return 0
diff --git a/charts.d/cpufreq.chart.sh b/charts.d/cpufreq.chart.sh
index 06f692fa69..944541c0e3 100755
--- a/charts.d/cpufreq.chart.sh
+++ b/charts.d/cpufreq.chart.sh
@@ -51,7 +51,7 @@ cpufreq_create() {
id="$( fixid "cpu$cpu" )"
- echo >&2 "charts.d: cpufreq: on file='$file', dir='$dir', cpu='$cpu', id='$id'"
+ debug "file='$file', dir='$dir', cpu='$cpu', id='$id'"
echo "DIMENSION $id '$id' absolute 1 1000"
echo >>$TMP_DIR/cpufreq.sh "echo \"SET $id = \"\$(< $file )"
@@ -59,7 +59,6 @@ cpufreq_create() {
echo >>$TMP_DIR/cpufreq.sh "echo END"
[ $cpufreq_source_update -eq 1 ] && echo >>$TMP_DIR/cpufreq.sh "}"
- # cat >&2 $TMP_DIR/cpufreq.sh
# ok, load the function cpufreq_update() we created
[ $cpufreq_source_update -eq 1 ] && . $TMP_DIR/cpufreq.sh
diff --git a/charts.d/example.chart.sh b/charts.d/example.chart.sh
index 93f1cf4fdd..cec5e9f7d6 100755
--- a/charts.d/example.chart.sh
+++ b/charts.d/example.chart.sh
@@ -67,7 +67,7 @@ example_check() {
# - 1 to disable the chart
# check something
- [ "${example_magic_number}" != "12345" ] && echo >&2 "example: you have to set example_magic_number=$example_magic_number in example.conf to start example chart." && return 1
+ [ "${example_magic_number}" != "12345" ] && error "manual configuration required: you have to set example_magic_number=$example_magic_number in example.conf to start example chart." && return 1
# check that we can collect data
example_get || return 1
@@ -108,7 +108,6 @@ BEGIN example.random2 $1
SET random = $example_value4
END
VALUESEOF
- # echo >&2 "example_count = $example_count value = $value4"
return 0
}
diff --git a/charts.d/exim.chart.sh b/charts.d/exim.chart.sh
index c60ae9460d..f9d48b8a8b 100644
--- a/charts.d/exim.chart.sh
+++ b/charts.d/exim.chart.sh
@@ -1,5 +1,6 @@
# no need for shebang - this file is loaded from charts.d.plugin
+# the exim command to run
exim_command=
# how frequently to collect queue size
@@ -8,28 +9,15 @@ exim_update_every=5
exim_priority=60000
exim_check() {
- if [ -z "$exim_command" -o ! -x "$exim_command" ]
- then
- local d=
- for d in /sbin /usr/sbin /usr/local/sbin
- do
- if [ -x "$d/exim" ]
- then
- exim_command="$d/exim"
- break
- fi
- done
- fi
-
- if [ -z "$exim_command" -o ! -x "$exim_command" ]
- then
- echo >&2 "$PROGRAM_NAME: exim: cannot find exim executable. Please set 'exim_command=/path/to/exim' in $confd/exim.conf"
- return 1
- fi
+ if [ -z "${exim_command}" ]
+ then
+ require_cmd exim || return 1
+ exim_command="${EXIM_CMD}"
+ fi
- if [ `$exim_command -bpc 2>&1 | grep -c denied` -ne 0 ]
+ if [ $(${exim_command} -bpc 2>&1 | grep -c denied) -ne 0 ]
then
- echo >&2 "$PROGRAM_NAME: exim: permission denied. Please set 'queue_list_requires_admin = false' in your exim options file"
+ error "permission denied - please set 'queue_list_requires_admin = false' in your exim options file"
return 1
fi
@@ -37,16 +25,16 @@ exim_check() {
}
exim_create() {
-cat <<EOF
+ cat <<EOF
CHART exim_local.qemails '' "Exim Queue Emails" "emails" queue exim.queued.emails line $((exim_priority + 1)) $exim_update_every
DIMENSION emails '' absolute 1 1
EOF
-return 0
+ return 0
}
exim_update() {
-echo "BEGIN exim_local.qemails $1"
-echo "SET emails = " `$exim_command -bpc`
-echo "END"
-return 0
+ echo "BEGIN exim_local.qemails $1"
+ echo "SET emails = " $(run ${exim_command} -bpc)
+ echo "END"
+ return 0
}
diff --git a/charts.d/hddtemp.chart.sh b/charts.d/hddtemp.chart.sh
index 41c3e24780..7e4f67daca 100755
--- a/charts.d/hddtemp.chart.sh
+++ b/charts.d/hddtemp.chart.sh
@@ -13,7 +13,8 @@ hddtemp_priority=90000
# _check is called once, to find out if this chart should be enabled or not
hddtemp_check() {
- nc $hddtemp_host $hddtemp_port &>/dev/null && return 0 || return 1
+ require_cmd nc || return 1
+ run nc $hddtemp_host $hddtemp_port && return 0 || return 1
}
# _create is called once, to create the charts
diff --git a/charts.d/mem_apps.chart.sh b/charts.d/mem_apps.chart.sh
index ab95b361c8..a350d88c31 100755
--- a/charts.d/mem_apps.chart.sh
+++ b/charts.d/mem_apps.chart.sh
@@ -15,7 +15,7 @@ mem_apps_check() {
if [ -z "$mem_apps_apps" ]
then
- echo >&2 "$PROGRAM_NAME: mem_apps: not configured. Please set mem_apps_apps='command1 command2 ...' in $confd/mem_apps_apps.conf"
+ error "manual configuration required: please set mem_apps_apps='command1 command2 ...' in $confd/mem_apps_apps.conf"
return 1
fi
return 0
diff --git a/charts.d/mysql.chart.sh b/charts.d/mysql.chart.sh
index 120fec66e3..2bb80a8a9c 100755
--- a/charts.d/mysql.chart.sh
+++ b/charts.d/mysql.chart.sh
@@ -17,9 +17,9 @@ mysql_get() {
local oIFS="${IFS}"
mysql_data=()
IFS=$'\t'$'\n'
- #arr=($("${@}" -e "SHOW GLOBAL STATUS WHERE value REGEXP '^[0-9]';" | egrep "^(Bytes|Slow_|Que|Handl|Table|Selec|Sort_|Creat|Conne|Abort|Binlo|Threa|Innod|Qcach|Key_|Open)" ))
- #arr=($("${@}" -N -e "SHOW GLOBAL STATUS;" | egrep "^(Bytes|Slow_|Que|Handl|Table|Selec|Sort_|Creat|Conne|Abort|Binlo|Threa|Innod|Qcach|Key_|Open)[^ ]+\s[0-9]" ))
- arr=($("${@}" -N -e "SHOW GLOBAL STATUS;" | egrep "^(Bytes|Slow_|Que|Handl|Table|Selec|Sort_|Creat|Conne|Abort|Binlo|Threa|Innod|Qcach|Key_|Open)[^[:space:]]+[[:space:]]+[0-9]+" ))
+ #arr=($(run "${@}" -e "SHOW GLOBAL STATUS WHERE value REGEXP '^[0-9]';" | egrep "^(Bytes|Slow_|Que|Handl|Table|Selec|Sort_|Creat|Conne|Abort|Binlo|Threa|Innod|Qcach|Key_|Open)" ))
+ #arr=($(run "${@}" -N -e "SHOW GLOBAL STATUS;" | egrep "^(Bytes|Slow_|Que|Handl|Table|Selec|Sort_|Creat|Conne|Abort|Binlo|Threa|Innod|Qcach|Key_|Open)[^ ]+\s[0-9]" ))
+ arr=($(run "${@}" -N -e "SHOW GLOBAL STATUS;" | egrep "^(Bytes|Slow_|Que|Handl|Table|Selec|Sort_|Creat|Conne|Abort|Binlo|Threa|Innod|Qcach|Key_|Open)[^[:space:]]+[[:space:]]+[0-9]+" ))
IFS="${oIFS}"
[ "${#arr[@]}" -lt 3 ] && return 1
@@ -74,13 +74,13 @@ mysql_check() {
[ -z "${mysql_cmds[$m]}" ] && mysql_cmds[$m]="$mysql_cmd"
if [ -z "${mysql_cmds[$m]}" ]
then
- echo >&2 "$PROGRAM_NAME: mysql: cannot get mysql command for '$m'. Please set mysql_cmds[$m]='/path/to/mysql', in $confd/mysql.conf"
+ error "cannot get mysql command for '$m'. Please set mysql_cmds[$m]='/path/to/mysql', in $confd/mysql.conf"
fi
mysql_get "${mysql_cmds[$m]}" ${mysql_opts[$m]}
if [ ! $? -eq 0 ]
then
- echo >&2 "$PROGRAM_NAME: mysql: cannot get global status for '$m'. Please set mysql_opts[$m]='options' to whatever needed to get connected to the mysql server, in $confd/mysql.conf"
+ error "cannot get global status for '$m'. Please set mysql_opts[$m]='options' to whatever needed to get connected to the mysql server, in $confd/mysql.conf"
unset mysql_cmds[$m]
unset mysql_opts[$m]
unset mysql_ids[$m]
@@ -97,7 +97,7 @@ mysql_check() {
mysql_check tryroot "${@}"
return $?
else
- echo >&2 "$PROGRAM_NAME: mysql: no mysql servers found. Please set mysql_opts[name]='options' to whatever needed to get connected to the mysql server, in $confd/mysql.conf"
+ error "no mysql servers found. Please set mysql_opts[name]='options' to whatever needed to get connected to the mysql server, in $confd/mysql.conf"
return 1
fi
fi
@@ -318,7 +318,7 @@ mysql_update() {
unset mysql_ids[$m]
unset mysql_opts[$m]
unset mysql_cmds[$m]
- echo >&2 "$PROGRAM_NAME: mysql: failed to get values for '$m', disabling it."
+ error "failed to get values for '$m', disabling it."
continue
fi
@@ -510,7 +510,7 @@ VALUESEOF
fi
done
- [ ${#mysql_ids[@]} -eq 0 ] && echo >&2 "$PROGRAM_NAME: mysql: no mysql servers left active." && return 1
+ [ ${#mysql_ids[@]} -eq 0 ] && error "no mysql servers left active." && return 1
return 0
}
diff --git a/charts.d/nginx.chart.sh b/charts.d/nginx.chart.sh
index a2a9b320fa..f0092fd074 100755
--- a/charts.d/nginx.chart.sh
+++ b/charts.d/nginx.chart.sh
@@ -20,7 +20,7 @@ nginx_reading=0
nginx_writing=0
nginx_waiting=0
nginx_get() {
- nginx_response=($(curl -Ss ${nginx_curl_opts} "${nginx_url}"))
+ nginx_response=($(run curl -Ss ${nginx_curl_opts} "${nginx_url}"))
[ $? -ne 0 -o "${#nginx_response[@]}" -eq 0 ] && return 1
if [ "${nginx_response[0]}" != "Active" \
@@ -34,7 +34,7 @@ nginx_get() {
-o "${nginx_response[14]}" != "Waiting:" \
]
then
- echo >&2 "nginx: Invalid response from nginx server: ${nginx_response[*]}"
+ error "Invalid response from nginx server: ${nginx_response[*]}"
return 1
fi
@@ -55,7 +55,7 @@ nginx_get() {
-o -z "${nginx_waiting}" \
]
then
- echo >&2 "nginx: empty values got from nginx server: ${nginx_response[*]}"
+ error "empty values got from nginx server: ${nginx_response[*]}"
return 1
fi
@@ -68,7 +68,7 @@ nginx_check() {
nginx_get
if [ $? -ne 0 ]
then
- echo >&2 "nginx: cannot find stub_status on URL '${nginx_url}'. Please set nginx_url='http://nginx.server/stub_status' in $confd/nginx.conf"
+ error "cannot find stub_status on URL '${nginx_url}'. Please set nginx_url='http://nginx.server/stub_status' in $confd/nginx.conf"
return 1
fi
diff --git a/charts.d/nut.chart.sh b/charts.d/nut.chart.sh
index 3c8e1c9d05..e2b3a85c54 100755
--- a/charts.d/nut.chart.sh
+++ b/charts.d/nut.chart.sh
@@ -15,11 +15,11 @@ nut_priority=90000
declare -A nut_ids=()
nut_get_all() {
- timeout $nut_timeout upsc -l
+ run -t $nut_timeout upsc -l
}
nut_get() {
- timeout $nut_timeout upsc "$1"
+ run -t $nut_timeout upsc "$1"
}
nut_check() {
@@ -42,12 +42,12 @@ nut_check() {
nut_ids[$x]="$( fixid "$x" )"
continue
fi
- echo >&2 "nut: ERROR: Cannot get information for NUT UPS '$x'."
+ error "cannot get information for NUT UPS '$x'."
done
if [ ${#nut_ids[@]} -eq 0 ]
then
- echo >&2 "nut: Please set nut_ups='ups_name' in $confd/nut.conf"
+ error "Cannot find UPSes - please set nut_ups='ups_name' in $confd/nut.conf"
return 1
fi
@@ -179,9 +179,9 @@ END {
print \"SET temp = \" temp;
print \"END\"
}"
- [ $? -ne 0 ] && unset nut_ids[$i] && echo >&2 "nut: failed to get values for '$i', disabling it."
+ [ $? -ne 0 ] && unset nut_ids[$i] && error "failed to get values for '$i', disabling it."
done
- [ ${#nut_ids[@]} -eq 0 ] && echo >&2 "nut: no UPSes left active." && return 1
+ [ ${#nut_ids[@]} -eq 0 ] && error "no UPSes left active." && return 1
return 0
}
diff --git a/charts.d/opensips.chart.sh b/charts.d/opensips.chart.sh
index 779087e353..12247fc322 100755
--- a/charts.d/opensips.chart.sh
+++ b/charts.d/opensips.chart.sh
@@ -7,7 +7,7 @@ opensips_timeout=2
opensips_priority=80000
opensips_get_stats() {
- timeout $opensips_timeout "$opensips_cmd" $opensips_opts |\
+ run -t $opensips_timeout "$opensips_cmd" $opensips_opts |\
grep "^\(core\|dialog\|net\|registrar\|shmem\|siptrace\|sl\|tm\|uri\|usrloc\):[a-zA-Z0-9_-]\+[[:space:]]*[=:]\+[[:space:]]*[0-9]\+[[:space:]]*$" |\
sed \
-e "s|[[:space:]]*[=:]\+[[:space:]]*\([0-9]\+\)[[:space:]]*$|=\1|g" \
@@ -31,7 +31,7 @@ opensips_check() {
local x="$(opensips_get_stats | grep "^opensips_core_")"
if [ ! $? -eq 0 -o -z "$x" ]
then
- echo >&2 "$PROGRAM_NAME: opensips: cannot get global status. Please set opensips_opts='options' whatever needed to get connected to opensips server, in $confd/opensips.conf"
+ error "cannot get global status. Please set opensips_opts='options' whatever needed to get connected to opensips server, in $confd/opensips.conf"
return 1
fi
@@ -214,7 +214,7 @@ opensips_update() {
eval "local $(opensips_get_stats)"
[ $? -ne 0 ] && return 1
- [ $opensips_command_failed -eq 1 ] && echo >&2 "$PROGRAM_NAME: opensips: failed to get values, disabling." && return 1
+ [ $opensips_command_failed -eq 1 ] && error "failed to get values, disabling." && return 1
# write the result of the work.
cat <<VALUESEOF
diff --git a/charts.d/phpfpm.chart.sh b/charts.d/phpfpm.chart.sh
index 976ce91b19..16669e1be0 100755
--- a/charts.d/phpfpm.chart.sh
+++ b/charts.d/phpfpm.chart.sh
@@ -32,7 +32,7 @@ phpfpm_slow_requests=0
phpfpm_get() {
local opts="${1}" url="${2}"
- phpfpm_response=($(curl -Ss ${opts} "${url}"))
+ phpfpm_response=($(run curl -Ss ${opts} "${url}"))
[ $? -ne 0 -o "${#phpfpm_response[@]}" -eq 0 ] && return 1
if [[ "${phpfpm_response[0]}" != "pool:" \
@@ -46,7 +46,7 @@ phpfpm_get() {
|| "${phpfpm_response[32]}" != "total" \
]]
then
- echo >&2 "phpfpm: invalid response from phpfpm status server: ${phpfpm_response[*]}"
+ error "invalid response from phpfpm status server: ${phpfpm_response[*]}"
return 1
fi
@@ -83,7 +83,7 @@ phpfpm_get() {
|| -z "${phpfpm_max_children_reached}" \
]]
then
- echo >&2 "phpfpm: empty values got from phpfpm status server: ${phpfpm_response[*]}"
+ error "empty values got from phpfpm status server: ${phpfpm_response[*]}"
return 1
fi
@@ -101,14 +101,14 @@ phpfpm_check() {
do
phpfpm_get "${phpfpm_curl_opts[$m]}" "${phpfpm_urls[$m]}"
if [ $? -ne 0 ]; then
- echo >&2 "phpfpm: cannot find status on URL '${phpfpm_url[$m]}'. Please set phpfpm_urls[$m]='http://localhost/status' in $confd/phpfpm.conf"
+ error "cannot find status on URL '${phpfpm_url[$m]}'. Please set phpfpm_urls[$m]='http://localhost/status' in $confd/phpfpm.conf"
unset phpfpm_urls[$m]
continue
fi
done
if [ ${#phpfpm_urls[@]} -eq 0 ]; then
- echo >&2 "phpfpm: no phpfpm servers found. Please set phpfpm_urls[name]='url' to whatever needed to get status to the phpfpm server, in $confd/phpfpm.conf"
+ error "no phpfpm servers found. Please set phpfpm_urls[name]='url' to whatever needed to get status to the phpfpm server, in $confd/phpfpm.conf"
return 1
fi
diff --git a/charts.d/postfix.chart.sh b/charts.d/postfix.chart.sh
index 7f07a18682..3a93357947 100755
--- a/charts.d/postfix.chart.sh
+++ b/charts.d/postfix.chart.sh
@@ -18,23 +18,11 @@ postfix_check() {
if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ]
then
postfix_postqueue="`which postqueue 2>/dev/null`"
- if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ]
- then
- local d=
- for d in /sbin /usr/sbin /usr/local/sbin
- do
- if [ -x "$d/postqueue" ]
- then
- postfix_postqueue="$d/postqueue"
- break
- fi
- done
- fi
fi
if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ]
then
- echo >&2 "$PROGRAM_NAME: postfix: cannot find postqueue. Please set 'postfix_postqueue=/path/to/postqueue' in $confd/postfix.conf"
+ error "cannot find postqueue. Please set 'postfix_postqueue=/path/to/postqueue' in $confd/postfix.conf"
return 1
fi
@@ -73,10 +61,10 @@ postfix_update() {
postfix_q_emails=0
postfix_q_size=0
- eval "`$postfix_postqueue -p |\
+ eval "$(run $postfix_postqueue -p |\
grep "^--" |\
sed -e "s/-- \([0-9]\+\) Kbytes in \([0-9]\+\) Requests.$/local postfix_q_size=\1\nlocal postfix_q_emails=\2/g" |\
- egrep "^local postfix_q_(emails|size)=[0-9]+$"`"
+ egrep "^local postfix_q_(emails|size)=[0-9]+$")"
# write the result of the work.
cat <<VALUESEOF
diff --git a/charts.d/sensors.chart.sh b/charts.d/sensors.chart.sh
index 9652f896a0..f30177a4b1 100755
--- a/charts.d/sensors.chart.sh
+++ b/charts.d/sensors.chart.sh
@@ -43,7 +43,7 @@ sensors_check() {
# - 0 to enable the chart
# - 1 to disable the chart
- [ -z "$( sensors_find_all_files $sensors_sys_dir )" ] && echo >&2 "$PROGRAM_NAME: sensors: no sensors found in '$sensors_sys_dir'." && return 1
+ [ -z "$( sensors_find_all_files $sensors_sys_dir )" ] && error "no sensors found in '$sensors_sys_dir'." && return 1
return 0
}
@@ -64,7 +64,7 @@ sensors_check_files() {
[ $v -ne 0 ] && echo "$f" && continue
excluded=
- echo >&2 "$PROGRAM_NAME: sensors: $f gives zero values"
+ error "$f gives zero values"
done
}
@@ -83,7 +83,7 @@ sensors_check_temp_type() {
v=$(( v + 1 - 1 ))
[ $v -ne 0 ] && echo "$f" && continue
- echo >&2 "$PROGRAM_NAME: sensors: $f is disabled"
+ error "$f is disabled"
done
}
@@ -121,7 +121,7 @@ sensors_create() {
id="$( fixid "$device.$subsystem.$dir" )"
- echo >&2 "charts.d: sensors: on path='$path', dir='$dir', device='$device', subsystem='$subsystem', id='$id', name='$name'"
+ debug "path='$path', dir='$dir', device='$device', subsystem='$subsystem', id='$id', name='$name'"
for mode in temperature voltage fans power current energy humidity
do
@@ -221,7 +221,6 @@ sensors_create() {
done
[ $sensors_source_update -eq 1 ] && echo >>$TMP_DIR/sensors.sh "}"
- # cat >&2 $TMP_DIR/sensors.sh
# ok, load the function sensors_update() we created
[ $sensors_source_update -eq 1 ] && . $TMP_DIR/sensors.sh
diff --git a/charts.d/squid.chart.sh b/charts.d/squid.chart.sh
index 3e72ba6df5..4b4d43ae1f 100755
--- a/charts.d/squid.chart.sh
+++ b/charts.d/squid.chart.sh
@@ -9,7 +9,7 @@ squid_priority=60000
squid_get_stats_internal() {
local host="$1" port="$2" url="$3"
- squidclient -h $host -p $port $url
+ run squidclient -h $host -p $port $url
}
squid_get_stats() {
@@ -29,13 +29,13 @@ squid_autodetect() {
squid_host="$host"
squid_port="$port"
squid_url="$url"
- echo >&2 "squid: found squid at '$host:$port' with url '$url'"
+ debug "found squid at '$host:$port' with url '$url'"
return 0
fi
done
done
- echo >&2 "squid: cannot find squid running in localhost. Please set squid_url='url' and squid_host='IP' and squid_port='PORT' in $confd/squid.conf"
+ error "cannot find squid running in localhost. Please set squid_url='url' and squid_host='IP' and squid_port='PORT' in $confd/squid.conf"
return 1
}
@@ -53,7 +53,7 @@ squid_check() {
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"
+ 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
fi
diff --git a/charts.d/tomcat.chart.sh b/charts.d/tomcat.chart.sh
index cc6baea1ae..c692ae069b 100755
--- a/charts.d/tomcat.chart.sh
+++ b/charts.d/tomcat.chart.sh
@@ -34,13 +34,13 @@ tomcat_check() {
# check if url, username, passwords are set
if [ -z "${tomcat_url}" ]; then
- echo >&2 "tomcat url is unset or set to the empty string"
+ error "tomcat url is unset or set to the empty string"
return 1
fi
if [ -z "${tomcat_user}" ]; then
# check backwards compatibility
if [ -z "${tomcatUser}" ]; then
- echo >&2 "tomcat user is unset or set to the empty string"
+ error "tomcat user is unset or set to the empty string"
return 1
else
tomcat_user="${tomcatUser}"
@@ -49,7 +49,7 @@ tomcat_check() {
if [ -z "${tomcat_password}" ]; then
# check backwards compatibility
if [ -z "${tomcatPassword}" ]; then
- echo >&2 "tomcat password is unset or set to the empty string"
+ error "tomcat password is unset or set to the empty string"
return 1
else
tomcat_password="${tomcatPassword}"
@@ -60,8 +60,7 @@ tomcat_check() {
tomcat_get
if [ $? -ne 0 ]
then
- echo >&2 "tomcat: couldn't get to status page on URL '${tomcat_url}'."\
- "Please make sure tomcat url, username and password are correct."
+ error "cannot get to status page on URL '${tomcat_url}'. Please make sure tomcat url, username and password are correct."
return 1
fi
@@ -75,8 +74,8 @@ tomcat_check() {
tomcat_get() {
# collect tomcat values
tomcat_port="$(IFS=/ read -ra a <<< "$tomcat_url"; hostport=${a[2]}; echo "${hostport#*:}")"
- mapfile -t lines < <(curl -u "$tomcat_user":"$tomcat_password" -Ss ${tomcat_curl_opts} "$tomcat_url" |\
- xmlstarlet sel \
+ mapfile -t lines < <(run curl -u "$tomcat_user":"$tomcat_password" -Ss ${tomcat_curl_opts} "$tomcat_url" |\
+ run xmlstarlet sel \
-t -m "/status/jvm/memory" -v @free \
-n -m "/status/connector[@name='\"http-bio-$tomcat_port\"']/threadInfo" -v @currentThreadCount \
-n -v @currentThreadsBusy \