Best way to apply notifications to hosts

I’ve been going round circles for a while - I’m hoping someone will be able to tell me if what I’d like to do is even possible…? :smiley:


  • I have a number of hosts.
  • Each host has a custom variable ‘notification_groups’ which is a ‘Director Object’ array, containing one or more UserGroups.
  • These user groups contain users.
  • The users have custom variables defined, like mobile number, email, various push-API tokens (pushover, slack, prowl, telegram).

I’ve written a number of notification scripts: a host and service script for each method.

How on earth do I apply them? I’m thinking it must be really obvious (or impossible).

Any help anyone could give me would be HUGELY appreciated. Thanks!

Hi Geoff,

I would recommend you to play with apply rules. If you have a lot information/attributes per host object you can use it and define apply rule logic. Custom variable could be array or string or some other type it doesn’t matter.

So you need first notification template and from it you will create apply rule. In notification template you can specify users, user groups, notification cmd etc.

So lets say you have host object “server1” and you assigned value “notification_group_noc” fo field notification_group.

Notification apply rule should look like: == “server1” AND host.vars.notification_group == “notification_group_noc”

or if you want to apply this to all servers with “notification_group_noc”, the apply rule should be:

host.vars.notification_group == “notification_group_noc”

Any custom variables has been stored under host.vars.<name_of_custom_variable>

Hope this is helpful.



I was hoping for a way to make the apply rules more generic, so I wouldn’t have to have one for each user group (or one containing all the user groups).

In my ideal world I imagined a user creating a group, then it automatically having notifications added to it.

I ended up writing a script which targets each notification template with an apply-rule, for each user group. I run this once a minute, which seems reasonable.

But thanks for taking the time to reply - it’s good to know I’m not going mad!! :smiley:

This story could be more complex and you can specify email on each host … let say each host location has different email … then you need to develop new field, assign it to host template and use this new field lets say the name is “host.vars.email_to” and specify that inside of notification template … it should look like $host.vars.email_to$ on that filed … playing with apply rules, custom fields and custom variables you can do a lot … just be sure that you have the right logic :wink:

That’s a good idea! Thankyou!