Last Updated on December 31, 2022 by Thiago Crepaldi
From previous posts, we have deployed Zabbix Server on a Proxmox container. We also hardened the installation through Let’s Encrypt certificates for the web frontend and TLS encryption for the communication between Server and Agents/Proxies, after all, although encrypted Zabbix Server <-> Agent/Proxy communication with PSK or SSL certificates 🙂
In this post I will cover how to monitor a Apache2 Web Server using Zabbix Agent 2 template. Templates are great because they already pack a bunch of monitoring items, actions, triggers, etc that we would have to add one by one otherwise. Using template is smart because when we need to make changes, we just do it in the template and all hosts that use them will see the new settings. On a manual setup, you would have to make the change in each host, one by one…
This post assumes you already installed and configured your Zabbix Agent, but if you didn’t, refer to How to install and configure Zabbix agent and resume from here when you are done.
Checking Apache2 configuration
You can find more information on Zabbix Apache integration page, but the steps below are a working summary for Apache2.
The first step is checking the availability of the module with this command line:
# apache2ctl -M 2>/dev/null | grep status_module
status_module (shared)
Some systems may have httpd process instead of apache2/apache2ctl. If you get status_module (shared) as the output, status_module is available.
If status module is loaded, skip to the next section. Otherwise, create a status.conf file with the following content:
# vim /etc/apache2/mods-available/status.conf
<IfModule mod_status.c>
# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Uncomment and change the "192.0.2.0/24" to allow access from other hosts.
<Location /server-status>
SetHandler server-status
Require local
</Location>
# Keep track of extended status information for each request
ExtendedStatus On
# Determine if mod_status displays the first 63 characters of a request or
# the last 63, assuming the request itself is greater than 63 chars.
# Default: Off
#SeeRequestTail On
<IfModule mod_proxy.c>
# Show Proxy LoadBalancer status in mod_status
ProxyStatus On
</IfModule>
</IfModule>
And load the status module:
# a2enmod status
At this point, you should be able to see the status module loaded on your system.
Configuring Zabbix Server through Web UI
Go to Configuration >> Hosts and select your agent with Apache2 running. When the configuration dialog open, the Host tab should be the default one. Look for the Templates section. In the text box, type “Apache” and select the “Apache by Zabbix agent” in the search result. This will link the template to your agent.
The last step is setting your web server settings in the plugin so that it can fetch its metadata.Click on Macros tab. If you have a default Apache installation, you are good to go. But you may have to add from one to 6 macros. Click on Add and fill in the new row as follow:
- Macro: {$APACHE.PROCESS_NAME}
- Value: apache2
- Description: A helpful description or leave it empty
Complete the configuration by clicking Update. If everything went well, after a couple seconds, depending on your configuration, data should start flowing into Zabbix Server. Otherwise, refer to Zabbix Apache integration page to check on the other macros to set
Go to Monitoring >> Latest data. In the filter section, type the name of your database server in the Hosts box and Apache in the Name box and finally hit Apply. A list of items should be displayed for it.
That is it, have fun!