Command validation error with arguments

Hello,

I’ve got a problem deploying a command with arguments using the Director.

The command I am trying to deploy looks like this:

object CheckCommand "printerbox_snmp" {
import "plugin-check-command"
command = PluginDir + "/check_snmp"
timeout = 30s
arguments += {
    "-H" = {
        description = "Host to connect to"
        order = 1
        value = "$snmp_host$"
    }
    "-o" = {
        description = "OID to request"
        order = 2
        value = "$snmp_oid$"
    }
}
}

When I’m deploying this configuration it tells me that the Validationcheck failed because:

Attribute ‘command’ must be an array if the ‘arguments’ attribute is set.

The whole message looks like this:

[2021-04-28 08:12:06 +0200] information/cli: Icinga application loader (version: r2.12.3-1)
[2021-04-28 08:12:06 +0200] information/cli: Loading configuration file(s).
[2021-04-28 08:12:06 +0200] information/ConfigItem: Committing config item(s).
[2021-04-28 08:12:06 +0200] information/ApiListener: My API identity: ***mon***
[2021-04-28 08:12:06 +0200] critical/config: Error: Validation failed for object 'printerbox' of type 'CheckCommand'; Attribute 'command': Attribute 'command' must be an array if the 'arguments' attribute is set.
Location: in [stage]/zones.d/director-global/commands.conf: 1878:5-1878:39
[stage]/zones.d/director-global/commands.conf(1876): object CheckCommand "printerbox" {
[stage]/zones.d/director-global/commands.conf(1877):     import "plugin-check-command"
[stage]/zones.d/director-global/commands.conf(1878):     command = PluginDir + "/check_snmp"
                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[stage]/zones.d/director-global/commands.conf(1879):     timeout = 30s
[stage]/zones.d/director-global/commands.conf(1880):     arguments += {

[2021-04-28 08:12:06 +0200] critical/config: 1 error
[2021-04-28 08:12:06 +0200] critical/cli: Config validation failed. Re-run with 'icinga2 daemon -C' after fixing the config.

If I delete those arguments it deploys the command flawlessly.

So please help me, what’s wrong with tis definition?

  • Director version (System - About): 1.8.0
  • Icinga Web 2 version and modules (System - About): 2.8.2
  • Icinga 2 version (icinga2 --version): r2.12.3-1
  • Operating System and version: Debian 10.8
  • Webserver, PHP versions: Apache/7.2

Regards,
Heiko

Hi & welcome to the icinga community,

you would need to replace

command = PluginDir + “/check_snmp”

with

command = [ PluginDir + “/check_snmp” ]

However, since snmp is already part of the ITL you don’t need to define it on your own.

Hi, Roland.

Thanks, that’s it.

I think about how it broke. I remember configuring this command normally in the director. When I look into the activity log of the director I can see that the command lack the square brackets from the beginning. In the director create command there are no square brackets around the command value.

I didn’t even manage to get them back into the configuration, using the director form. So I ended up into recreating the command from scratch and that contained those square brackets again.

Tanks.

I got it:

Accidentally I reproduced this behaviour: In the command definition I just set:
“Render as String:” to Yes.

Then those Brackets dissapear. If you set it back to “No” they are back again.

Is this an Director Issue?

I’m sorry, I don’t know as we don’t use the director for service definitions.