What is host-notify-by-email and exclusions in notifications



I am new here and have read through documentation and ran a few searches but can’t seem to come up with the answer I need. At least I was not able to find it.

  1. What is the difference between notify-by-email and host-notify-by-email. I looked at their corresponding command definition in the miscommands.cfg file but I can’t decipher the functional difference.

Say I set up a check for VNC. Which email notification method will it use?

  1. Is it possible to exclude certain contacts for notifications? For example, consider this setup:

5 machines named A through E

1 usergroup called Admins

2 users called Adam and Eve, but in group Admins.

Adam wants to receive all notifications. Eve only cares about information pertinent to A and B.

I have a service setup called, say PING with contact_group = Admins, and host_name = A, B, C, D, E

Problem is Eve does not care about C, D, E.

Do I have to make TWO PING services now? I hope not because it’s not just one service. I would have to make duplicates for many services.

Any help would be appreciated.


To answer your first question:

host-notify-by-email serves to notify you of changes in the status of a host. In Nagios you define a check-host-alive command (by default a ping command) that Nagios uses to check if a host is up or reachable. If the ping fails, then Nagios will use host-notify-by-email to send you a message, as if to say “Hi! This host is down!!”

Now, notify-by-email is a command that serves to tell you that a particular service check on the host is down. Say you’re using SNMP to check the disk space on the remote host, and the disk space hits the critical threshold you’ve defined. Nagios will use the notify-by-email command to tell you “Hey! There’s a problem with your disk space on this host!!” But the host is still up. Get it? Got it? Good.

Now, next question: in services.cfg, there is an option called contact_groups. You list here the contact groups that you want to be notified for status changes to this particular service. As you define different services for different hosts, this allows you to control which hosts will be notified of any problems with this service.

Hope this helps. Post back with any questions.



Thank you for your response but I am still a little confused, I’ll ask for clarifications in the same order.

  1. Is check-host-alive somehow hardcoded in Nagios? Why did they decide to make this special command that acts differently? I looked at the host-notify-by-email command definition in miscommands.cfg and it does not reference check-host-alive at all. In other words, I don’t see any indication how Nagios would know that my PING check is called check-host-alive or vice versa. It also doesn’t know if I commented out check-host-alive altogether and made a new PING check command and called it are-servers-alive.

  2. I think I was not clear about this question. I already have contact_groups setup in services.cfg. My question has to do with exlusion. What if there are certain members in the groups that only want certain emails. Do I have to put everyone in an individual contact group? Here is an example:

I have two users sygyzy, SonOfThunder. I have a check-host-alive service with 10 hosts. Right now I just have one entry for it in services.

host_name A, B, C, D, E, F, G, H, I, J
service_description PING
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups default_group
notification_interval 120
notification_period 24x7
notification_options c,r
check_command check-host-alive

Say SonOfThunder only cares about A, B, and C and does not want emails when the other hosts go down. How do I accomplish this in a way that minimizes having to make unneccessary new entries?

  1. Check-host-alive can be found in checkcommands.cfg, I believe. It can be modified/renamed however you want it to be. If you rename it, just make sure your check command uses the right name (i.e. “are-servers-alive”). Your host-notify-by-email command really has nothing to do with the check-host-alive command. By default, Nagios states that if check X fails, use notification command Y. They are independent of each other in that sense.

Btw, usually you only define “check-host-alive” for your check command in your host configuration file, not your service configuration file.

  1. In this case, SonOfThunder would be in a different group, and that new group would be listed in the service config as the contact_group for the host/service.

I think you need to re-read the Nagios docs. You’re missing a couple of vital points.


Perhaps another view on the problems might help.
In “services.cfg” there is the “contact_groups” definition.
Put in there a group called admins1 for services A and B ONLY llike this:
contact_groups admin1
For services C, D, E put in there like this:
members admin1,admin2

In the file “contactgroups.cfg” there is a defintion called “contactgroup_name” and “members”. Make it like this:
contactgroup_name admin1
members adam,joe, pete,sam
and make another entry like this:
contactgroup_name admin2
members eve,frank,whoeverelse_doesn’t_like_C, D, E
Problem solved, eve doesn’t get anything about c,d and e.

About the notify commands. You stated there is no difference? Please look again, since each command is formatted differently.
Just one instance is this:
notify-by-email has this in it:
But host-notify-by-email has this:
The reason for that is fairly straight forward. For a service check, you want it to say in the subject line, that "service ftpcheck has failed. In a host failure, you want it to say “Host whatever failed.” It wouldn’t make any sense if the content of each type of failure was formatted the same.

It’s actually very nice, since you can create formats to exaclty the way you like.