HSLAB HTTP Monitor
Current Apache status is with the mod_status module
One nice way to get a snapshot of the current Apache status is with the mod_status module. mod_status describes the current state of every HTTP server, whether it is waiting for a new connection, reading the request, handling the request or writing a response.
mod_status is compiled into Apache by default, meaning that all you need to do in order to activate it is to set the appropriate directives, and set the default handler, or request-handling subroutine, to be ``server-status''. Any URL defined to have a handler of ``server-status'' then produces a status listing, ignoring the rest of the user's request.
It is thus most common for mod_status to be activated for only one URL. For example, we can create the virtual ``/server-status'' URL on our web server, such that anyone visiting /server-status will be shown the output from mod_status. We also indicate that Apache should always produce a full status listing, rather than the simple version. Here is one such simple configuration:
<Location /server-status>
SetHandler server-status
</Location>
ExtendedStatus On
Once I put those four lines inside of httpd.conf and restart Apache--or send it a HUP signal--I get the following output from the /server-status URL:
Server Version: Apache/1.3.12 (UNIX) mod_perl/1.24The status information begins with a fair amount of text indicating how long the server has been running, and how many times people have accessed the server. It also indicates just how many bytes are being served by this web process and how many servers are sitting idle. mod_status thus provides a nice window into the world of the Apache server, allowing us to see whether we have defined MaxSpareServers in the most resource-efficient manner.
Server Built: Mar 29 2000 12:25:42
Current Time: Friday, 21-Jul-2000 16:02:51 IDT
Restart Time: Friday, 21-Jul-2000 16:02:48 IDT
Parent Server Generation: 2
Server uptime: 3 seconds
Total accesses: 0 - Total Traffic: 0 kB
CPU Usage: u0 s0 cu0 cs0
0 requests/sec - 0 B/second -
1 requests currently being processed, 4 idle servers
mod_status then produces output in the following format, which can seem cryptic at first:
W____.............................................
.................................................
.................................................
.................................................
Each ``.'' character represents a potential Apache server process which is currently not running. Those that are waiting for a new connection are represented by ``_'' those that are reading input from the user's HTTP request are represented by ``R'' and writing their output to the user's browser are represented by ``W''. Not all letters may be visible at a given time; the current Apache status changes dynamically, and the output you see from mod_status will change to reflect that.
Following this display, we get a play-by-play view of what each active process is doing. We can see which connections are taking a long time to be processed, which connections are the most popular each month, and nearly any other facet.
Of course, it is normally a bad idea to open up your status information to the entire world. Luckily, you can use the ``Order'', ``Deny'' and ``Allow'' directives to restrict access to a set of IP addresses or to an entire domain. For example:
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from .lerner.co.il
</Location>
With the above configuration, mod_status will display results only for IP addresses in my domain. Requests coming from another domain will get an HTTP response indicating that access is forbidden to them.
Tags: -
Related entries:
Last update: 2006-12-22 02:24
Author: Oleg
Revision: 1.0