I want to set Nagios up to issue warnings (e.g. mildly high load or disk usage) via email, but for critical items to alert by pager.
Right now we notify via email and pager simultaneously for all warnings. My generic contact definition is as follows:
define contact{
name generic-contact
service_notification_options w,u,c,r,f,s
host_notification_options d,u,r,f,s
service_notification_commands notify-service-by-email,notify-service-by-pager
host_notification_commands notify-host-by-email,notify-host-by-pager
register 0
service_notification_period 24x7
host_notification_period 24x7
}
How can I make it so that the email notification occurs for both warnings and critical, but paging for critical only?
You should be able to achieve this by defining different contacts - one for pager notification only, one for email notification only - and assigning different values of
host/service_notification_options
:If you want to keep host/service definition overhead low, you should aggregate them in a contactgroup like this:
and use the contactgroup instead of individual contacts.
To send the WARNING alert via email and the CRITICAL alert via SMS, I also defined 2 contacts: one for email and one for SMS. It's working fine but below are what I have tried to accomplish this with only one contact.
The idea is re-write the
(service|host)_notification_commands
to check the$SERVICESTATE$
macro then use the corresponding method.command.cfg
notify.sh
Notice that when the service is OK, I need to check the
$LASTSERVICESTATE$
macro to decide which method to use.contacts.cfg
templates.cfg
I don't know if this is the best option, but I can't recall of Nagios being able to page only on a special flag. What you can do however is duplicate the contact with his name and something to id him as sms (name-sms). This will cause redundant contacts. However if you are using groups you can just add the contact to the group.