0

I have a CheckCommand defined in Icinga2 that looks like this:

object CheckCommand "foo" {
    import "plugin-check-command"
    command = [ "/opt/my_plugins/check_foo" ]

    arguments = {
        "-a" = {
            value = "$foo_a$"
            description = "Parameter A"
        }
        "-b" = {
            value = "$foo_b$"
            description = "Parameter B"
        }

    vars.foo_a = "$a$"
    vars.foo_b = "$b$"
}

Either a, or b, or both are required by the command, but it cannot run if it doesn't get at least one of those parameters. I'd like to express this requirement in the Icinga2 command definition, is it possible?

Luke404
  • 10,282
  • 3
  • 25
  • 31

1 Answers1

0

Note: This is applicable for NRPE remote plugin execution

We also got same problem for custom plugins.

Normally Icinga will execute commands like this

'/usr/local/nagios/libexec/check_nrpe' '-p' '56666' '-H' '10.104.16.214' \
'-a' '80' '90' '-c' 'nrpe_check_network_interface' 

This will cause the problem, while parsing this parameters our plugin will receive like invalid arguments. Probably in bash or shell we use shift to go to next arguments that may cause issue.

Icinga2 provide some more option in Checkcommand like ordering.

object CheckCommand "foo" {
    import "plugin-check-command"
    command = [ "/opt/my_plugins/check_foo" ]

    arguments = {
// If you need you can give this also
        "-H" = {
           value="$host$"
           order=0
        }
        "-a" = {
            value = "$foo_a$"
            description = "Parameter A"
            order = 1
        }
        "-b" = {
            value = "$foo_b$"
            description = "Parameter B"
            order = 2
        }

//No need to give vars here since it will come from service trigger part as macro.
}

Not sure, Try this! this may help.

saravanakumar
  • 1,747
  • 4
  • 20
  • 38