Apache server-status Monitoring

This "server-status" Apache module based tool is very basic and visually dull, but it is simple to set up and probably has very low overhead. Will Shott's sysinfo page is a nicer looking all round system tool - if you colourise it - that uses only linux commands to work, so is a good beginner's exercise in script and html programming and to learn some of the system tools. 

Unfortunately it is only a system snapshot, so requires the shell script to run periodically to update the webpage. I set a cronjob every hour just for the exercise. The original Post was 2 years ago, with some additions yesterday. 

sysinfdellmint.png

Info for server-status is found at:

https://httpd.apache.org/docs/2.4/mod/mod_status.html

Enabling Status Support

To enable status reports only for browsers from the example.com domain add this code to your httpd.conf configuration file

<Location "/server-status">

SetHandler server-status

Require host example.com

</Location>

You can now access server statistics by using a Web browser to access the page http://your.server.name/server-status

Automatic Updates

You can get the status page to update itself automatically if you have a browser that supports "refresh". Access the page http://your.server.name/server-status?refresh=N to refresh the page every N seconds.

Checking the current server status shows unset:

statusoff.png

You can find the files contained in the above text via:

grep -R "SetHandler server-status" /etc/apache2/*

/etc/apache2/mods-available/status.conf: SetHandler server-status

/etc/apache2/mods-enabled/status.conf: SetHandler server-status

Open the first listed above:

sudo vi /etc/apache2/mods-available/status.conf

Change and uncomment below to something to suit your network e.g. from:

<Location /server-status>

SetHandler server-status

Require local

#Require ip 192.0.2.0/24

</Location>

in my network's subnet case, to:

Require ip 192.168.1.0/24

Restart apache:

sudo service apache2 restart

* Restarting web server apache2 [ OK ]

Refresh your server page with F5:

statoff.png

This is only a static page though, so needs to be refreshed every say, 1 second by appending  “?refresh=1” to the menu bar. Now you should see changes e.g:

Server uptime: 4 minutes 31 seconds

Server uptime: 4 minutes 32 seconds

etc.

At the page bottom you can see:

To obtain a full report with current status information you need to use the ExtendedStatus On directive.

The ExtendedStatus module shows extra CPU, PID info. It is set on by editing the same files found via:

grep -iR "extendedstatus" /etc/apache2/*

# Keep track of extended status information for each request

ExtendedStatus On

restart Apache and F5 the browser again. The PID key list is now replaced by a list of users connected to allocated SRV sessions:

users.png

 

Comments are closed.

Post Navigation