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 # let netdata calculate averages (0)
11 # or use apache calculated averages (1)
14 # convert apache floating point values
15 # to integer using this multiplier
16 # this only affects precision - the values
17 # will be in the proper units
18 apache_decimal_detail=1000000
20 declare -a apache_response=()
33 apache_response=($(curl -s "${apache_url}"))
34 [ $? -ne 0 -o "${#apache_response[@]}" -eq 0 ] && return 1
36 if [ "${apache_response[0]}" != "Total" \
37 -o "${apache_response[1]}" != "Accesses:" \
38 -o "${apache_response[3]}" != "Total" \
39 -o "${apache_response[4]}" != "kBytes:" \
40 -o "${apache_response[6]}" != "CPULoad:" \
41 -o "${apache_response[8]}" != "Uptime:" \
42 -o "${apache_response[10]}" != "ReqPerSec:" \
43 -o "${apache_response[12]}" != "BytesPerSec:" \
44 -o "${apache_response[14]}" != "BytesPerReq:" \
45 -o "${apache_response[16]}" != "BusyWorkers:" \
46 -o "${apache_response[18]}" != "IdleWorkers:" \
47 -o "${apache_response[20]}" != "Scoreboard:" \
50 echo >&2 "apache: Invalid response from apache server: ${apache_response[*]}"
54 apache_accesses="${apache_response[2]}"
55 apache_kbytes="${apache_response[5]}"
57 # float2int "${apache_response[7]}" ${apache_decimal_detail}
58 # apache_cpuload=${FLOAT2INT_RESULT}
60 # apache_uptime="${apache_response[9]}"
62 if [ ${apache_averages} -eq 1 ]
64 float2int "${apache_response[11]}" ${apache_decimal_detail}
65 apache_reqpersec=${FLOAT2INT_RESULT}
67 float2int "${apache_response[13]}" ${apache_decimal_detail}
68 apache_bytespersec=${FLOAT2INT_RESULT}
71 float2int "${apache_response[15]}" ${apache_decimal_detail}
72 apache_bytesperreq=${FLOAT2INT_RESULT}
74 apache_busyworkers="${apache_response[17]}"
75 apache_idleworkers="${apache_response[19]}"
76 apache_scoreboard="${apache_response[21]}"
78 if [ -z "${apache_accesses}" \
79 -o -z "${apache_kbytes}" \
80 -o -z "${apache_cpuload}" \
81 -o -z "${apache_uptime}" \
82 -o -z "${apache_reqpersec}" \
83 -o -z "${apache_bytespersec}" \
84 -o -z "${apache_bytesperreq}" \
85 -o -z "${apache_busyworkers}" \
86 -o -z "${apache_idleworkers}" \
87 -o -z "${apache_scoreboard}" \
90 echo >&2 "apache: empty values got from apache server: ${apache_response[*]}"
97 # _check is called once, to find out if this chart should be enabled or not
103 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"
107 # this should return:
108 # - 0 to enable the chart
109 # - 1 to disable the chart
114 # _create is called once, to create the charts
117 CHART apache.bytesperreq '' "apache Average Response Size (lifetime)" "bytes/request" apache apache area 16005 $apache_update_every
118 DIMENSION size '' absolute 1 ${apache_decimal_detail}
119 CHART apache.workers '' "apache Workers" "workers" apache apache stacked 16006 $apache_update_every
120 DIMENSION idle '' absolute 1 1
121 DIMENSION busy '' absolute 1 1
124 if [ ${apache_averages} -eq 1 ]
126 # apache calculated averages
128 CHART apache.requests '' "apache Requests" "requests/s" apache apache line 16001 $apache_update_every
129 DIMENSION requests '' absolute 1 ${apache_decimal_detail}
130 CHART apache.net '' "apache Bandwidth" "kilobits/s" apache apache area 16002 $apache_update_every
131 DIMENSION sent '' absolute 8 $[apache_decimal_detail * 1000]
134 # netdata calculated averages
136 CHART apache.requests '' "apache Requests" "requests/s" apache apache line 16001 $apache_update_every
137 DIMENSION requests '' incremental 1 1
138 CHART apache.net '' "apache Bandwidth" "kilobits/s" apache apache area 16002 $apache_update_every
139 DIMENSION sent '' incremental 8 1
146 # _update is called continiously, to collect the values
149 # the first argument to this function is the microseconds since last update
150 # pass this parameter to the BEGIN statement (see bellow).
152 # do all the work to collect / calculate the values
154 # remember: KEEP IT SIMPLE AND SHORT
156 apache_get || return 1
158 if [ ${apache_averages} -eq 1 ]
160 reqs=${apache_reqpersec}
161 net=${apache_bytespersec}
163 reqs=${apache_accesses}
167 # write the result of the work.
169 BEGIN apache.requests $1
170 SET requests = $[reqs]
175 BEGIN apache.bytesperreq $1
176 SET size = $[apache_bytesperreq]
178 BEGIN apache.workers $1
179 SET idle = $[apache_idleworkers]
180 SET busy = $[apache_busyworkers]