How to Monitor Apache Performance Using mod_status in Ubuntu

[‘

n

While you can always have a peek at Apache log files to get information about your webserver such as active connections, you can get a very detailed overview of your web server’s performance by enabling the mod_status module.

n

What is the mod_status module?

n

The mod_status module is an Apache module that allows users to access highly detailed information about Apache’s performance on a plain HTML page. In fact, Apache maintains its own server status page for general public viewing.

n

You can view status for Apache (Ubuntu) by heading over to the address below:

n

n

Check Apache Performance Status
Check Apache Performance Status

n

The Apache mod_status makes it possible to serve a plain HTML page containing information such as:

n

    n

  • Server version
  • n

  • Current day and time in UTC
  • n

  • Server Uptime
  • n

  • Server load
  • n

  • Total traffic
  • n

  • Total number of incoming requests
  • n

  • The webserver’s CPU usage
  • n

  • PIDs with the respective clients and so much more.
  • n

n

Let’s now shift gears and see how you can get up-to-date statistics about Apache web server.

n

Testing Environment

n

Operating System: tUbuntu 20.04rnApplication:            Apache HTTP serverrnVersion:                2.4.41rnIP address:             34.123.9.111rnDocument root:          /var/www/htmlrn

n

Enable mod_status in Apache Ubuntu

n

By default, Apache ships with the mod_status module already enabled. You can verify this by checking the mods_enabled directory by running ls command as shown:

n

$ ls /etc/apache2/mods-enabledrn

n

Check mod_status Module in Apache Ubuntu
Check mod_status Module in Apache Ubuntu

n

Ensure that the status.conf and status.load files are present. If not, you need to enable mod_status module by invoking the command:

n

$ sudo /usr/sbin/a2enmod statusrn

n

Configure mod_status in Apache Ubuntu

n

As stated earlier, the mod_status is already enabled. However, additional tweaks are required for you to access the server-status page. To do so, you need to modify the status.conf file.

n

$ sudo vim /etc/apache2/mods-enabled/status.conf rn

n

Set the Require ip directive to reflect the IP address of the machine that you will be accessing the server from.

n

Configure mod_status Module in Apache Ubuntu
Configure mod_status Module in Apache Ubuntu

n

Save the changes and restart Apache for the changes to take effect to confirm the status as shown:

n

$ sudo systemctl restart apache2rn

n

Then verify the status of Apache and ensure it up and running.

n

$ sudo systemctl status apache2rn

n

Check Apache Status in Ubuntu
Check Apache Status in Ubuntu

n

Thereafter, browse the web server’s URL as shown.

n

http://server-ip/server-statusrn

n

You will get a status HTML page displaying a host of Apache’s information and an array of statistics as shown.

n

Monitor Apache Ubuntu Performance
Monitor Apache Ubuntu Performance

n

NOTE: To have the page refresh after every a given time interval, for example, 5 seconds, append the “?refresh=5” at the end of the URL.

n

http://server-ip/server-status?refresh=5rn

n

This provides a better monitoring capacity of your server’s performance than the plain static HTML page earlier on.

n

That’s all for now about the mod_status module. Stay Tuned to Tecmint for so much more.

n

‘]