Monitor Apache web server Activity & Performance through mod_status module

Apache Mod_Status module allows a server administrator to Monitor Apache web server Activity & Performance. This will clearly shows web server details such as Server Version, Serve Build date & time, Server Uptime, total accesses in number (How many request served this duration), total traffic (Bandwidth usage), CPU usage for web server activity, how many request per sec, how many requests currently being processed & idle workers. Also a HTML page is presented that gives the current server statistics in an easily human readable form. If required this page can be made to automatically refresh.

If you have installed any control panel like cPanel, Plesk, etc.., there will be a option to check the apache server Activity & Performance through GUI.

Apache mod_status Module info:

  • How many worker request is currently processing and how many worker process is idle.
  • 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
  • Web server restarted time, current time and how login it has been running.
  • Server build date and time
  • Total traffic and CPU load
  • 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

By default mod_status module was installed in apaceh web server.If its not installed you should re-install the apache web server to enable the module before re-installing, take the backup of Apache directory.

1) Install/Enable mod_status module

By default, mod_status module enabled on Aapche. The reports are commented and you can not access it. Just uncomment below code in your apache config file to enable it. If it’s not there you can add it. For Ubuntu, Mint & Debian Systems /etc/apache2/apache2.conf & CentOS, RHEL & Fedora Systems /etc/httpd/conf/httpd.conf file.

[For Apache 2.2]
<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from localhost
</Location>

[For Apache 2.4]
<Location "/server-status">
    SetHandler server-status
    Require host localhost
</Location>

Save and close the file, then restart apache web server

[For Ubuntu,Mint,Debian]
# service apache2 restart
# systemctl restart apache2.service

[For CentOS,RHEL,Fedora]
# service httpd restart
# systemctl restart httpd.service

2) Access mod_status module

Now, you can Monitor Apache web server Activity & Performance through mod_status module either terminal or web browser.
monitor-apache-web-server-activity-via-mod-status-module-1

# elinks http://localhost/server-status

Output :

                                              Apache Server Status for localhost (via 127.0.0.1)                                               
                                                                                                                                               
   Server Version: Apache/2.4.12 (Ubuntu)                                                                                                      
                                                                                                                                               
   Server MPM: prefork                                                                                                                         
                                                                                                                                               
   Server Built: Jul 24 2015 15:59:00                                                                                                          
                                                                                                                                               
   ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────   
                                                                                                                                               
   Current Time: Saturday, 05-Mar-2016 02:43:07 IST                                                                                            
                                                                                                                                               
   Restart Time: Saturday, 05-Mar-2016 02:41:14 IST                                                                                            
                                                                                                                                               
   Parent Server Config. Generation: 1                                                                                                         
                                                                                                                                               
   Parent Server MPM Generation: 0                                                                                                             
                                                                                                                                               
   Server uptime: 1 minute 53 seconds                                                                                                          
                                                                                                                                               
   Server load: 0.59 0.29 0.32                                                                                                                 
                                                                                                                                               
   Total accesses: 2 - Total Traffic: 22 kB                                                                                                    
                                                                                                                                               
   CPU Usage: u0 s0 cu0 cs0                                                                                                                    
                                                                                                                                               
   .0177 requests/sec - 199 B/second - 11.0 kB/request                                                                                         
                                                                                                                                               
   1 requests currently being processed, 4 idle workers                                                                                        
                                                                                                                                               
 __W__...........................................................                                                                              
 ................................................................                                                                              
 ......................                                                                                                                        
                                                                                                                                               
   Scoreboard Key:                                                                                                                             
   "_" Waiting for Connection, "S" Starting up, "R" Reading Request,                                                                           
   "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,                                                                                    
   "C" Closing connection, "L" Logging, "G" Gracefully finishing,                                                                              
   "I" Idle cleanup of worker, "." Open slot with no current process                                                                           

   Srv PID   Acc  M CPU  SS Req Conn Child Slot  Client      VHost               Request                                                       
   0-0 6124 0/1/1 _ 0.00 73 0   0.0  0.01  0.01 127.0.0.1 127.0.1.1:80 GET / HTTP/1.0                                                          
   1-0 6125 0/1/1 _ 0.00 13 0   0.0  0.01  0.01 127.0.0.1 127.0.1.1:80 GET / HTTP/1.0                                                          
   2-0 6126 0/0/0 W 0.00 0  0   0.0  0.00  0.00 127.0.0.1 127.0.1.1:80 GET /server-status HTTP/1.1                                             
                                                                                                                                               
   ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────   
                                                                                                                                               
    Srv  Child Server number - generation                                                                                                      
    PID  OS process ID                                                                                                                         
    Acc  Number of accesses this connection / this child / this slot                                                                           
     M   Mode of operation                                                                                                                     
    CPU  CPU usage, number of seconds                                                                                                          
    SS   Seconds since beginning of most recent request                                                                                        
    Req  Milliseconds required to process most recent request                                                                                  
   Conn  Kilobytes transferred this connection                                                                                                 
   Child Megabytes transferred this child                                                                                                      
   Slot  Total megabytes transferred this slot                                                                                                 
                                                                                                                                               
   ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────   
                                                                                                                                               
    Apache/2.4.12 (Ubuntu) Server at localhost Port 80
OK                                                                                             

3) mod_status module Automatic Updates

You can get the status page to update itself automatically, either terminal or web browser that supports “refresh”. Here the page refresh every 5 seconds, you can change the seconds based on your requirement.
monitor-apache-web-server-activity-via-mod-status-module-2a
For terminal

# elinks http://localhost/server-status?refresh=5

Enjoy..)

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...