several notification commands with different timeperiods

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
link
Posts: 7
Joined: Mon Jun 10, 2013 4:37 am

several notification commands with different timeperiods

Post by link »

Hello,

Idea seems simple, but didn't find how to acomplish that.
I want to send sms alerts only in non-working hours.
Tried to define two contact templates (generit, sms-conctat) with different commands (email-notify, sms-notify)
and added to contact : use generic-contact,sms-contact
but that do not work.

Does anyone have an idea how to execute ceration notification commands only for specific timeperiod ?
thanks in advance.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: several notification commands with different timeperiods

Post by abrist »

Did you set the desired respective timeperiods on the templates?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
link
Posts: 7
Joined: Mon Jun 10, 2013 4:37 am

Re: several notification commands with different timeperiods

Post by link »

sure I do

Code: Select all

define contact{
        name                            generic-contact        
        service_notification_period     24x7                  
        host_notification_period        24x7                 
        service_notification_options    w,u,c,r,f,s           
        host_notification_options       d,u,r,f,s            
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        register                        0                     
        }

define contact{
        name                            sms-contact       
        service_notification_period     nonworkhours                   
        host_notification_period        nonworkhours                   
        service_notification_commands   notify-by-sms  
        host_notification_commands      host-notify-by-sms
        register                        0                      
        }
then I do:

Code: Select all

define contact{
        contact_name                    nagiosadmin           
        use                             generic-contact,sms-contact     
        alias                           Nagios Admin           

        email                           [email protected]
        pager                           xxxxxxxxxxxxxxx
        }
I can set any timeperiod in sms-contact template, it just never works
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: several notification commands with different timeperiods

Post by abrist »

So what is the exact issue? Are you receiving any sms texts and emails? If so, when?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
link
Posts: 7
Joined: Mon Jun 10, 2013 4:37 am

Re: several notification commands with different timeperiods

Post by link »

with config I posted I never receive sms, only mails.
if I do in one template:

Code: Select all

service_notification_commands   notify-service-by-email,notify-by-sms
then I get mail and sms, but 24x7 for sure.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: several notification commands with different timeperiods

Post by slansing »

Those are the command handlers for your notifications, that is expected behavior.

Quoting Andy:
So what is the exact issue?
link
Posts: 7
Joined: Mon Jun 10, 2013 4:37 am

Re: several notification commands with different timeperiods

Post by link »

with config I posted I suggest that I will receive mails + sms in non-working hours.
And issue is that I receive only mails and never sms.

Just for test I've changed 'nonworkhours' to '24x7' in sms-contact tempate, and anyway I never received any sms.
Checked nagios.log as well - it never calls notufy-by-sms in such configuration.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: several notification commands with different timeperiods

Post by abrist »

This may be due to the missing notification options. It looks as if you have not declared any host/service states to be notified about. You may want to add:

Code: Select all

service_notification_options    w,u,c,r,f,s           
host_notification_options       d,u,r,f,s  
To your sms contact definition.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
link
Posts: 7
Joined: Mon Jun 10, 2013 4:37 am

Re: several notification commands with different timeperiods

Post by link »

nope, I tried that before and now checked again.
It doen't metter if *notification_options are presend or not.
nagios just executes notify-service-by-email and never by-sms
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: several notification commands with different timeperiods

Post by abrist »

Lets check the logs:

Code: Select all

grep notify-by-sms /usr/local/nagios/var/nagios.log
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked