Page 1 of 2
several notification commands with different timeperiods
Posted: Mon Jun 10, 2013 4:41 am
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.
Re: several notification commands with different timeperiods
Posted: Mon Jun 10, 2013 11:48 am
by abrist
Did you set the desired respective timeperiods on the templates?
Re: several notification commands with different timeperiods
Posted: Tue Jun 11, 2013 3:04 am
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
Re: several notification commands with different timeperiods
Posted: Tue Jun 11, 2013 10:45 am
by abrist
So what is the exact issue? Are you receiving any sms texts and emails? If so, when?
Re: several notification commands with different timeperiods
Posted: Wed Jun 12, 2013 2:47 am
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.
Re: several notification commands with different timeperiods
Posted: Wed Jun 12, 2013 9:12 am
by slansing
Those are the command handlers for your notifications, that is expected behavior.
Quoting Andy:
So what is the exact issue?
Re: several notification commands with different timeperiods
Posted: Wed Jun 12, 2013 10:24 am
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.
Re: several notification commands with different timeperiods
Posted: Wed Jun 12, 2013 10:41 am
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.
Re: several notification commands with different timeperiods
Posted: Fri Jun 14, 2013 3:52 am
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
Re: several notification commands with different timeperiods
Posted: Fri Jun 14, 2013 12:48 pm
by abrist
Lets check the logs:
Code: Select all
grep notify-by-sms /usr/local/nagios/var/nagios.log