Page 1 of 2
2 notification method,
Posted: Tue Jan 02, 2018 11:38 am
by liangwh
Hi,
I would like to have 2 different notification setup. for example email, and SMS.
what i am trying to achieve is , nagios will always send notification using 1st method,ie.email.. however if the email services down, then nagios will use 2nd method.ie.sms to send out notification
may i know is this possible to do? kindly advise
Re: 2 notification method,
Posted: Tue Jan 02, 2018 5:53 pm
by dwhitfield
You can set up two, but there isn't any sort of failover mechanism. You could set up both but just have the sms notification command commented out. You could have a script uncomment those lines if the mail server is down. You could do this through an event handler:
https://assets.nagios.com/downloads/nag ... dlers.html
Re: 2 notification method,
Posted: Wed Jan 03, 2018 3:20 am
by liangwh
Hi dwhitfield, thanks for your reply.
understand that there is no failover mechanism , however i would like to ask is my steps below do-able/correct? is there a better way of doing this as workaround? thanks
1. in command.cfg, commented out sms method
2. setup another service check .ie. check_smtp,
when check_smtp is critical, it goes to event-handler
sed some keyword and comment all sms method
nagios will now send sms.
however, is there any way to to re-comment out sms method once the check_smtp is recovered?
Thanks
Re: 2 notification method,
Posted: Wed Jan 03, 2018 10:35 am
by mcapra
liangwh wrote:
however, is there any way to to re-comment out sms method once the check_smtp is recovered?
More
sed/
awk!
If this were my problem to solve, I'd bake the logic into my notification handler.
Code: Select all
if( send email command fails ) {
// try to send SMS
}
It's certainly cleaner and less tough on the Nagios daemon than modifying config files on the fly.
Re: 2 notification method,
Posted: Wed Jan 03, 2018 11:20 am
by dwhitfield
mcapra wrote:
It's certainly cleaner and less tough on the Nagios daemon than modifying config files on the fly.
This is true!
I guess it ultimately depends on how comfortable the OP is in not using the default notification commands. Event handlers are a great place for "custom" stuff, but there's certainly nothing stopping you from using custom notification scripts.
There are also escalations, which definitely don't do exactly what you want, but could be used as a work around if acknowledging issues is the norm in your environment:
https://assets.nagios.com/downloads/nag ... tions.html -- the major caveat here is that it will take some time for the escalation to kick in. You control the time, but there's no logic to check that mail is down.
Re: 2 notification method,
Posted: Fri Jan 05, 2018 2:01 am
by liangwh
mcapra wrote:liangwh wrote:
however, is there any way to to re-comment out sms method once the check_smtp is recovered?
More
sed/
awk!
ya ..but what i asking was, since the check_smtp recover will go to (same) event handler . so comment and uncomment should be all done in 1 script , am i correct.
If this were my problem to solve, I'd bake the logic into my notification handler.
Code: Select all
if( send email command fails ) {
// try to send SMS
}
It's certainly cleaner and less tough on the Nagios daemon than modifying config files on the fly.
Thanks for pointing this out, i didnt know there's notification handler.
how does it work compare to a normal event_handler. i tried google it but seems like its hard to find the link about it. appreciate if you could provide link so i can look it up before asking more question.
thanks alot
thanks
Re: 2 notification method,
Posted: Fri Jan 05, 2018 10:52 am
by dwhitfield
liangwh wrote: i tried google it but seems like its hard to find the link about it.
What did you find? I can give you links, but I don't want to double-dip. The place to start is
https://assets.nagios.com/downloads/nag ... tions.html
You should read the entire document, but "Notification Methods" is going to be the most useful section for you.
Re: 2 notification method,
Posted: Mon Jan 22, 2018 7:00 am
by liangwh
Hi,
I am sorry i cant find any notification handler to handle "if email fails, then sms"
Appreciate if you could share some idea
or is it still ok to use the steps earlier: check_smtp > critical > event handler >script to sed
Thanks
Re: 2 notification method,
Posted: Mon Jan 22, 2018 5:29 pm
by dwhitfield
liangwh wrote:
I am sorry i cant find any notification handler to handle "if email fails, then sms"
There isn't one. As
@mcapra noted, you have to write the handler yourself. The documentation is there to help you write your handler. Someone may also be able to help you write it as this is a public forum, but it's not something support techs do as a matter of policy.
We do also offer custom development if that would be of interest.
Re: 2 notification method,
Posted: Tue Jan 23, 2018 12:31 am
by liangwh
Hi ,
I would like to try to write the handler. However I still cant get the idea how this handler works.
If i use global event handler, and the handler is if email fails then sms,
does that mean that contacts should not have any host/service notification enabled , because that already configured on the handler.
For the custom development, I might need to check with my commercial team. Meaning for now i would like to test it by myself first.
thanks