2 notification method,

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.
liangwh
Posts: 23
Joined: Mon Mar 31, 2014 12:14 am

2 notification method,

Post 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
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: 2 notification method,

Post 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
liangwh
Posts: 23
Joined: Mon Mar 31, 2014 12:14 am

Re: 2 notification method,

Post 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
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: 2 notification method,

Post 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.
Former Nagios employee
https://www.mcapra.com/
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: 2 notification method,

Post 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.
liangwh
Posts: 23
Joined: Mon Mar 31, 2014 12:14 am

Re: 2 notification method,

Post 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
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: 2 notification method,

Post 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.
liangwh
Posts: 23
Joined: Mon Mar 31, 2014 12:14 am

Re: 2 notification method,

Post 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
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: 2 notification method,

Post 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.
liangwh
Posts: 23
Joined: Mon Mar 31, 2014 12:14 am

Re: 2 notification method,

Post 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
Locked