NagiosXI Alert handler

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

NagiosXI Alert handler

Post 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?
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: NagiosXI Alert handler

Post 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).
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.
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: NagiosXI Alert handler

Post 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)
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: NagiosXI Alert handler

Post 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!
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: NagiosXI Alert handler

Post 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)?
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: NagiosXI Alert handler

Post 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.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: NagiosXI Alert handler

Post 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.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
Locked