• Get In Touch
October 9, 2016

Monitor Apache Server Load and Page Statistics Using Mod_Status

Need Hosting? Try ours, it's fast, reliable and feature loaded with support you can depend on.
View Plans

Apache is the most popular and widely used web server in the world, so it is important to monitor and debug the performance. Mod_status is an Apache module that is used to monitor Apache web server load and current connections via a web based interface. Mod_status allows a system administrator to monitor performance of Apache server. Mod_status is the most useful and easiest module to confgure with Apache.

The Mod_status module shows the following information:

  • Server load and uptime.
  • CPU usage and total traffic of Web Server.
  • Total number of incoming connections.
  • Total number of bytes and counts server.
  • Total number of idle and busy workers.

In this tutorial, we will learn how to install and use Mod_status on the Apache web server running on Ubuntu-14.04.

Requirements

  • A server running Ubuntu-14.04 with Apache installed.
  • A non-root user with sudo privileges setup on your server.

Enable mod_status in Apache

By default Apache comes with mode_status enabled. You can check the contents of apache’s enabled modules directory by running the following command:

ls /etc/apache2/mods-enabled

You should see the mod_status module in the following output:

    access_compat.load  authn_file.load  autoindex.load  env.load          mpm_prefork.load  rewrite.load        spdy.load    wsgi.conf
    alias.conf          authz_core.load  deflate.conf    filter.load       negotiation.conf  setenvif.conf       ssl.conf     wsgi.load
    alias.load          authz_host.load  deflate.load    mime.conf         negotiation.load  setenvif.load       ssl.load
    auth_basic.load     authz_user.load  dir.conf        mime.load         php5.conf         socache_shmcb.load  status.conf
    authn_core.load     autoindex.conf   dir.load        mpm_prefork.conf  php5.load         spdy.conf           status.load

If mod_status module not enabled, then you can easily enable it by running the following command:

sudo a2enmod status

Configure Mod_status Module

In order to enable the access of mod status page, you will need to configure mod_status default configuration file located at /etc/apache2/mods-enabled/ directory.

Open the status.conf file using your favorite editor:

sudo nano /etc/apache2/mods-enabled/status.conf

Find the section Location /server-status, it should look like following.


SetHandler server-status Require host example.com

Now, change all lines as shown below. where remote-ip-address is the IP address of the remote computer you will be using to access your web server:


SetHandler server-status Require local Require ip remote-ip-address

Once you are finished, save and close the file.

The above configuration is valid only for your default apache site, if you have created virtual hosts, then will need to configure the above settings for each virtual host.

You can do this by editing 000-default.conf file:

sudo nano /etc/apache2/sites-enabled/000-default.conf

Add the following lines under the section VirtualHost *:80:


SetHandler server-status Require local Require ip remote-ip-address

Now, save the file and restart apache service.

sudo /etc/init.d/apache2 restart

Test Mod_status

Once you have finished, it’s time to test the mod_status module.

From your remote computer, open your web browser and access the Apache status page using the URL http://your-server-ip/server-status. You should see the following page:

HP_NO_IMG/data/uploads/users/7ecb43a5-b365-4ebf-93d5-f3b632f29f33/2064803149.png” alt=”” />

In the above image, you can see that html interface shows you all the information about server load, uptime and process id. You can also refresh the page every 10 seconds by adding ?refresh=10 at the end of the URL.

If you want to view the status of Apache using command line browser called lynx.
You can install it by running the following command:

sudo apt-get install lynx

Once installation is complete, you can get the Apache status using the following command:

lynx http://server-ip-address/server-status

You should see the following output:

