Am 27.02.2016 um 22:09 schrieb Michael Friedrich: Hi Michael, >> 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.
Hmm, that sounds like a good idea. I'm not that much into the apply rules so far, but I will give it a shot. > 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 I was fiddling around with those, too. But I had the problem that I was not able to modify the exĂsting "-P" argument if I import eg. snmpv3 into my own checkcommand. > 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. Yep, I should start to set it to 2c, since at least check_snmp uses that. Many thanks for the hint! Best regards, Stephan
signature.asc
Description: OpenPGP digital signature
_______________________________________________ icinga-users mailing list [email protected] https://lists.icinga.org/mailman/listinfo/icinga-users
