How to convert from nrpe to icinga2

I’m in the process in converting older handmade done checks from nrpe to nagios2.
I need some advise how to convert the objects into icinga2 Syntax correctly.

This entry is in my nrpe.cfg

### CHECK ORACLE ###
command[check_oracle_nospaceerrcnt]=/usr/lib64/nagios/plugins/check_oracle_nospaceerrcnt.sh $ARG1$ $ARG2$

This comes from my hosts techlab1.cfg

define host {
        host_name                       techlab1
        alias                           techlab1
        address                         192.168.19.10
        check_command                   check_ping!10,2%!20,5%
        max_check_attempts              1
        contacts                        nagiosadmin
        contact_groups                  admins
        icon_image                      linux.gif
        register                        1
}

From my services file check_oracle_nospaceerrcnt.cfg:

define service {
        #NAGIOSQL_CONFIG_NAME           check_oracle_nospaceerrcnt
        host_name                       techlab1
        service_description             check_oracle_nospaceerrcnt
        display_name                    check_oracle_nospaceerrcnt
        check_command                   check_oracle_nospaceerrcnt!tl1!techlab.techlab.local
        max_check_attempts              1
        register                        1
}

entry form my commands.cfg:

define command {
        command_name                    check_oracle_nospaceerrcnt
        command_line                    $USER1$/check_nrpe -H $HOSTADDRESS$ -2 -c check_oracle_nospaceerrcnt -a $ARG1$ $ARG2$
        register                        1
}

The check should be used on the icinga2 agent.
So I neeed the conversion from nrpe to icinga2 agent setup.
I’ve already setup master and agent and don’t know how to proceed in converting
the icnga1 syntax to icinga2

Maybe this is the right syntax for the check command.

object CheckCommand "check_oracle_nospaceerrcnt" {
   import "plugin-check-command"
   command = [ PluginDir + "/check_oracle_nospaceerrcnt.sh" ]
}

But how do I use the ```
$ARG1$ $ARG2$

Maybe this should work:

object CheckCommand "check_oracle_nospaceerrcnt" {
   import "plugin-check-command"
   command = [ PluginDir + "/check_oracle_nospaceerrcnt.sh" '$ARG1$' -d '$ARG2$' ]
}

Please try:

object CheckCommand "oracle-nospaceerrcnt" {
   command = [ PluginDir + "/check_oracle_nospaceerrcnt.sh" ]

   arguments = {
      "1" = {
              value = "$arg1$"
              skip_key = true
              order = 1
           }
      "2" = {
              value = "$arg2$"
              skip_key = true
              order = 2
           }
   }
}

Instead of using generic variable names like arg1 I’d use more self explaining names e.g. oracle_nospace_warn or oracle_nospace_tablespace.

1 Like

Manny Thanks Roland, I defined my written plugin in the Director as follow:

object CheckCommand "check_oracle_nospaceerrcnt.sh" {
    import "plugin-check-command"
    command = [ PluginDir + "/check_oracle_nospaceerrcnt.sh" ]
    arguments += {
        "1" = {
            description = "Argument1"
            order = 1
            required = true
            skip_key = true
            value = "$arg1$"
        }
        "2" = {
            description = "Argument2"
            order = 2
            required = true
            skip_key = true
            value = "$arg2$"
        }
    }
}

It just works, I’m happy, thanks!