Icinga2 - Command - Arguments

Dear Community,

i have a short question, i migrate actualy our Icinga 1.8. to Icinga2.

I have this command:

object CheckCommand  "check_nrpe_proc" {

            command = [DAKPlugins + "/check_nrpe"]
            arguments = {
            "-u" = {}
            "-H" = "$address$"
            "-t" = "60"
            "-c" = "check_linux"
            "-a"  ="-T -p$service.vars.ARG1$ -w$service.vars.ARG2$ -c$service.vars.ARG3$"
          }

        }

I really don’t know how i can migrate the -a with all the arguments.

Maybe someone has an idea

Thank y

Fischeertrinken

Hi, welcome back. :slight_smile:

You shouldn’t reinvent the wheel with building your own check_nrpe_proc CheckCommand.

In the first place, you should get rid of NRPE all together and start using the Icinga agent. It’s much more powerful, secure and flexible.

If for whatever reason you have to stay with NRPE, there’s an nrpe command in the ITL which is all you need.

https://icinga.com/docs/icinga2/latest/doc/10-icinga-template-library/#nrpe

Please use this and all is just built how you would need it. Only build your own CheckPlugins for completely new plugins which are not part of the ITL. This way you make good use of the power of Icinga 2, have CheckCommands which are curated and maintained and save yourself (and us) a lot of headache with debugging. :slight_smile:

Hey Thomas, thank y for your fast answer.

I already saw that you got the Plugins for NRPE. But i really don’t know how to use them or activate it, cause the documentation about your nrpe plugin, i do not get it.

Maybe you can give me little hide, to activate or use the nrpe check_command.

thank y

Hello,

NRPE command usage is like every command, you only need to know that you have to put the arguments in an array like

vars.nrpe_aguments = [  "warn" , "crit" , "path" ]

And so on, even it is only 1 argument. it wil be then
ARG1 = “warn”
ARG2 = “crit”
ARG3 = “path”

Regards,
Carsten

1 Like

Just as @anon66228339 said.

And the rest works just like with your own command. Just use nrpe as command in your service definition and set the vars.

Refer to the documentation for the variables to set:

https://icinga.com/docs/icinga2/latest/doc/10-icinga-template-library/#nrpe

e.g. Just set

vars.nrpe_command = "check_linux"

in your Service definition.

This will call the check_nrpe plugin with the right commandline argument. Keep in mind that CheckCommand definitions usually contain all possible commandline arguments but only those where the corresponding custom variable is set are actually used when calling the plugin.

object Service "Apache2" {
    host_name = "SER-TEST-VM-1"
    check_period = "24x7"
    check_command = "check_nrpe_proc"
    vars.nrpe_address = "$address$"
    vars.nrpe_command = "check_linux"
    vars.nrpe_timeout = "60"
    vars.nrpe_arguments = ["-T","-p", "/var/run/apache2.pid"]
    vars.notification["mail"] = { groups =[ "DAK-unix-admins"]}
    vars.notification_period ="24x7"
}

Hey,
i use now the NRPE Check command. But i’m still not sure about, how i have to set the nrpe_arguments.

Cause in this case i got the Error: Incorrect command line arguments supplied

Maybe some of you can help me :slight_smile:

Thank y!

Just solved my self.
vars.nrpe_arguments = "-T -p /var/run/apache2.pid"

But thank y!