Tips & Tricks: Monitoring your Apache Web Server

Monitoring Apache Web Servers

Why?

Monitoring the status of an Apache Web Server that is hosting your web based application is very useful in the following situations:

  • To determine if your Web Server is accepting requests
  • The number of connected clients, status of client workers, and requests per second
  • Web Server up time and CPU load

How?

To monitor the Apache server during operation a simple modification can be used (and afterwards a browser can be connected to the status page on the Apache server to quickly access the results).

Steps:
Modify the httpd.conf file adding the following lines (change foo.com to the domain name where you will connect your browser to check for status):

<Location /server-status>

SetHandler server-status
Order Deny,Allow
Deny from all
Allow from .foo.com

</Location>

Access your web browser here.

This will provide a list of:

•   The number of worker serving requests
•   The number of idle worker
•   The status of each worker, the number of requests that worker has performed and the total number of bytes served by the worker (*)
•   A total number of accesses and byte count served (*)
•   The time the server was started/restarted and the time it has been running for
•   Averages giving the number of requests per second, the number of bytes served per second and the average number of bytes per request (*)
•   The current percentage CPU used by each worker and in total by Apache (*)
•   The current hosts and requests being processed (*)

The status page will report the following:

Apache Server Status for localhost
Server Version: Apache/2.2.19 (Win32)
Server Built: May 20 2011 17:39:35

——————————————————————————–

Current Time: Wednesday, 13-Jul-2011 15:26:11 Central Daylight Time
Restart Time: Wednesday, 13-Jul-2011 15:24:53 Central Daylight Time
Parent Server Generation: 0
Server uptime: 1 minute 17 seconds
1 requests currently being processed, 63 idle workers
_______________________________________________________________W
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….
……………………………………………………….

Scoreboard Key:
“_” Waiting for Connection, “S” Starting up, “R” Reading Request,
“W” Sending Reply, “K” Keepalive (read), “D” DNS Lookup,
“C” Closing connection, “L” Logging, “G” Gracefully finishing,
“I” Idle cleanup of worker, “.” Open slot with no current process

PID Key:

3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: _ , 3500 in state: _ , 3500 in state: _
3500 in state: W ,