Page 1 of 1

customizing notifications

Posted: Fri Feb 15, 2013 5:23 pm
by jeremy.garman
Hi guys. I've read several threads on related subjects, but I'm embarrassed to say that I didn't really follow the config settings listed.
I've got a whole bunch of hosts defined, and a whole bunch of services defined per host, all of which are being monitored, and (currently, only bc I'm still in the system config stage of my deployment) all of the hosts are set for sending notifications when required.
--------------------
sample host def:
define host{
use linux-server ; Inherit default values from a template
host_name lmprodwa2.lmgroup.com ; The name we're giving to this server
alias lmprodwa2 ; A longer name for the server
address 192.168.115.70 ; IP address of the server
contact_groups oncall ; contact for alert notifications
}
--------------
service def:
define service{
use generic-service
host_name lmprodwa2.lmgroup.com
service_description CPU Load
check_command check_nrpe!check_load
}
----------------------------
host notification def (yes, I'm using sendmail on my ubuntu Nagios server):
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/sbin/sendmail -s "$NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$" $CONTACTEMAIL$
}
---------------
contact def:
define contact{
contact_name itoncall ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias IT Oncall ; Full name of user
email [email protected] ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
----------------------
contact group def:
define contactgroup{
contactgroup_name oncall
alias Nagios Administrators
members itoncall
}

So what I'd like to do is this:
setup one notification group to receive all system warning and critical alerts (including problem, recovery and acknowledged messages), for 24/7 notification period.
setup another notification group to receive ONLY critical alerts (including only problem and recovery messages), for 24/7 notification period.
setup a third notification group to receive all system warning and critical alerts (including problem, recovery and acknowledged messages), only for business hours (8-5pm)

so far, I have the first notification group working fine, but I can't decipher the notification options, variables and arguments sufficiently to setup the other two notification groups effectively.

any help on this would be greatly appreciated!!!
thanks in advance,
- Jeremy

Re: customizing notifications

Posted: Mon Feb 18, 2013 5:01 am
by gshergill
Hi Jeremy,

Under your contact definition you have the following:

Code: Select all

use generic-contact ; Inherit default values from generic-contact template (defined above)
This is what your generic-contact will probably look like;

Code: Select all

define contact{
        name                            generic-contact         ; The name of this contact template
        service_notification_period     24x7                    ; service notifications can be sent anytime
        host_notification_period        24x7                    ; host notifications can be sent anytime
        service_notification_options    w,u,c,r,f,s             ; send notifications for all service states, flapping events, and scheduled downtime events
        host_notification_options       d,u,r,f,s               ; send notifications for all host states, flapping events, and scheduled downtime events
        service_notification_commands   notify-service-by-email ; send service notifications via email
        host_notification_commands      notify-host-by-email    ; send host notifications via email
        register                        0                       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
        }
The link below describes each of the options for a contact definition:
Simply create three contact templates and set the users to whichever they require.

As for time periods, this is the one you would need I think for the third one:

Code: Select all

define timeperiod{
        name            workhours
        timeperiod_name workhours
        alias           8-5 A Day, 5 Days A Week
        monday          08:00-17:00
        tuesday         08:00-17:00
        wednesday       08:00-17:00
        thursday        08:00-17:00
        friday          08:00-17:00
        }
Change as required.

Hopefully this can point you in the right direction, good luck!

Kind Regards,

Gary Shergill

Re: customizing notifications

Posted: Tue Feb 19, 2013 11:18 am
by abrist
If you have any other issues, open a new thread OP, and reference this thread.