jump to navigation

Monitor Apache’s Performance with “mod_status” Module November 22, 2012

Posted by Tournas Dimitrios in Linux.

Apache’s Status module (mod_status) allows a server administrator to find out how well his web-server is performing . All reports are generated in a html format and can be accessed via a graphical or text-based browser (terminal browser — lynx — ) . Accessing the html page produces an snapshot of Apache’s status (static content) , using a compatible browser though , a mirror of live statistics can be displayed (made by automatically refresh) . While we can get the same information  by checking Apache’s access log-files or by using regular Linux / UNIX commands such as lsof – netstat – top – vmstat  (and others) , it’s obvious how convenient our Apache monitoring tasks can be when all these information is gathered into one single access point .  Although this module (mod_status) is installed by default on all Apache installations , it must be enabled from within Apache’s configuration file . Some of the details that are revealed by mod_status  are listed below  :

  • Averages giving the number of requests per second
  • The number of worker serving requests
  • The number of idle worker
  • The status of each worker, the number of requests that worker
  • The time the server was started/restarted and the time it has been running for
  • If mod_status is configured in extended-status , more details are displayed . Keep in mind though , the collection of extended status information can slow down the server.

The Apache Project keeps their server status page available to the general public .

Of course , we don’t want these information to be publicly accessible (hope it’s obvious) , so we will configure Apache’s configuration file to serve mod_status statistics only to local requests (via a text-based browser — lynx — ) . The process of enabling and configuring of mod_status is done from within Apache’s configuration file . This article presents the configurations made on a CentOs 6 installation  (/etc/httpd/conf/httpd.conf ) , there shouldn’t be significant differences on other distributions though  . Here follows the configuration process  :

  • Comment out the line with the following directive  :
    LoadModule status_module modules/mod_status.so
    If there is a “#” character in front of LoadModule , that means mod_status is disabled . Remove the # to enable mod_status
  • Still in httpd.conf , scroll down until you find the following section
    Just un-comment lines 922 up-to line 927 (by removing the # )  , or duplicate these lines (as I did) . Notice the “Allow from” line , set it to (this will restrict access only to localhost) .
    If you had created one or more virtual hosts , you’ll want to paste this configuration for the /server-status location into the default virtual host for every domain configured in Apache’s configuration file .  “example.com/server-status“). Then you would need to  change each “<Location /server-status> ” line on every virtual host section . For instance , <Location http://www.example1.com/server-status&gt;<Location http://www.anotherexample.com/server-status&gt; .
  • Enabling ExtendedStatus : This setting adds more information to the status page Apache returns , like CPU use and requests per second . Enabling this directive makes Apache do a little extra work when it gets a status request , so you might get a performance hit on a busy server . Some monitoring applications , like munin , require that this directive is enabled before they can monitor Apache . Find the following line and un-comment it :
    ExtendedStatus On
  • Restart Apache
    service  httpd  restart  (on CentOs)
    apachectl restart  (on all distro’s)
  • Installing a text-based  browser (lynx) : With Apache’s  status page restricted to localhost access we won’t be able to see the page from a web browser , so a terminal based browser will be installed .
    yum  install lynx 
  • Let’s have fun !

Most of the server status page statistics should be pretty self-explanatory . Most notable indication is the  “CPU Usage”  ( high CPU usage could indicate a problem with an running application –mod_php — , time to upgrade your server’s RAM ) . Another indication , the “__”  waiting for connection , can be configured by increased by Apache’s  “MaxClientsdirective .

Just for demonstration purposes , let’s create some fake http-requests with the help of Apache’s bench-marking tool “ab”  .

This results into the following mod_status metrics :

Of course , bench-marking Apache is out of the scope of this article . Factors that influence the results taken from mod_status are : hardware/platform that Apache is installed on , how many modules were initialized during Apache’s start-up process , how Apache was compiled ( prefork , worker , event ) and many more .


1. Victor - November 22, 2012

hi, i just discovered your blog on google and i must say this blog is great.

2. DMC - November 26, 2012

I have read so many content concerning the blogger lovers except this post
is actually a pleasant post, keep it up.

3. Teresa - November 26, 2012

I do not even know how I ended up here, but I thought this
post was great. I don’t know who you are but definitely you are going to a famous blogger if you are not already😉 Cheers!

4. Wendy - November 30, 2012

Wow! In the end I got a website from where I be able to
in fact obtain useful facts regarding my study and knowledge.

5. carol - November 30, 2012

helpful blog, bookmarked the website with hopes to read more, this is the way a blog should be! thanks!

6. Cidinha - December 6, 2012

simply, admirable what you have done here. it is pleasing to look you express from the heart. remarkable post and will look forward to your future update.

7. Teodoro - December 7, 2012

Great site, I really love your writing. Thanks for sharing it with us

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s