This article will help you get the Apache plugin for sd-agent configured and returning metrics
Installing the apache plugin package
Install the apache plugin on Debian/Ubuntu:
sudo apt-get install sd-agent-apache
Install the apache plugin on RHEL/CentOS:
sudo yum install sd-agent-apache
Read more about agent plugins.
Configuring the agent to monitor Apache
1. Ensure the mod_status module is installed. This is usually compiled in by default but you may need to uncomment a line in your httpd.conf file:
#LoadModule status_module modules/mod_status.so
- Removing the # will uncomment the line and enable mod_status.
On packaged Ubuntu Apache installations you can enable the mod_status module by using the a2enmod command:
sudo a2enmod status
2. Adding the following line to your httpd.conf file will enable the mod_status output.
ExtendedStatus On
- If you restart Apache after adding this line and get an error, check that mod_status has been installed correctly. Look in your Apache error_log for details.
You then need to add in the following lines to set up the location from which the status output can be parsed by the agent:
<Location /server-status> SetHandler server-status Order Deny,Allow Deny from all Allow from localhost </Location>
This will allow the status output to be accessed from http://localhost/server-status (localhost only works on the server itself - replace localhost with your server IP and it will be accessible externally to the IPs you specify in the Allow list, see below).
- You will now need to restart your Apache web server to allow the changes to take effect.
3. Configure /etc/sd-agent/conf.d/apache.yaml
init_config: instances:
- apache_status_url: http://localhost/server-status?auto
- If you have password protected the status page, you should configure the username and password for the authorized user:
apache_user: serverdensity
apache_password: supersecretpassword
4. Restart the agent
sudo /etc/init.d/sd-agent restart
Error: server-status not found
If you get a 404 error or a different page loads when you access the server status, you may have some .htaccess rewrite rules that are preventing Apache from handling the request. You can use this rewrite conditional to ensure requests get processed correctly. This goes above the rewrite rule that is catching the request to server-status
RewriteCond %\{REQUEST_URI\} !=/server-status
Verifying the configuration
Execute info to verify the configuration with the following:
sudo /etc/init.d/sd-agent info
or
/usr/share/python/sd-agent/agent.py info
If the agent has been configured correctly you'll see an output such as:
apache ----- - instance #0 [OK] - Collected * metrics
You can also view the metrics returned with the following command:
sudo -u sd-agent /usr/share/python/sd-agent/agent.py check apache
Configuring graphs
Click the name of your server from the Devices list in your Server Density account then go to the Metrics tab. Click the + Graph button on the right then choose the apache metrics to display the graphs. The metrics will also be available to select when building dashboard graphs.
Monitored metrics
Metric | Values |
---|---|
apache.net.bytes |
/ Type: int |
apache.net.bytes_per_s |
/ Type: int |
apache.net.hits |
/ Type: int |
apache.net.request_per_s |
request / second Type: float |
apache.performance.busy_workers |
/ Type: int |
apache.performance.cpu_load |
/ Type: int |
apache.performance.idle_workers |
/ Type: int |
apache.performance.uptime |
/ Type: int |
Metrics Conversion
Please refer to the metrics conversion document to map old metrics names to the new metric names.
Hi Richard,
Thanks for pointing this out, we've gone ahead and updated the article so that only localhost is used.
There is an error on this page, at least for Ubuntu 14.04.
You need to use "127.0.0.1" in both the apache config and the SD config files. You cannot interchange this and "localhost" otherwise you will get a 403 error.