Page 1 of 1
NagiosXI Alert handler
Posted: Mon Dec 16, 2013 11:31 am
by BanditBBS
Ok, I want to change the way i handle on-call rotation so I don't have to "apply configuration" in nagios every day.
Is there a way to call and use the XI Notification handler from command line? Like if I know the contact and all the other information, can I pass it onto some php to send the alert?
Re: NagiosXI Alert handler
Posted: Mon Dec 16, 2013 11:48 am
by abrist
It is funny you ask this as Scott just wrote new php notification handlers that use the XI mail settings but can be used with core contacts. You could create your own script that essentaily calls the new notification handler with macros of your choice (like the $CONTACTEMAIL).
Re: NagiosXI Alert handler
Posted: Mon Dec 16, 2013 3:20 pm
by BanditBBS
I can definitely see this being very useful but not a perfect fit for what I wanted. I could use it, but it would remove from functionality for me. I'd like to create a script that is passed all the proper information, it figures out what XI user to actually notify and then passes that information back into XI so the user's settings are used(sms, time of day, blah blah blah)
Re: NagiosXI Alert handler
Posted: Mon Dec 16, 2013 3:40 pm
by BanditBBS
I guess I'm an idiot. I can just use the handle_nagioscore_notification.php script that is already being used and just wrap it with my custom script. Close this, no, keep it open, I'll update with a much better on call rotation handling then what I did in the past that is much cleaner and requires no nagios restart.
EDIT: no, this still isn't perfect...OMG, now I understand why you don't include this feature!
Re: NagiosXI Alert handler
Posted: Mon Dec 16, 2013 3:53 pm
by BanditBBS
Let me ask this question:
currently by defualt there is this command for contacts host commands in XI:
Code: Select all
/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$"
Does that one command handle email and sms? If I call that script and supply it all that information form the command line, would it obey what the user has set on their account (i.e only during certain hours, no flapping alerts, no email only sms, etc)?
Re: NagiosXI Alert handler
Posted: Mon Dec 16, 2013 8:31 pm
by scottwilkerson
BanditBBS wrote:
Does that one command handle email and sms?
Kind of... It just creates an event, then the eventman cron processes these events, looks up the users settings (mail, sms, time limitations, custom message template, etc.) then the message is sent using these, if need be.
Re: NagiosXI Alert handler
Posted: Mon Dec 16, 2013 8:39 pm
by BanditBBS
scottwilkerson wrote:BanditBBS wrote:
Does that one command handle email and sms?
Kind of... It just creates an event, then the eventman cron processes these events, looks up the users settings (mail, sms, time limitations, custom message template, etc.) then the message is sent using these, if need be.
Ok, good. I did not understand that process, now that it has been explained, I think I can get this to work rather easily. God is my dev server going to be a Frankenstein after the mods I'm testing
Scott, or whoever, feel free to close this. I'll post my finished new on-call handling as a new post/to the exchange when I am done.