> On 21. Dec 2017, at 09:02, Joosten, Markus <markus.joos...@plumbe.de> wrote:
> 
> Am 2017-12-21 04:20, schrieb Jayapandian Ponraj:
>> Thanks for the reply
>> We do heavily use apply rules based on host variables and for hostgroup 
>> definitions, but once in a while we come across a service which is spread 
>> across 2 or 3 hosts which don't share anything in common. We can go ahead 
>> add separate service definition for each of them(not preferred) or write an 
>> apply rule with a reflex matching those specific hosts.
>> Adding plain service definition for a single host and switching over to 
>> apply rules when 2 or 3 hosts are involved feels counter-intuitive. Since 
>> service definitions will be added by many teams would like to keep it 
>> simple..
>> So need a simple and elegant solution keeping in mind the common pitfalls.
>> https://www.icinga.com/2016/04/28/avoiding-common-pitfalls-with-apply-rules/
>> So idea is to keep it simple and avoid the pitfalls and performance issues.
> Hi there,
> I'd say there are at least a few ways to keep it simple and achieve your 
> solution.
> 
> Probably my preferred solution would be to use an explicit assign statement 
> within your apply rule for every host:
> 
> assign where host.name == "host1"
> assign where host.name == "host2"
> assign where host.name == “host3"

Keep in mind that each assign where expression is evaluated on all host 
objects. This is rather expensive compared to just one logical expression which 
combines the conditions with &&.

Furthermore it can be easily made more readable using the in operator and array 
notation.

assign where host.name in [ “h1”, “h2" ] 

Still, I’d suggest to use more generic patterns, as hostnames may be changed 
and modifying the apply rules later on is cumbersome.

Kind regards,
Michael

> 
> Another possibility is to use a host group for these hosts, but to me this 
> seems counter-intuitive as it groups hosts together which just share a 
> service.
> 
> Regards,
> Markus
> _______________________________________________
> icinga-users mailing list
> icinga-users@lists.icinga.org
> https://lists.icinga.org/mailman/listinfo/icinga-users

_______________________________________________
icinga-users mailing list
icinga-users@lists.icinga.org
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to