> Am 27.02.2016 um 21:08 schrieb Stephan Tesch <[email protected]>:
>
> Hey everyone,
>
> I just started a couple of days ago to use Icinga 2. So far it looks
> very promising, so a big thanks to the developers for this piece of
> software!
>
> For my setup I have to manage a lot of SNMP devices, and my idea was to
> create a service / check command that looks at certain vars and then
> decides if the query should go for SNMPv2c or v3. The default will be
> v3, but nonetheless I'd like to specify on a per host basis, that SNMPv2
> gets used.
>
> What I don't seem to get working is a dynamic construct like this, and I
> don't know why. Any hints are highly appreciated:
>
> object CheckCommand "mySnmp" {
>  if ( "$snmp_version$" == "2" ) {
>      arguments += {
>        "-P" = "2c"
>      }
>    } else {
>      arguments += {
>        "-P" = "3"
>      }
>  }
> }
>
> object Host "myHost" {
>  import "myTemplate"
>  address = "192.168.10.111"
>  vars.is_virtual = true
>  vars.snmp_version = "2"
> }
>
> It seems to me, that $snmp_version$ doesn't resolve but on the other
> hand the else path is not taken?! Any ideas?

A quick question - wouldn't it be more reasonable to have multiple snmp 
checkcommands, and only select them conditionally in service apply rules based 
on the host custom attribute? That would of course need some extra custom 
attributes as command parameters the.

Though it is a more sensible approach if you decide to make use of the already 
existing ITL plugin check commands for snmp.

http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/plugin-check-commands#plugin-check-command-snmp
http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/plugin-check-commands#plugin-check-command-snmpv3

Apart from that - if you would just check in the service apply rule for the 
host.vars.snmp_version variable, and then set it into the service scope with 
"2" bevoming "2c" this would be eaven more easy.

object Host "myhost" {
  ...
  vars.snmp_version = "2"
}

apply Service "snmp" {

  check_command = "snmp"

  if (host.vars.snmp_version == "2") {
    vars.snmp_version = "2c"
  } else {
    vars.snmp_version = "3"
  }

  //more snmp command attributes

  assign where host.vars.snmp_version != ""
}

Your idea with the check command isn't bad but I wouldn't go that route down 
there.

Kind regards,
Michael

>
> Thanks,
> Stephan
>
> _______________________________________________
> icinga-users mailing list
> [email protected]
> https://lists.icinga.org/mailman/listinfo/icinga-users

-- 
Michael Friedrich, DI (FH)
Senior Developer

NETWAYS GmbH | Deutschherrnstr. 15-19 | D-90429 Nuernberg
Tel: +49 911 92885-0 | Fax: +49 911 92885-77
CEO: Julian Hein, Bernd Erk | AG Nuernberg HRB18461
http://www.netways.de | [email protected]

** OSDC 2016 - April - netways.de/osdc **
** OSBConf 2016 - September - osbconf.org **
_______________________________________________
icinga-users mailing list
[email protected]
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to