It then would run the check only against servers that are in both
WWW-Servers and US-Servers, in my example, just www-us.
Is this feature available? If it isn't, will it be available in the
future?
Ethan Galstad said that he doesn't have any plans to add intersection support.
Is there an alternative way to accomplish this given the most recent
Nagios version?
You can exclude some hosts from the definition by preceding the host or hostgroup with a !
symbol. So, try something like this:
define service{
use local-service
hostgroup_name *,!EU-Servers,!FTP-Servers
servicegroups WWW Checks
service_description Check HTTP Response Time
check_command check_http_response_time!50
}
I know it's an old post, but I just ran across this question while I was looking for something else. I'm not much of a nagios expert, but I do love it.
Any check that you place in a hostgroup will apply to any host in that hostgroup (which you knew already). If you create the same check in the host cfg, then it'll override the hostgroup check.
Anyhow, the way I do this is to:
1. Set up a hostgroup cfg file with the checks in it.
Here's my basic C: drive space check.
define service{
use generic-service
hostgroup_name windows-servers
service_description C: Drive Space
notification_period workhours
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
2. However, one server runs with much less free space than the norm. So in it's host cfg, I have:
define service{
use generic-service
host_name ServerName
service_description C: Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 95 -c 99
notification_period workhours
}
Now the service check is going to alert you for 80% and 90% for all hosts in the hostgroup, except for the host that you added the check with the change values in it.
Arranging it this way allows me to only add custom services, and service checks that aren't the norm in the host definition.
I'm not sure if this is common use or not, but this article blew my mind when it came to setting up the config files. I was already tired of editing these humongous text files, and this just made it so easy.
Anyway, I hope that helps.
Best Answer
I wouldn't depend on hostgroups for that - they can be used to group hosts for external user interfaces and help as a basis, but I would recomment looking into alternate apply rule match conditions such as
You can of course use the apply rule assign/ignore where expressions for services also inside your hostgroup membership assignment definition, if they match.
Another cool thing you can do with Icinga 2 - use apply for rules and grnerate services based on host custom attributes as array or dictionary. That way you'll pass the entire check information from the host to the service apply rules if you want to.
Look at the docs for a detailed explaination and example: http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/monitoring-basics#using-apply-for