Integrating custom plugins

Let's say we wrote a custom sample-plugin.sh check plugin that takes some arguments and gives check results.

First, we need to put the check plugin at a proper path in the filesystem. Place the check script inside the standard plugin installation directory. RedHat/CentOS distributions install the plugins inside /usr/lib64/nagios/plugins or /usr/lib/nagios/plugins, depending on the architecture of the server; this may differ for other distributions. Place the check script in one of these directories and make sure it is executables the operating system user that Icinga is running as.

Check if we can run the script from the command line as an icinga user:

$ su icinga -c '/usr/lib64/nagios/plugins/sample-plugin.sh 192.168.1.212'
Sample check OK

We use the following command with the path in the Icinga command object definition; let's call it check_sample:

define command {
    command_name    check_sample
    command_line    /usr/lib64/nagios/plugins/sample-plugin.sh $HOSTADDRESS$ $ARG1$ $ARG2$
}

Now we can use the following command object in service definitions using the check_command directive:

define service {
    ...
    check_command    check_sample!argument1!argument2
    ...
}

As mentioned earlier, arguments to be passed to the check script are separated by an exclamation (!) sign in the check_command directive in a service definition. The preceding service check will expand the command line into the following (assuming the service check is on a host with the address 192.168.1.212):

/usr/lib64/nagios/plugins/sample-plugin.sh 192.168.1.212 argument1 argument2

The $ARGn$ macros are defined by corresponding arguments (separated by !) passed to the check_command directive.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.118.90