Apache allows us to grab usage statistics
example
Apache Server Status for 192.168.1.80 Server Version: Apache/2.2.15 (Unix) DAV/2 PHP/5.3.3 Server Built: Feb 13 2012 22:31:42 Current Time: Tuesday, 26-Feb-2013 17:25:26 GMT Restart Time: Tuesday, 26-Feb-2013 17:25:00 GMT Parent Server Generation: 0 Server uptime: 26 seconds Total accesses: 19 - Total Traffic: 6 kB CPU Usage: u0 s0 cu0 cs0 .731 requests/sec - 236 B/second - 323 B/request 1 requests currently being processed, 7 idle workers
The default location for these is http:/localhost/server-stats
Enable server stats
to enable change the apache httpd.conf (/etc/httpd/conf/httpd.conf)
1. Enable line:
ExtendedStatus On
2. uncomment server stats section :
SetHandler server-status
Order deny,allow
Allow from 127.0.0.1
Deny from all
- amend the above to suit local requirements.
check the change config file:
[root]# apachectl configtest
Syntax OK
3. once changed remember to restart the http server :service httpd restart
So, now we’ve grabbed the data, what can we do with it? Using wget, we can grab the data and pass that onto a monitoring system for subsequent trend or alerting.
I’m using Zabbix to monitor which when configured gives me this example graph:
Method
to achieve this, choose a method from the Zabbix wiki :
For simplicity, i’m using Method 3
Apache Server
1. down load the script & template from above wiki link.
2. copy the shell script to required path – here i’m using /etc/zabbix/externalscripts
3. on the machine running apache, append to the agent conf file
UserParameter=apache[*],/etc/zabbix/externalscripts/zapache.sh \$1
4. Restart the zabbix agent : service zabbix-agent restart
Zabbix Server
a good tip before enabling importing any template and subsequent triggers is on the zabbix server use zabbix_get
to check the configuration works.
eg zabbix_get -s [servername] -p 10050 -k apache[Uptime]
1. import the download template
2. assign the template to the apache server
3. check for incoming data/errors etc.
4. create any required graphs