21.9. Looking Inside the ServerThere are a number of tools that allow you look at the server internals at runtime, through a convenient web interface. 21.9.1. Apache::Status—Embedded Interpreter Status InformationThis is a very useful module. It lets you watch what happens to the Perl part of the mod_perl server. You can watch the size of all subroutines and variables, variable dumps, lexical information, opcode trees, and more. You shouldn't use it on a production server, as it adds quite a bit of overhead for each request. 21.9.1.1. Minimal configurationThis configuration enables the Apache::Status module with its minimum feature set. Add this to httpd.conf: <Location /perl-status> SetHandler perl-script PerlHandler Apache::Status </Location> If you are going to use Apache::Status it's important to put it as the first module in the startup file, or in httpd.conf: # startup.pl use Apache::Status ( ); use Apache::Registry ( ); use Apache::DBI ( ); For example, if you use Apache::DBI and you don't load Apache::Status before Apache::DBI, you will not get the Apache::DBI menu entry (which allows you to see persistent connections). 21.9.1.2. Extended configurationThere are several variables you can use to modify the behavior of Apache::Status:
There is more information about Apache::Status in its manpage. 21.9.1.3. UsageAssuming that your mod_perl server is listening on port 81, fetch http://www.example.com:81/perl-status: Embedded Perl version v5.6.1 for Apache/1.3.17 (Unix) mod_perl/1.25 process 9943, running since Fri Feb 9 17:48:50 2001 All the sections below are links when you view them through /perl-status: Perl Configuration Loaded Modules Inheritance Tree Enabled mod_perl Hooks Environment PerlRequire'd Files Signal Handlers Symbol Table Dump ISA Tree Compiled Registry Scripts Here's what these sections show:
From some menus you can move deeper to peek into the internals of the server, to see the values of the global variables in the packages, to see the cached scripts and modules, and much more. Just click around. Remember that whenever you access /perl-status you are always inside one of the child processes, so you may not see what you expect, since this child process might have a different history of processed requests and therefore a different internal state. Sometimes when you fetch /perl-status and look at the Compiled Registry Scripts section you see no listing of scripts at all. Apache::Statusshows the registry scripts compiled in the httpd child that is serving your request for /perl-status; if the child has not yet compiled the requested script, /perl-status will just show you the main menu. 21.9.2. mod_statusThe mod_status module allows a server administrator to find out how well the server is performing. An HTML page is presented that gives the current server statistics in an easily readable form. If required, given a compatible browser, this page can be automatically refreshed. Another page gives a simple machine-readable list of the current server state. This Apache module is written in C. It is compiled by default, so all you have to do to use it is enable it in your configuration file: <Location /status> SetHandler server-status </Location> For security reasons you will probably want to limit access to it. If you have installed Apache according to the instructions given in this book, you will find a prepared configuration section in httpd.conf. To enable use of the mod_status module, just uncomment it: ExtendedStatus On <Location /status> SetHandler server-status Order deny,allow Deny from all Allow from localhost </Location> You can now access server statistics by using a web browser to access the page http://localhost/status (as long as your server recognizes localhost). The details given by mod_status are:
In Chapter 5 you can read about Apache::VMonitor, which is a more advanced sibling of mod_status. Turning the ExtendedStatus mode on is not recommended for high-performance production sites, as it adds overhead to the request response times. Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|