Tuesday, August 16, 2011

How To Access(& Monitoring) Apache Server Counters

The Apache server comes with different counters which allows you to monitor the health of the server. When extended status is enabled you can not only access default counters but also the following counters. They are:

Extended Status ON
*Total Accesses - Total access count since the server was started
*Total kBytes - Total volume delivered in bytes since the server was started
*Uptime - Time during which the server was running
*ReqPerSec - Average number of requests per second since the server was started
*BytesPerSec - Average number of bytes delivered per second
*BytesPerReq - Average number of bytes per request
*CPULoad - not available on most Win32 versions

Default Counters
*BusyWorkers - Number of worker processes actively processing requests
*IdleWorkers - Number of worker processes idle

How To Access The Apache Counters
The following steps are based on Apache 2.2 version (it was installed as part of XAMPP application). Also I am running the server on my local machine.

1: Open up the httpd.conf file. If installed via XAMPP, this file is found in the "conf" folder in the main "Apache" folder.
2: Search for "status_module" module and remove "#" tag infront of LoadModule text, incase it exists. Change "#LoadModule status_module modules/mod_status.so" to "LoadModule status_module modules/mod_status.so". See the screenshot below.
3: Restart the Apache Server for server to pick up the changes made to conf file.
4: Navigate to "http://localhost/server-status?auto" URL. Now you should be able to monitor the default counters(see the screenshot below). If the server is running on a remote machine then the URL will be "http://servername:port/server-status?auto".

To get further Apache counters, perform the following actions:
5: Add "ExtendedStatus On" text at the bottom of the httpd.conf file. See the screenshot below.
6: Restart the Apache Server for server to pick up the changes made to conf file.
7: Navigate to "http://localhost/server-status?auto" URL. Now you should be able to view the default counters as well as the extended counters(see the screenshot below).

If you want further information such as "PID", "DNS Lookup", "Waiting for Connection", "Reading Request", Server Version etc, then just navigate to the following URL ("http://localhost/server-status") on your localhost or "http://servername:port/server-status" for remote server. See the screenshot below.



NOTE: By default ExtendedStatus is not enabled. When enabled it will make multiple time calls and this can cause a performance hit.

NOTE:Once you have enabled the status, you can access these counters via the HP SiteScope application.

No comments: