Set a command argument if host-variable is false

I am trying to create a command (with the help of the director) which is executed via SNMP.

This command should be executed for hosts with SNMPv1 as well as for hosts with SNMPv3.

Since the arguments differ according to version, I assign the hosts a Boolean value called “use_snmp_v3”. The arguments are to be assigned using the host variable (use_snmp_v3).

This works if the value is set to “true”, then the corresponding values are assigned with “set_if = $ use_snmp_v3 $”.

What unfortunately does not work is to set the argument “-C” if the host variable (use_snmp_v3) is set to “false”. I tried “$use_snmp_v3$ == false” and “!$Use_snmp_v3$” but both of them don’t work.

Is there any way to solve this?

  • Version used (icinga2 --version): 2.12.3
  • Operating System and version: CentOS 7
  • Icinga Web 2 version and modules (System - About) 2.8.2

You could try changing the condition format for the arguments from string to Icinga DSL

and see if you can create some Icinga DSL code that matches your needs

I guess the easiest way would be to also create a user_snmp_v1 variable and use that.

1 Like

Thanks, got it done with it: