Page 1 of 1

Exclude service check from one host in hostgroup

Posted: Wed Sep 07, 2016 9:48 am
by eloyd
Is it possible to put a host into a host group, assign a service to the hostgroup, but then not have that service run on specific hosts? For instance:
  • Make a hostgroup called CARS
  • Put the hosts Chevy, Toyota, Volkswagen, and Ford into CARS
  • Run a service check called DO_WE_HAVE_GAS on hostgroup CARS
  • Run a service check called EMISSIONS on hostgroup CARS
  • Whoops!! Don't want to run EMISSIONS on Volkswagen!
So how can I leave everything as it is, but exclude the EMISSIONS service check from running on VOLKSWAGEN?

Re: Exclude service check from one host in hostgroup

Posted: Wed Sep 07, 2016 10:19 am
by BanditBBS
Using custom variables.....let me look for the thread...

EDIT: can't find thread, but...
Add a free variable

Variable Name = host_name
Variable value = !YOUR-HOST.COM,!YOUR-OTHER-HOST.COM

Now for the caveat....
This works perfectly fine if you have a service definition where you are adding hostgroups and want to just exclude a couple hosts. This will fail miserably if you also are adding individual hosts (in addition to hostgroups) because the free variable you set will in fact overwrite the individual hosts you have.

Re: Exclude service check from one host in hostgroup

Posted: Wed Sep 07, 2016 10:32 am
by eloyd
So, if I get you right, you're saying add a free variable called "host_name" with a value called "!Volkswagen" to my EMISSIONS service check? My understanding is if I do that, then I get a variable called $_SERVICEhost_name$, unless I misunderstand.

And is this the thread you're referring to: https://support.nagios.com/forum/viewto ... 16&t=24170

Re: Exclude service check from one host in hostgroup

Posted: Wed Sep 07, 2016 10:39 am
by BanditBBS
Yeah, that's it! Also, the OP in that thread said it works, so no idea in regards to your question.

Re: Exclude service check from one host in hostgroup

Posted: Wed Sep 07, 2016 10:42 am
by eloyd
Yah, I read through it. I'll see if it works for this customer.

Re: Exclude service check from one host in hostgroup

Posted: Wed Sep 07, 2016 11:38 am
by eloyd
Suh-weet. Works. Thanks, Bandit for pointing me at Scott's kludge.

Image

Re: Exclude service check from one host in hostgroup

Posted: Wed Sep 07, 2016 1:03 pm
by bwallace
Thanks Guys! Locking this thread now...