3 # the URL to download apache status info
4 apache_url="http://127.0.0.1:80/server-status?auto"
6 # _update_every is a special variable - it holds the number of seconds
7 # between the calls of the _update() function
10 # convert apache floating point values
11 # to integer using this multiplier
12 # this only affects precision - the values
13 # will be in the proper units
14 apache_decimal_detail=1000000
16 declare -a apache_response=()
25 apache_keys_detected=0
29 apache_key_bytespersec=
30 apache_key_bytesperreq=
31 apache_key_busyworkers=
32 apache_key_idleworkers=
33 apache_key_connstotal=
34 apache_key_connsasyncwriting=
35 apache_key_connsasynckeepalive=
36 apache_key_connsasyncclosing=
42 'Accesses:') apache_key_accesses=$[i + 1] ;;
43 'kBytes:') apache_key_kbytes=$[i + 1] ;;
44 'ReqPerSec:') apache_key_reqpersec=$[i + 1] ;;
45 'BytesPerSec:') apache_key_bytespersec=$[i + 1] ;;
46 'BytesPerReq:') apache_key_bytesperreq=$[i + 1] ;;
47 'BusyWorkers:') apache_key_busyworkers=$[i + 1] ;;
48 'IdleWorkers:') apache_key_idleworkers=$[i + 1] ;;
49 'ConnsTotal:') apache_key_connstotal=$[i + 1] ;;
50 'ConnsAsyncWriting:') apache_key_connsasyncwriting=$[i + 1] ;;
51 'ConnsAsyncKeepAlive:') apache_key_connsasynckeepalive=$[i + 1] ;;
52 'ConnsAsyncClosing:') apache_key_connsasyncclosing=$[i + 1] ;;
58 # we will not check of the Conns*
59 # keys, since these are apache 2.4 specific
60 if [ -z "${apache_key_accesses}" \
61 -o -z "${apache_key_kbytes}" \
62 -o -z "${apache_key_reqpersec}" \
63 -o -z "${apache_key_bytespersec}" \
64 -o -z "${apache_key_bytesperreq}" \
65 -o -z "${apache_key_busyworkers}" \
66 -o -z "${apache_key_idleworkers}" \
69 echo >&2 "apache: Invalid response or missing keys from apache server: ${*}"
77 apache_response=($(curl -s "${apache_url}"))
78 [ $? -ne 0 -o "${#apache_response[@]}" -eq 0 ] && return 1
80 if [ ${apache_keys_detected} -eq 0 ]
82 apache_detect "${apache_response[@]}" || return 1
83 apache_keys_detected=1
86 apache_accesses="${apache_response[${apache_key_accesses}]}"
87 apache_kbytes="${apache_response[${apache_key_kbytes}]}"
89 float2int "${apache_response[${apache_key_reqpersec}]}" ${apache_decimal_detail}
90 apache_reqpersec=${FLOAT2INT_RESULT}
92 float2int "${apache_response[${apache_key_bytespersec}]}" ${apache_decimal_detail}
93 apache_bytespersec=${FLOAT2INT_RESULT}
95 float2int "${apache_response[${apache_key_bytesperreq}]}" ${apache_decimal_detail}
96 apache_bytesperreq=${FLOAT2INT_RESULT}
98 apache_busyworkers="${apache_response[${apache_key_busyworkers}]}"
99 apache_idleworkers="${apache_response[${apache_key_idleworkers}]}"
101 if [ -z "${apache_accesses}" \
102 -o -z "${apache_kbytes}" \
103 -o -z "${apache_reqpersec}" \
104 -o -z "${apache_bytespersec}" \
105 -o -z "${apache_bytesperreq}" \
106 -o -z "${apache_busyworkers}" \
107 -o -z "${apache_idleworkers}" \
110 echo >&2 "apache: empty values got from apache server: ${apache_response[*]}"
117 # _check is called once, to find out if this chart should be enabled or not
123 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"
127 # this should return:
128 # - 0 to enable the chart
129 # - 1 to disable the chart
134 # _create is called once, to create the charts
137 CHART apache.bytesperreq '' "apache Lifetime Avg. Response Size" "bytes/request" apache apache area 16008 $apache_update_every
138 DIMENSION size '' absolute 1 ${apache_decimal_detail}
139 CHART apache.workers '' "apache Workers" "workers" apache apache stacked 16005 $apache_update_every
140 DIMENSION idle '' absolute 1 1
141 DIMENSION busy '' absolute 1 1
142 CHART apache.reqpersec '' "apache Lifetime Avg. Requests/s" "requests/s" apache apache line 16006 $apache_update_every
143 DIMENSION requests '' absolute 1 ${apache_decimal_detail}
144 CHART apache.bytespersec '' "apache Lifetime Avg. Bandwidth/s" "kilobits/s" apache apache area 16007 $apache_update_every
145 DIMENSION sent '' absolute 8 $[apache_decimal_detail * 1000]
146 CHART apache.requests '' "apache Requests" "requests/s" apache apache line 16001 $apache_update_every
147 DIMENSION requests '' incremental 1 1
148 CHART apache.net '' "apache Bandwidth" "kilobits/s" apache apache area 16002 $apache_update_every
149 DIMENSION sent '' incremental 8 1
155 # _update is called continiously, to collect the values
158 # the first argument to this function is the microseconds since last update
159 # pass this parameter to the BEGIN statement (see bellow).
161 # do all the work to collect / calculate the values
163 # remember: KEEP IT SIMPLE AND SHORT
165 apache_get || return 1
167 # write the result of the work.
169 BEGIN apache.requests $1
170 SET requests = $[apache_accesses]
173 SET sent = $[apache_kbytes]
175 BEGIN apache.reqpersec $1
176 SET requests = $[apache_reqpersec]
178 BEGIN apache.bytespersec $1
179 SET sent = $[apache_bytespersec]
181 BEGIN apache.bytesperreq $1
182 SET size = $[apache_bytesperreq]
184 BEGIN apache.workers $1
185 SET idle = $[apache_idleworkers]
186 SET busy = $[apache_busyworkers]