Extract a Portion of a Service Group Membership
Posted: Wed Jul 11, 2012 12:41 pm
Our primary purpose for Nagios is interface status checking. To that end, I'm trying to improve its efficiency by having it check all of the monitored interfaces on a switch or router without having to run the check script every time. I only want it to return results for the configured interfaces so I don't end up with a lot of "Passive check result returned for xxx but no service is defined" messages. (And most of the interfaces on each device I'm not going to care about.)
My first option is to add all of the monitored interfaces across all of the devices to a servicegroup called interfaces but that entire list across all devices in the group gets passed to the script every time. I don't see a way to specify the host name in an on-demand macro (like $SERVICEGROUPMEMBERS:switch1:interfaces$) so that I just get the interface list from the device it is currently checking.
My second option is to define separate servicegroups for each device (switch1_interfaces, switch2_interfaces, router1_interfaces, etc.) and then configure each check specifically for that servicegroup. That seems a PITA; it would be helpful if I could pre-define a service template that could do a substitution like $SERVICEGROUPMEMBERS:$HOSTNAME$_interfaces$. But I'm not seeing that so I'll have to do it the long way. For each device, I can define a service and have a custom macro (like _INTERFACES $SERVICEGROUPMEMBERS:switch1_interfaces$) so that I can just reference _INTERFACES in the service template, but I still need to manually change the "switch1_interfaces" in each service. It just feels error-prone.
Unless anyone has any suggestions? Thanks!
My first option is to add all of the monitored interfaces across all of the devices to a servicegroup called interfaces but that entire list across all devices in the group gets passed to the script every time. I don't see a way to specify the host name in an on-demand macro (like $SERVICEGROUPMEMBERS:switch1:interfaces$) so that I just get the interface list from the device it is currently checking.
My second option is to define separate servicegroups for each device (switch1_interfaces, switch2_interfaces, router1_interfaces, etc.) and then configure each check specifically for that servicegroup. That seems a PITA; it would be helpful if I could pre-define a service template that could do a substitution like $SERVICEGROUPMEMBERS:$HOSTNAME$_interfaces$. But I'm not seeing that so I'll have to do it the long way. For each device, I can define a service and have a custom macro (like _INTERFACES $SERVICEGROUPMEMBERS:switch1_interfaces$) so that I can just reference _INTERFACES in the service template, but I still need to manually change the "switch1_interfaces" in each service. It just feels error-prone.
Unless anyone has any suggestions? Thanks!