X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=charts.d%2Fapache.chart.sh;h=b503e74e3d2cdb8e8acd25e937c23d19aea858e9;hb=0711ceaacadf4b435b11377ce9f0e65392675d2a;hp=20c59afabb152a4a74094385c9445f437b8f46f4;hpb=4816f581ba1103f0b8d3923b51f1538f109da5ab;p=netdata.git diff --git a/charts.d/apache.chart.sh b/charts.d/apache.chart.sh old mode 100755 new mode 100644 index 20c59afa..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 @@ -45,38 +54,33 @@ apache_detect() { for x in "${@}" do case "${x}" in - '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] ;; + '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}" \ - -o -z "${apache_key_scoreboard}" \ - ] - then - echo >&2 "apache: Invalid response or missing keys from apache server: ${*}" - return 1 - fi + [ -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}" \ @@ -85,6 +89,8 @@ apache_detect() { ] then apache_has_conns=1 + else + apache_has_conns=0 fi return 0 @@ -92,7 +98,7 @@ apache_detect() { apache_get() { local oIFS="${IFS}" ret - IFS=$':\n' apache_response=($(curl -s "${apache_url}")) + IFS=$':\n' apache_response=($(run curl -Ss ${apache_curl_opts} "${apache_url}")) ret=$? IFS="${oIFS}" @@ -130,7 +136,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 +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 @@ -165,27 +171,27 @@ apache_check() { # _create is called once, to create the charts apache_create() { cat <