The Apache HTTP Server, also known as Apache HTTPd, is a commonly used web server software. Its wide usage has been due to its easy customizable feature and being open source.
If you have been using Apache, it is critical to monitor its performance to be aware of degradation issues and bottlenecks. Use our plugin and see real time performance trends and historical metrics, all in a single dashboard. This document details:
Performance Monitoring Metrics
Requests per Second
req_per_sec
records the total number of HTTP requests the web server is processing per second.
Busy Workers
Use the metric busy_workers
to get the total number of processes actively processing an HTTP request
Idle Workers
idle_workers
is the total number of idle workers/idle processes waiting for an HTTP request. If you have very few or no idle processes, it means your server is using up all the processes and new requests have to be on hold until the older requests are completed.
Uptime
The metric uptime
gets the total amount of time the server has been up and running.
Bytes per Second
bytes_per_sec
records the total amount of data the web server is transferring per second.
CPU Load
Use the metric cpu_load
and get the total percentage of CPU used by the web server.
Bytes per Request
The average number of bytes being transferred per HTTP request is obtained using the metric bytes_per_req
.
Total Accesses
The total number of accesses on the server is monitored using the metric total_accessess
.
Prerequisites
- This is a Python-based plugin supported from Python versions 2.7 and above. For version 2.7, we use
urllib2
module and for version 3.0 and above, we useurllib
module for monitoring the web server.
Apache Configuration
Please follow the below steps to configure your web server to monitor its performance. Regardless of the system you’re using, make sure to save a backup of the configuration file before making changes to it; in case you need to revert to an earlier version.
- Edit the status module's configuration file: /etc/apache2/mods-enabled/status.load
- Find the below line and make sure it is uncommented LoadModule status_module /usr/lib/apache2/modules/mod_status.so
- Edit the status module configuration file: /etc/apache2/mods-enabled/status.conf
- The below line allows access to the Status page from localhost using the URI /server-status <Location /server-status>
SetHandler server-status
Require local
</Location> - To restrict access to authenticated users and to specific IP addresses: SetHandler server-statusAuthUserFile /passwordlocationAuthType BasicAuthNameRequire user
- Make sure the ExtendedStatus is enabled to track additional data about the currently executing requests per worker. ExtendedStatus On
- Restart the server
- Edit the ports configuration file: For Ubuntu/Debian: Edit /etc/apache2/ports.confFor Centos/Redhat: Edit /etc/httpd/conf/httpd.conf
- Check for the line
Listen 80
. Change port from 80 to the desired port. - To make the server accept connections on the port for only specific interfaces, change
Listen 90
toListen domain.com:90
- Save the file and restart the server
- Enable SSL support on Apache default virtual host file, found in the following location: For Ubuntu/Debian: sudo vi /etc/apache2/sites-enable/000-default.confFor Centos/Redhat: sudo vi /etc/httpd/conf.d/ssl.conf
- Edit the virtual host file to support SSL in port 443 For Ubuntu/Debian:
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile <File Name>
SSLCertificateKeyFile <Key>
</VirtualHost>
For Centos/Redhat:
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# SSLProtocol all -SSLv2
# SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA
SSLCertificateFile <File Name>
SSLCertificateKeyFile <Key>
</VirtualHost> - Run the below commands to enable SSL mode For Ubuntu/Debian: sudo a2enmod sslFor Centos/Redhat: sudo yum install mod_ssl
- Restart the server
Plugin Installation
- Configure Apache as mentioned above to monitor its performance attributes.
- Download and install the latest version of the Site24x7 Linux agent in the server where you plan to run the plugin. If it is installed successfully, you will see a Linux server monitor in the Site24x7 Control Panel. This confirms that the agent is able to communicate with our data center.
- Download the "apache.py" file from our GitHub repository wget https://raw.githubusercontent.com/site24x7/plugins/master/apache/apache.py
- Update the file with your Status URL for monitoring apache. By default, we have enabled it to be:
http://localhost:80/server-status?auto
- Create a folder with the name "apache", under the Site24x7 Linux agent plugin directory '/opt/site24x7/monagent/plugins/' and place the 'apache.py' under '/opt/site24x7/monagent/plugins/apache/'
The agent will automatically execute the plugin within five minutes and send performance data to the Site24x7 data center.
Manually execute the plugin script using the following command and verify its output:
python apache.py
View Data in the Site24x7 Web Client
- Log in and go to Server > Plugins > click on the name of the plugin monitor.
- You will be able to view the performance charts on the various metrics for your server.
Error Handling
S.No | Error Message | Reason |
---|---|---|
1 | Error_code : URL Error [Errno -2] Name or service not known | Invalid hostname |
2 | Error_code : URL Error [Errno 1] _ssl.c:510: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol | If the Apache Status URL is not HTTPS configured |
3 | Error_code : HTTP Error 404 | Invalid Status URL |
4 | Error_code : HTTP Error 400 | Invalid Port number |
Plugin Contribution
Feel free to contribute to our existing plugin and come up with suggestions or feedback on our Community.
Related Articles
- Out-of-the-box plugins - Monitor your entire app stack with our extensive list of integrations
- Server Monitoring - Stay on top of server outages and performance issues
- Redis - Monitor performance metrics of your Redis databases
- MySQL - Monitor performance metrics of your MySQL databases
- Zombie Process - Analyze performance of your Zombie process server
- Nagios - Execute thousands of Nagios plugins in Site24x7 without the need of running a Nagios server
- Custom Script Monitoring - Create custom Linux and Windows plugins and monitor attributes that you need
- GitHub Repository - Check out our 50+ plugin integrations