To monitor Apache2 on an Ubuntu server where Icinga agent is installed, while Icinga server is installed on another Ubuntu server, you can follow these step-by-step instructions. This guide assumes that Icinga 2 and Icinga Web 2 are properly installed and configured on your Icinga server, and the Icinga agent is installed and connected to your Icinga server.
Step 1: Install Necessary Plugins
On the Icinga Agent Server: Ensure you have the nagios-plugins package installed, as it includes the check for Apache. Install it using:
$ sudo apt-get update
$ sudo apt-get install nagios-pluginsCode language: JavaScript (javascript)
Step 2: Configure Icinga Agent
Check the Apache Status Module: Make sure that the Apache status module is enabled on the Apache server. You can enable it with:
$ sudo a2enmod status
$ sudo systemctl restart apache2
Ensure the /etc/apache2/mods-enabled/status.conf is configured to allow access from the Icinga server IP. It might look something like this:
<Location /server-status>
SetHandler server-status
Require local
Require ip 192.168.x.x # IP of your Icinga server
</Location>
Configure the Agent: On the Icinga agent, ensure it can execute the Apache check. You might need to create a command in Icinga if it doesn’t exist:
object CheckCommand "check_apache_status" {
import "plugin-check-command"
command = [ PluginDir + "/check_http" ]
arguments = {
"-H" = "$address$"
"-u" = "/server-status?auto"
}
}Code language: PHP (php)
Step 3: Configure Icinga Server
Define the Host Object: If you haven't already defined the host object for the Apache server in your Icinga configuration, add it:
object Host "apache-server" {
import "generic-host"
address = "apache-agent-ip"
check_command = "hostalive"
}
Define Service for Apache Monitoring: Create a service definition to check Apache status:
apply Service "apache-status" {
import "generic-service"
check_command = "apache_status"
vars.address = "$host.address$"
assign where host.name == "apache-server"
}
OR
apply Service "apache-status" {
import "generic-service"
check_command = "http"
vars.address = "$host.address$"
assign where host.name == "apache-server"
}
Reload Icinga 2: After making changes to the configuration files, reload the Icinga 2 service to apply the changes:
sudo systemctl reload icinga2
Step 4: Verify the Configuration
Icinga Web 2: Log into Icinga Web 2 and navigate to the 'Services' section. You should see your new service for monitoring Apache. Verify that it is checking the status as expected.
Troubleshooting: If there are issues, check the Icinga 2 logs for any errors related to the Apache checks. The logs are usually located in /var/log/icinga2/icinga2.log.Code language: JavaScript (javascript)
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals