icinga2: How to install icinga2 plugins in Linux?

Posted by

Installing Icinga2 plugins on a Linux system enables you to extend the monitoring capabilities of Icinga2 by adding checks for various services and metrics. Here's how you can install Icinga2 plugins step-by-step:

Step 1: Install Icinga2
Ensure that Icinga2 is already installed on your system. If not, you can install it using the commands mentioned in the previous answer for either Ubuntu/Debian or CentOS/RHEL systems.

Step 2: Install the Monitoring Plugins
Most Icinga2 installations use the Monitoring Plugins (formerly Nagios Plugins) package, which provides a standard set of checks. Install them as follows:

For Ubuntu/Debian:
sudo apt update
sudo apt install monitoring-plugins

For CentOS/RHEL:
sudo yum install epel-release
sudo yum install nagios-plugins-all

Step 3: Install Additional Plugins
You might need more specific plugins than those provided by the default Monitoring Plugins package. You can find additional plugins at the Icinga Exchange or other repositories like GitHub.

To install a plugin from a source other than the package manager:

Download the plugin script (usually a .sh or .pl file).
Make the script executable and place it in the plugins directory (typically /usr/lib/nagios/plugins or /usr/lib64/nagios/plugins depending on your architecture).

For example:
sudo wget -O /usr/lib/nagios/plugins/check_example.sh https://example.com/plugins/check_example.sh
sudo chmod +x /usr/lib/nagios/plugins/check_example.sh

Step 4: Test the Plugin
Before using the plugin with Icinga2, test it directly from the command line to ensure it works as expected:


/usr/lib/nagios/plugins/check_example.sh -option1 -option2
Replace check_example.sh with your plugin and adjust the options according to the plugin’s requirements.

Step 5: Configure Icinga2 to Use the Plugin
Create a new command definition in Icinga2 for the plugin. This involves editing the configuration files found in /etc/icinga2/conf.d or wherever you manage your Icinga2 configurations.

Here’s an example command definition for a custom plugin:

object CheckCommand "check-example" {
    import "plugin-check-command"
    command = [ PluginDir + "/check_example.sh" ]
    arguments = {
        "-option1" = "$arg1$"
        "-option2" = "$arg2$"
    }
}
Step 6: Add the Check to a Host or Service
Now, apply the new command to a host or service object. For example, to monitor a service using your new plugin:

apply Service "example-service" {
    import "generic-service"
    check_command = "check-example"
    vars.arg1 = "value1"
    vars.arg2 = "value2"
    assign where host.name == "YourHost"
}
Step 7: Reload Icinga2
After adding the new configuration, reload Icinga2 to apply changes:

sudo systemctl reload icinga2
Step 8: Verify the Configuration

Finally, verify that the new plugin is working correctly through the Icinga Web 2 interface or by checking the Icinga2 logs for any errors.

This completes the installation and configuration of new Icinga2 plugins on your Linux system.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x