A Perl Script For Monitoring Apache Server Status
By Lincoln D. Stein
Web servers rarely occur singly. They tend to run in packs. If you're a typical Webmaster, you're not responsible for just one server, but for a whole herd. It's easy enough to manage one or two servers, but when there are a half-dozen or more, you really need some sort of central server-management tool to keep track of what's going on and alert you to problems. Ideally, such a tool would run at regular intervals, contacting each of the servers under your care, logging the results, and alerting you if it detects that a server is no longer responding to requests.
There are a variety of commercial tools for this purpose. The ones that readers of this column most often recommend include WebTrends Log Analyzer, which uses FTP and server-side scripts to collect server performance statistics from log files, and WindDance Networks WebChallenger, which uses packet sniffing to pull its information directly off the local area network.
However, I've always done these sorts of things myself on the theory that the tools you create yourself are most likely to meet your evolving needs. In this column, I present a short Perl script that I use to collect usage and status information from the remote and local Apache Web servers that I manage. With some modifications, this script can be turned into a full-featured Web analysis tool.
The Apache status Module
Versions 1.2