From bb8cdaf9dd25372bbbd09d916e9afe7f907ec1d6 Mon Sep 17 00:00:00 2001 From: "Costa Tsaousis (ktsaou)" Date: Thu, 9 Jun 2016 22:49:44 +0300 Subject: properly handle the exit status of plugins to avoid infinite restart attempts; plugins that report failure are now restarted up to 10 times if they have collected values in the past; apache fixed to work with latest apache; example plugin is now disabled by default to prevent starting bash in systems that dont have any other bash plugin used --- charts.d/apache.chart.sh | 23 ++++++++++------------- charts.d/example.chart.sh | 7 +++++++ 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'charts.d') diff --git a/charts.d/apache.chart.sh b/charts.d/apache.chart.sh index f4f7d0581b..a3e064094c 100755 --- a/charts.d/apache.chart.sh +++ b/charts.d/apache.chart.sh @@ -67,19 +67,14 @@ apache_detect() { # we will not check of the Conns* # keys, since these are apache 2.4 specific - if [ -z "${apache_key_accesses}" \ - -o -z "${apache_key_kbytes}" \ - -o -z "${apache_key_reqpersec}" \ - -o -z "${apache_key_bytespersec}" \ - -o -z "${apache_key_bytesperreq}" \ - -o -z "${apache_key_busyworkers}" \ - -o -z "${apache_key_idleworkers}" \ - -o -z "${apache_key_scoreboard}" \ - ] - then - echo >&2 "apache: Invalid response or missing keys from apache server: ${*}" - return 1 - fi + [ -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 if [ ! -z "${apache_key_connstotal}" \ -a ! -z "${apache_key_connsasyncwriting}" \ @@ -88,6 +83,8 @@ apache_detect() { ] then apache_has_conns=1 + else + apache_has_conns=0 fi return 0 diff --git a/charts.d/example.chart.sh b/charts.d/example.chart.sh index ad20504621..b20740e862 100755 --- a/charts.d/example.chart.sh +++ b/charts.d/example.chart.sh @@ -7,14 +7,21 @@ # between the calls of the _update() function example_update_every= +# the priority is used to sort the charts on the dashboard +# 1 = the first chart example_priority=150000 +# to enable this chart, you have to set this to 12345 +# (just a demonstration for something that needs to be checked) +example_magic_number= + # _check is called once, to find out if this chart should be enabled or not example_check() { # this should return: # - 0 to enable the chart # - 1 to disable the chart + [ "${example_magic_number}" != "12345" ] && return 1 return 0 } -- cgit v1.2.3