Am 28.02.2016 um 09:56 schrieb Stephan Tesch: Hi everyone,
just to close this issue, I solved it by using two different check commands:
### Checkcommand definition
# CPU monitoring
object CheckCommand "ive_cpu2" {
import "snmp"
vars.snmp_oid = ".1.3.6.1.4.1.12532.10.0"
vars.snmp_warn = "$cpu_warn$"
vars.snmp_crit = "$cpu_crit$"
vars.snmp_label = "CPU"
}
object CheckCommand "ive_cpu3" {
import "snmpv3"
vars.snmpv3_oid = ".1.3.6.1.4.1.12532.10.0"
vars.snmpv3_warn = "$cpu_warn$"
vars.snmpv3_crit = "$cpu_crit$"
vars.snmpv3_label = "CPU"
}
## Service Definitions
# CPU Monitoring
apply Service "ive_cpu" {
import "generic-service"
display_name = "CPU Load"
check_command = "ive_cpu3"
assign where "sslvpn" in host.groups && host.vars.snmp_version
!= "2c"
}
apply Service "ive_cpu" {
import "generic-service"
display_name = "CPU Load"
check_command = "ive_cpu2"
assign where "sslvpn" in host.groups && host.vars.snmp_version
== "2c"
}
If anyone has better ideas, don't hesitate to post them.
Best regards,
Stephan
> 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
