the Apache module mod_status is very useful for inspecting your running webserver, but it gives you only realtime informations about workers, connections, and so on. I wanted a way to keep this data and then be able to do comparison, charts and more useful reports. The first step was configuring mod_status in order to be only accessible from localhost:
andrea@myserver:~$ cat /etc/apache2/mods-enabled/status.conf
<IfModule mod_status.c>
#
# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Uncomment and change the "192.0.2.0/24" to allow access from other hosts.
#
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1 ::1
# Allow from 192.0.2.0/24
</Location>
# Keep track of extended status information for each request
ExtendedStatus On
# Determine if mod_status displays the first 63 characters of a request or
# the last 63, assuming the request itself is greater than 63 chars.
# Default: Off
#SeeRequestTail On
<IfModule mod_proxy.c>
# Show Proxy LoadBalancer status in mod_status
ProxyStatus On
</IfModule>
</IfModule>
now a little shell script to grab the status page together with other useful informations…
andrea@myserver:~ $ cat apache_status_logger.sh
#!/bin/sh
(date +%Y%m%d_%H%M%S && links2 -dump http://127.0.0.1/server-status && top -n1 -b) >> /home/andrea/apache_status_$(date +%Y%m%d).log
scheduled every 5 minutes with a cron entry like this:
# m h dom mon dow command
*/5 * * * * /home/andrea/apache_status_logger.sh
you will get for each day a separate file with date, time, apache status, and a list of running processes with their statistics. Now you can parse the data with any tool you want; i.e. want to know which was the busiest days?
andrea@myserver:~$ grep 'requests currently' apache_status_*.log | sort -k2 -nr | head -5
apache_status_20141024.log: 132 requests currently being processed, 0 idle workers
apache_status_20141024.log: 78 requests currently being processed, 0 idle workers
apache_status_20141103.log: 48 requests currently being processed, 3 idle workers
apache_status_20141028.log: 47 requests currently being processed, 2 idle workers
apache_status_20141030.log: 42 requests currently being processed, 0 idle workers