X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=charts.d%2Fapache.chart.sh;h=b503e74e3d2cdb8e8acd25e937c23d19aea858e9;hb=b060bae83cc36fdc4f14120228e4c9b0d1ec42e8;hp=eeb90247bf44df9cafb780f567d6b094520282e6;hpb=63aed58633cb183c4769898c4b1c625ad5e0fde6;p=netdata.git diff --git a/charts.d/apache.chart.sh b/charts.d/apache.chart.sh old mode 100755 new mode 100644 index eeb90247..b503e74e --- a/charts.d/apache.chart.sh +++ b/charts.d/apache.chart.sh @@ -1,12 +1,21 @@ -#!/bin/sh +# no need for shebang - this file is loaded from charts.d.plugin + +# netdata +# real-time performance and health monitoring, done right! +# (C) 2016 Costa Tsaousis +# GPL v3+ +# # the URL to download apache status info apache_url="http://127.0.0.1:80/server-status?auto" +apache_curl_opts= # _update_every is a special variable - it holds the number of seconds # between the calls of the _update() function apache_update_every= +apache_priority=60000 + # convert apache floating point values # to integer using this multiplier # this only affects precision - the values @@ -21,8 +30,13 @@ apache_bytespersec=0 apache_bytesperreq=0 apache_busyworkers=0 apache_idleworkers=0 +apache_connstotal=0 +apache_connsasyncwriting=0 +apache_connsasynckeepalive=0 +apache_connsasyncclosing=0 apache_keys_detected=0 +apache_has_conns=0 apache_key_accesses= apache_key_kbytes= apache_key_reqpersec= @@ -30,6 +44,7 @@ apache_key_bytespersec= apache_key_bytesperreq= apache_key_busyworkers= apache_key_idleworkers= +apache_key_scoreboard= apache_key_connstotal= apache_key_connsasyncwriting= apache_key_connsasynckeepalive= @@ -39,45 +54,59 @@ apache_detect() { for x in "${@}" do case "${x}" in - 'Accesses:') apache_key_accesses=$[i + 1] ;; - 'kBytes:') apache_key_kbytes=$[i + 1] ;; - 'ReqPerSec:') apache_key_reqpersec=$[i + 1] ;; - 'BytesPerSec:') apache_key_bytespersec=$[i + 1] ;; - 'BytesPerReq:') apache_key_bytesperreq=$[i + 1] ;; - 'BusyWorkers:') apache_key_busyworkers=$[i + 1] ;; - 'IdleWorkers:') apache_key_idleworkers=$[i + 1] ;; - 'ConnsTotal:') apache_key_connstotal=$[i + 1] ;; - 'ConnsAsyncWriting:') apache_key_connsasyncwriting=$[i + 1] ;; - 'ConnsAsyncKeepAlive:') apache_key_connsasynckeepalive=$[i + 1] ;; - 'ConnsAsyncClosing:') apache_key_connsasyncclosing=$[i + 1] ;; + 'Total Accesses') apache_key_accesses=$((i + 1)) ;; + 'Total kBytes') apache_key_kbytes=$((i + 1)) ;; + 'ReqPerSec') apache_key_reqpersec=$((i + 1)) ;; + 'BytesPerSec') apache_key_bytespersec=$((i + 1)) ;; + 'BytesPerReq') apache_key_bytesperreq=$((i + 1)) ;; + 'BusyWorkers') apache_key_busyworkers=$((i + 1)) ;; + 'IdleWorkers') apache_key_idleworkers=$((i + 1));; + 'ConnsTotal') apache_key_connstotal=$((i + 1)) ;; + 'ConnsAsyncWriting') apache_key_connsasyncwriting=$((i + 1)) ;; + 'ConnsAsyncKeepAlive') apache_key_connsasynckeepalive=$((i + 1)) ;; + 'ConnsAsyncClosing') apache_key_connsasyncclosing=$((i + 1)) ;; + 'Scoreboard') apache_key_scoreboard=$((i)) ;; esac - i=$[i + 1] + i=$((i + 1)) done # 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}" \ + [ -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}" \ + -a ! -z "${apache_key_connsasynckeepalive}" \ + -a ! -z "${apache_key_connsasyncclosing}" \ ] then - echo >&2 "apache: Invalid response or missing keys from apache server: ${*}" - return 1 + apache_has_conns=1 + else + apache_has_conns=0 fi return 0 } apache_get() { - apache_response=($(curl -s "${apache_url}")) - [ $? -ne 0 -o "${#apache_response[@]}" -eq 0 ] && return 1 + local oIFS="${IFS}" ret + 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 - if [ ${apache_keys_detected} -eq 0 ] + # 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 apache_detect "${apache_response[@]}" || return 1 apache_keys_detected=1 @@ -107,10 +136,18 @@ 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 + if [ ${apache_has_conns} -eq 1 ] + then + apache_connstotal="${apache_response[${apache_key_connstotal}]}" + apache_connsasyncwriting="${apache_response[${apache_key_connsasyncwriting}]}" + apache_connsasynckeepalive="${apache_response[${apache_key_connsasynckeepalive}]}" + apache_connsasyncclosing="${apache_response[${apache_key_connsasyncclosing}]}" + fi + return 0 } @@ -120,7 +157,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 @@ -134,21 +171,33 @@ apache_check() { # _create is called once, to create the charts apache_create() { cat <