Monitor Apache HTTPD server in real-time

Q I have recently started a small design business and am now hosting a number of sites for my clients on my dedicated Red Hat Enterprise Linux 3 server. As I have numerous access_log files scattered all over the filesystem, what's the easiest way to keep a real-time view of what's going on with the HTTPD web server? If I use top, I can see several HTTPD processes consuming a fair bit of CPU, but I don't know how to associate these processes with a particular website.

A The HTTPD server on RHEL 3 comes pre-packaged with mod_status, which is an Apache module for monitoring how the web server is performing. To enable it, open up /etc/httpd/conf/httpd.conf and uncomment the following lines:

<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from desktop.ip
</Location>

To obtain a full status report, also uncomment this line:

ExtendedStatus On

After restarting the HTTPD server, you can browse http://server.ip/server-status?refresh=5. This will display an HTML page that refreshes every five seconds, providing you with the following information:

  • The number of workers (threads) serving requests.
  • The number of idle workers.
  • 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.

(Quoted directly from http://httpd.apache.org/docs/2.0/mod/mod_status.html.) It is also good practice to keep this information restricted to specific hosts, as a lot of information is revealed about your HTTPD server through this module. Leaving the default Deny From All and then opening up access with Allow From Desktop.ip will ensure that only authorised hosts are permitted to view this information.

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar