Installing and Setting up a new Plugin

I am trying to incorporate a new check_jmx command I have pulled down from here: https://snippets.syabru.ch/nagios-jmx-plugin/download/nagios-jmx-plugin.zip it contains

  1. check_jmx
    • The Check command
  2. check_jmx.jar
    • Library
  3. jmx.cfg
    • Command config file?

My /etc/icinga2/constants.conf informs me that the PluginDir = “/usr/lib/nagios/plugins” so I have installed 1. & 2. from above in this directory. I also ran the command and received data from the server I queried so it’s working fine from the command line.

I could not find any documentation that informs me where to put the jmx.cfg file that has these contents:

# 'check_jmx' command definition
define command {
  command_name    check_jmx
  command_line    /usr/lib/nagios/plugins/check_jmx -U 
  service:jmx:rmi:///jndi/rmi://'$HOSTADDRESS$':'$ARG1$'/jmxrmi $ARG2$
}

But a bit of searching with find came up with this location /etc/nagios-plugins/config where I can see ssh.cfg, snmp.cfg and lots of others. So I have placed the jmx.cfg file here.

I have now restarted my icinga2 server and logged in to the web UI, navigated to Director and followed this advice


Icinga Director Integration

Navigate into Commands > External Commands and search for mysql_health . Select mysql_health and navigate into the Fields tab.


I searched for check_jmx but unfortunately the command is not found when searching in.

  • Commands
  • External Commands
  • Command Templates.

Back to the docs, I read this section

But it did not help, it’s not very clear to a none seasoned icinga user/admin what is to be done next. I checked this file.

  • /etc/icinga2/conf.d/commands.conf
    as suggested, but I could not understand why all the other check_commands were not listed there. How is check_ssh and the other check_* magically found in Director?

I hope someone can provide some clarity on what is to be done next so I can set this command as a service within Director.

Icinga is really great but the documentation is somewhat complex, its not really step by step but instead ‘click this link’ to find out more. I ended up with 10 open tabs and a very confused mind.

I would be more than happy to contribute a simple ‘How to integrate a new plugin, step by step’ document once I have solved this and can repeat it.

Thank you in advance for any assistance.

Hi,

you’re looking for this introduction: https://icinga.com/docs/icinga2/latest/doc/05-service-monitoring/

Cheers,
Michael

Thank you Michael, rather a terse response methinks :frowning: along the lines of RTFM.

I could not find any step by step instructions in the document you suggest. This link points not to an introduction, but rather, to a technical manual which I have been trying to make sense of in the context of the plugin I am trying to install. With 11 links to further information in the first paragraph it becomes overwhelming and difficult to read.

Cheers
Peter

Hi,

when I am sharing documentation links, they are meant helpful and not in any way of harsh RTFM or something like that. Sorry if that came out this way.

I rewrote that chapter a while ago, and I think it helps to get started with plugin integrations. Since you mentioned that you would want to contribute such, I thought I’d mention it to avoid you doing double work then.

Coming back to the original question, the command definition you’re showing is from Icinga 1.x and not compatible with Icinga 2.

IIRC the Icinga Template Library already provides a CheckCommand definition for the JMX check plugin, called jmx4perl. This is available inside the Director with fetching it from Icinga 2’s REST API as external command. With putting the plugin into the PluginDir directory, this should then work OOTB.

Cheers,
Michael

2 Likes

Good morning Michael,

thank you for your prompt reply,

I have been successful in finally deploying the check_jmx command and I am getting information back into icinga now. The jmx4perl sounds interesting especially as it is icinga 2 so I will be looking into it as well.

Cheers
Peter

Hello Peter, do you now know all the processes? Step by step ?
I am currently having similar problems integrating a “new” plugin into Director. I’m trying to integrate this plugin: GitHub - exensio/synology-nagios-plugin: A simple Nagios Plugins which helps to monitor a Synology NAS

I executed the following steps:

  1. Copied the plugin here /usr/lib/nagios/plugins
  2. The plugin was successfully tested via the command line
  3. How is it going on now? Navigate into Commands > Commands and create new object ?

Thank you!

Yes, you will need to create a new command in director that calls the plugin.

After that you will either create a service, service apply rule, or service template to use the command that you defined. If you create a service template, you will still need to create a service apply rule or service that uses that template.

Hello Ben,
many thanks for your message. I have create a new command in director that calls synology. After then i have create a service templates synology. But i get an error message and i can’t find the error.

Error Message:
execvpe(/usr/lib/nagios/plugins/check_snmp_synology) failed: No such file or directory

Command
zones.d/director-global/commands.conf
object CheckCommand “synology” {
import “plugin-check-command”
command = [ PluginDir + “/check_snmp_synology” ]
timeout = 2m
arguments += {
“-2” = {
description = “Community Name”
value = “$ARG1$”
}
“-C” = “$ARG3$”
“-c” = “$ARG5$”
“-f -W” = “$ARG2$”
“-v -h” = “$HOSTADDRESS$”
“-w” = “$ARG4$”
}
}

Service Templates
zones.d/director-global/service_templates.conf
template Service “synology” {
check_command = “synology”
max_check_attempts = “5”
check_interval = 1m
retry_interval = 30s
enable_notifications = true
enable_active_checks = true
enable_passive_checks = true
enable_event_handler = true
enable_perfdata = true
vars.ARG1 = “public”
vars.HOSTADDRESS = “192.168.10.9”
}

Thanks,
Eugene

You need to verify that the plugin itself is copied into /usr/lib/nagios/plugins and is named check_snmp_synology… You’ll also want to make sure permissions on the plugin are set to where the Icinga runtime user can see it (check other plugins in that directory to see the permissions they have listed and mimic those).