@cryptotaxi247 / netdata-1 / commits / 4816f581b

make sure parsing adapts to apache status responses

Costa Tsaousis (ktsaou) committed Jan 24, 2016 at 14:13 UTC 4816f581ba1103f0b8d3923b51f1538f109da5ab
1 file changed +7 -2
charts.d/apache.chart.sh
+7 -2
@@ -35,6 +35,7 @@ apache_key_bytespersec=
35 apache_key_bytesperreq=
36 apache_key_busyworkers=
37 apache_key_idleworkers=
38 +apache_key_scoreboard=
39 apache_key_connstotal=
40 apache_key_connsasyncwriting=
41 apache_key_connsasynckeepalive=
@@ -50,11 +51,12 @@ apache_detect() {
51 'BytesPerSec') apache_key_bytespersec=$[i + 1] ;;
52 'BytesPerReq') apache_key_bytesperreq=$[i + 1] ;;
53 'BusyWorkers') apache_key_busyworkers=$[i + 1] ;;
53 - 'IdleWorkers') apache_key_idleworkers=$[i + 1] ;;
54 + 'IdleWorkers') apache_key_idleworkers=$[i + 1];;
55 'ConnsTotal') apache_key_connstotal=$[i + 1] ;;
56 'ConnsAsyncWriting') apache_key_connsasyncwriting=$[i + 1] ;;
57 'ConnsAsyncKeepAlive') apache_key_connsasynckeepalive=$[i + 1] ;;
58 'ConnsAsyncClosing') apache_key_connsasyncclosing=$[i + 1] ;;
59 + 'Scoreboard') apache_key_scoreboard=$[i] ;;
60 esac
61
62 i=$[i + 1]
@@ -69,6 +71,7 @@ apache_detect() {
71 -o -z "${apache_key_bytesperreq}" \
72 -o -z "${apache_key_busyworkers}" \
73 -o -z "${apache_key_idleworkers}" \
74 + -o -z "${apache_key_scoreboard}" \
75 ]
76 then
77 echo >&2 "apache: Invalid response or missing keys from apache server: ${*}"
@@ -95,7 +98,9 @@ apache_get() {
98
99 [ $ret -ne 0 -o "${#apache_response[@]}" -eq 0 ] && return 1
100
98 - if [ ${apache_keys_detected} -eq 0 ]
101 + # the last line on the apache output is "Scoreboard"
102 + # we use this label to detect that the output has a new word count
103 + if [ ${apache_keys_detected} -eq 0 -o "${apache_response[${apache_key_scoreboard}]}" != "Scoreboard" ]
104 then
105 apache_detect "${apache_response[@]}" || return 1
106 apache_keys_detected=1