FiveRuns Blog

On Rails production performance and monitoring

Posts
No comments

Instrumenting Apache

Like most servers, Apache allows you to capture details about its performance and status. These metrics are not published by default however and can be tricky to configure securely, especially in an environment using virtual hosts. This article describes how to configure Apache2 to enable its server-status statistics which can be viewed directly via web browser or collected by monitoring tools such as FiveRuns Manage. Additional metrics are published by enabling ExtendedStatus which we will also enable.

In its simplest implementation, there are just a few steps to enable Apache’s mod_status. In the Apache2 configuration file, (often: /etc/apache2/apache2.conf for Apache2 and /etc/httpd/conf/http.conf for Apache v.1.x) this is enabled by adding or uncommenting the following lines:

LoadModule status_module  libexec/apache2/mod_status.so 
ExtendedStatus On

<Location /server-status>
     SetHandler server-status
     order deny,allow
     deny from all
     allow from 127.0.0.1
</Location>

The above edits and a restart of Apache will publish the status metrics to clients on the local system. As in the Apache.org example, security can be lowered to allow remote clients access the server statistics. Since that can be a security concern and because monitoring tools can be installed locally, our examples restrict access to the local web server.

One challenge we often encounter is Apache environments using virtual hosts. The <Location /server-status> directive needs to either appear in the parent apache.conf/http.conf file or in the virtual host that is loaded first. When multiple .conf files are loaded via the Include directive, it is done alphabetically, so consider this when inserting the server-status Location block.

Alternately, you could dedicate a virtual host to serve the status information and bypass the load ordering issue above. The example below details a NameVirtualHost configuration utilizing the localhost hostname. A similar approach could be used to dedicate a vhost using IP-based Virtual Hosts and 127.0.0.1.

<VirtualHost *:80>
  ServerName localhost
  ServerAlias 127.0.0.1
  DocumentRoot /var/www/

  <Location />
     order deny,allow
     deny from all
     allow from 127.0.0.1
  </Location>

  <Location /server-status>
     SetHandler server-status
     order deny,allow
     deny from all
     allow from 127.0.0.1
  </Location>

  <Directory /var/www/>
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>

</VirtualHost>
Bookmark and Share
Continued Discussion

No comments have been added yet.

Contribute

Continue the conversation and share your thoughts. A name is required. Your e-mail address will not be displayed on the site. Textile formatting may be used in your comments (but will not be rendered in the live comment preview).

→ Posted by You on November 21, 2008 at 08:48 PM

Flickr

FiveRuns tagged photos on Flickr.

  • Al
  • FiveRuns at the SF Ruby User Group
  • FiveRuns at the SF Ruby User Group
  • FiveRuns at the SF Ruby User Group
  • Mindy
  • Mark
  • FiveRuns at the SF Ruby User Group
  • FiveRuns at the SF Ruby User Group

See more FiveRuns tagged photos…

Previous Entries

Other Categories

Entries are also organized under the following general topic categories.