“` language-bash
Apache Server Status for 192.168.43.206 (via 192.168.43.206)

   Server Version: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.19 OpenSSL/1.0.2h mod_wsgi/3.4 Python/2.7.6
   Server MPM: prefork
   Server Built: Jul 15 2016 15:34:04
     _______________________________________________________________________________________________________________________________________

   Current Time: Monday, 03-Oct-2016 23:36:16 IST
   Restart Time: Monday, 03-Oct-2016 23:23:16 IST
   Parent Server Config. Generation: 1
   Parent Server MPM Generation: 0
   Server uptime: 12 minutes 59 seconds
   Server load: 0.00 0.02 0.05
   Total accesses: 7 - Total Traffic: 14 kB
   CPU Usage: u.04 s.05 cu0 cs0 - .0116% CPU load
   .00899 requests/sec - 18 B/second - 2048 B/request
   1 requests currently being processed, 5 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 2754 0/1/1 _ 0.02 359 3   0.0  0.00  0.00 192.168.43.4 127.0.1.1:80 GET /server-status HTTP/1.1
   1-0 2755 0/3/3 _ 0.02 737 0   0.0  0.00  0.00 192.168.43.4 127.0.1.1:80 NULL

   2-0 2756 0/1/1 _ 0.02 423 2   0.0  0.00  0.00 192.168.43.4 127.0.1.1:80 NULL
   3-0 2757 0/1/1 _ 0.02 234 4   0.0  0.00  0.00 192.168.43.4 127.0.1.1:80 NULL
   4-0 2766 0/1/1 _ 0.01 485 3   0.0  0.00  0.00 192.168.43.4 127.0.1.1:80 NULL
   5-0 2773 0/0/0 W 0.00 0   0   0.0  0.00  0.00 192.168.43.4 127.0.1.1:80 GET /server-status HTTP/1.0
     _______________________________________________________________________________________________________________________________________

    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
     _______________________________________________________________________________________________________________________________________

   SSL/TLS Session Cache Status:
   cache type: SHMCB, shared memory: 512000 bytes, current entries: 0
   subcaches: 32, indexes per subcache: 88
   index usage: 0%, cache usage: 0%
   total entries stored since starting: 0
   total entries replaced since starting: 0
   total entries expired since starting: 0
   total (pre-expiry) entries scrolled out of the cache: 0
   total retrieves since starting: 0 hit, 0 miss
   total removes since starting: 0 hit, 0 miss
Need Hosting? Try ours, it's fast, reliable and feature loaded with support you can depend on.
View Plans

Share this Article!

Related Posts

Node.js Authentication – A Complete Guide with Passport and JWT

Node.js Authentication – A Complete Guide with Passport and JWT

Truth be told, it’s difficult for a web application that doesn’t have some kind of identification, even if you don’t see it as a security measure in and of itself. The Internet is a kind of lawless land, and even on free services like Google’s, authentication ensures that abuses will be avoided or at least […]

Node.js and MongoDB: How to Connect MongoDB With Node

Node.js and MongoDB: How to Connect MongoDB With Node

MongoDB is a document-oriented NoSQL database, which was born in 2007 in California as a service to be used within a larger project, but which soon became an independent and open-source product. It stores documents in JSON, a format based on JavaScript and simpler than XML, but still with good expressiveness. It is the dominant […]

Using MySQL with Node.js: A Complete Tutorial

Using MySQL with Node.js: A Complete Tutorial

Although data persistence is almost always a fundamental element of applications, Node.js has no native integration with databases. Everything is delegated to third-party libraries to be included manually, in addition to the standard APIs. Although MongoDB and other non-relational databases are the most common choice with Node because if you need to scale an application, […]

Node.Js Vs Django: Which Is the Best for Your Project

Node.Js Vs Django: Which Is the Best for Your Project

Django and NodeJs are two powerful technologies for web development, both have great functionality, versatile applications, and a great user interface. Both are open source and can be used for free. But which one fits your project best? NodeJs is based on JavaScript, while Django is written in Python. These are two equally popular technologies […]

Nodejs Vs PHP:  Which Works Best?

Nodejs Vs PHP: Which Works Best?

Before getting into the “battle” between Node.js and PHP we need to understand why the issue is still ongoing. It all started with the increased demand for smartphone applications, their success forcing developers to adapt to new back-end technologies that could handle a multitude of simultaneous requests. JavaScript has always been identified as a client-side […]