Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

icinga tutorials: How to monitor Apache2 using icinga agent

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-plugins

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"
    }
}

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.
Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x