Right now, a service definition can use host_name or hostgroup_name to apply the service check to a particular host or hostgroup. I would like to be able to apply a service to any host (or hostgroup) that has some custom attribute, so that it is easier to specify which service to check on which host.
The requested feature here could be used in many different ways, but here's a specific example of how I was thinking of using it.
1. Create a host template named eg 'app_server'
2. Within that host template, set a custom variable '_TYPE' to 'appserver'
3. In your service define, do 'custom_match HOST_TYPE appserver' in place of 'host_name' or 'hostgroup_name'.
Or alternatively, use a 'hostgroup_name' option in the service define, but then define your hostgroup using the 'custom_match HOST_TYPE appserver' technique instead of using the 'members' option to enumerate them.
Now, whenever you create a new host that happens to be an "app server", whatever that might mean, inherit from the 'app_server' template. The new host will automatically have the appropriate service checks associated with it.
I don't know if this is actually the right way to do it. I am in my very early days of using Nagios, and it just seems weird to me that you have to specify everything directly (host endoftheworld is named endoftheworld and service anyonestillalive should apply to hosts endoftheworld,aftertheplague,alieninvasion. service buildingsstanding should apply to hosts endoftheworld,aftertheplague,alieninvasion. etc.) I really want a layer of indirection -- tag host endoftheworld with 'badstuffhappened', then associate relevant checks with that tag. hostgroups are close, but they show up in the UI, might confuse people when they overlap, and still require you to enumerate all of the hosts in the group rather than having the hosts self-identify.
Maybe there's some way to do this that I'm missing?
Comments (0)