This tutorial covers how to enable Apache server-status (mod_status) with extended status data on Centos servers. This data is useful for Apache profiling and understanding whats happening on your web-server.
It allows you to view a detailed status page for your web server which is useful for watching your web server’s performance during load testing or to gather activity data.
You can see what server-status looks like here:
http://www.apache.org/server-status
and extended status looks like this
http://www.apache.org/server-status/?auto
Make sure mod_status is installed
First you need to make sire that mod_Status is installed. This is the apache module that powers server-status. Apache is usually configured with mod_status already installed, but not accessible. To see if its installed first check your apache config file at
1 |
/etc/httpd/conf/httpd.conf |
and search for
1 |
LoadModule status_module modules/mod_status.so |
If there is a ‘#’ sign in front of it then its been disabled, you will need to remove this for it to work.
Note: It is always advisable to make a copy of the httpd.conf file before editing it in case things go wrong!
Opening up up server-status access
Once you have made sure that the mod_status module is active, you then need to enable the server-status link so you can access it. Search for the following code and edit it as it is below.
1 2 3 4 5 6 7 8 9 |
# Allow server status reports generated by mod_status, # with the URL of http://servername/server-status # Change the ".example.com" to match your domain to enable. # SetHandler server-status Order deny,allow Deny from all Allow from localhost |
For security reasons we suggest you only give your ‘localhost’ access to this data as we have done.
Setting up extended-status
In order to now enable access to ‘extended-status’ data you will need to find and activate ExtendedStatus in the same config file as follows
1 2 3 4 5 |
# ExtendedStatus controls whether Apache will generate "full" status # information (ExtendedStatus On) or just basic information (ExtendedStatus # Off) when the "server-status" handler is called. The default is Off. # ExtendedStatus On |
You Will then need to restart Apache, a hard restart is best:
1 |
sudo service httpd restart |
However you can also use the less intrusive way of restarting apache
1 |
sudo /usr/sbin/apachectl restart |
Testing
To test that server-status is running you can use Lynx, a command line based ASCII browser which allows you to test if things are working locally on your server.
You can easily install lynx via
1 |
sudo yum install lynx |
Then hit the server-status page as follows
lynx http://localhost/server-status?refresh=5
To see the extended server data hit
lynx http://localhost/server-status/?auto
Troubleshooting
If you get any errors, then its time to troubleshoot. A ‘not found’ error means that mod_status isn’t properly enabled. A ‘forbidden’ error means that the Location configuration for /server-status wont let you access the page. A ‘connection refused’ most likely means that apache isn’t listening on port 80 so may not be running.
For Systems with Virtual Hosts
Note that for systems with multiple virtual hosts its a bit more tricky. We will update this guide shortly with instructions for these systems.
What does it all mean?
Most often the mod_status output is used by other tools to chart the server’s activity over time. Viewed directly, the status page is handy for a quick overview of what your server is doing at a given moment. Some of the displayed data can indicate problems that merit investigation.
Examples of items to watch for on the status page include:
- A high CPU usage for apache could indicate a problem with an application being run through a module like mod_php.
- While it is normal to see several keep-alives being handled by apache’s workers, if they constitute a vast majority of the worker statuses you see then your web server might be keeping old connections alive too long. You may want to look into reducing the amount of time connections are kept alive by apache via the KeepAliveTimeout directive.
- If you see very few inactive workers (represented by . characters) you may want to increase the MaxClients value for your apache server. Making sure you have idle workers ready to handle new requests can improve the web server’s responsiveness (assuming you have enough memory on the server available to handle the extra connections).
Summary
Apache’s status module can help you to highlight problems that would be otherwise difficult to isolate using standard system tools. Even if you’re only enabling mod_status for a monitoring tool, knowing how to access and read the data can help you be a more effective web server administrator.
I developed a javascript application to display data in graphs
https://github.com/dioubernardo/apacheServerStatusCharts