Paging and email notifications


#1

Does anyone know how to configure Nagios to page for Critical events and only email for Warning events?


#2

Make two separate contact definitions for email and pager. In contact definition for pager put notification_options for Critical, and in the contact definition for e-mail put the notification_options for Warning.


#3

Do you put this in contacts.cfg? I am trying to find an example of the syntax without much luck. Also, do you have to create different contact group names for each? We have 4 main contact groups currently, so does this mean I would have to create 4 more?

Thanks,
Bill


#4

[blockquote]Do you put this in contacts.cfg?[/blockquote]
You can put it in any file as long as those configuration files are defined in nagios.cfg. At the beginning of the nagios.cfg you can find
# OBJECT CONFIGURATION FILE(S) part of the file where you can define every .cfg file separately, like this (there is also an example in the file):

cfg_file=/etc/nagios/contactgroups.cfg cfg_file=/etc/nagios/contacts.cfg cfg_file=/etc/nagios/dependencies.cfg cfg_file=/etc/nagios/escalations.cfg cfg_file=/etc/nagios/hostgroups.cfg
or just set the directory containing all of your .cfg files (which is much more simple thing to do), like this:

(in this case, you have to hold all of your configuration files in that directory).
Then add any configuration file (which you can also create on your own), but be careful to set the file permissions so nagios user could read them.
You are free to use both options as well, but it is advisable for you to use only one of those, until you get familiar with Nagios. If you will use cfg_dir, then comment out (#) those cfg_file lines in nagios.cfg. If you would like to use cfg_file, then comment out (#) the cfg_dir

[blockquote]I am trying to find an example of the syntax without much luck.[/blockquote]
nagios.sourceforge.net/docs/3_0/ … ml#contact

I will now write the example of how you can do what I’ve meant, but I would strongly suggest you to read the documentation of Nagios which explains everything very well.

First, define two separate contacts, one for email with notification_options you wish (I’ve put Warning and Recovery here), and second one for pager (with Critical and Recovery options). I have left the host-notify options in default values (Down, Unreachable, Recovery) in both definitions, so you can specify them to follow your needs.

define contact{ contact_name email alias email_contact host_notifications_enabled 1 service_notifications_enabled 1 service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,r host_notification_options d,u,r service_notification_commands notify-by-email host_notification_commands host-notify-by-email email email_address }

define contact{ contact_name pager alias pager_contact host_notifications_enabled 1 service_notifications_enabled 1 service_notification_period 24x7 host_notification_period 24x7 service_notification_options c,r host_notification_options d,u,r service_notification_commands notify-by-epager host_notification_commands host-notify-by-epager pager pager_address }

Then make contactgroup definition:

define contactgroup{ contactgroup_name group alias contact_group members email,pager }
This way both contacts are in the same group, but the contact definition of each contact have it’s own setting which notifications should be sent to those.

And then use that group as contact_group variable in your host/service definitions.