Linux | Cloud | DevOps | Scripting

Breaking

Tuesday 7 June 2016

Monitor Apache Web Server load using mod_status

mod_status: Provides information of server activity and performance. Apache’s mod_status shows current information of web server. mod_status is used to get a current view of Apache key parameters and a snapshot of all its request handlers.

Before starting to monitor an apache web server, we must have a web server. For this, you must visit:

I have following Testing Environment:
  1. Operating System: RedHat 6.0
  2. IP Address: 192.168.10.139
  3. Hostname: rhpanacia.example.com
  4. Site: http://www.site1.example.com
  5. DocumentRoot: /var/www/rhpanacia
Step1: Enable mod_status in your webserver:
# vi /etc/httpd/conf/httpd.conf
<<Uncomment line no. 178>>
LoadModule status_module modules/mod_status.so

Step2: Configure mod_status:
<<Uncomment Lines for Location directive from line no 921-926>>

<Location /server-status>
            SetHandler server-status
            Order deny,allow
            Deny from all
            Allow from .example.com
</Location>

This is the default configuration for default Apache web site, having only one site. If you are using multiple sites then you must define these directive in your VirtualHost directive. Like:

<VirtualHost *:80>
            ServerAdmin root@rhpanacia.example.com
            DocumentRoot /var/www/rhpanacia
            ServerName site1.example.com
            ErrorLog /var/log/rhpanacia/rhpanacia.example.com-error_log
            CustomLog /var/log/rhpanacia/rhpanacia.example.com-access_log common
<Location /server-status>SetHandler server-status
            Order allow,deny
            Deny from all
            Allow from *.example.com
</Location>
</VirtualHost>

Step3: To get the information like, CPU usage, request per second, total traffic, etc., just enable ExtendedStatus. 
<<To enable it just jump to line no 228 and uncomment it:>>

ExtendedStatus On

Step4: Restart apache service
# service httpd restart
# chkconfig httpd on

Step5: Now, open browser and access link:
http://192.168.10.138/server-status
OR
http://site1.example.com/server-status

As result, we will get output like:


Step6: There is no need to refresh manually this page time by time. We can set time to get this page refresh. To set the automate refresh, we can add '?refresh=N' in the end of the URL. Like:

http://site1.example.com/server-status/?refresh=5





No comments:

Post a Comment

Pages