Page 1 of 1

Nagios Alerts :Custom

Posted: Wed Feb 06, 2019 2:00 pm
by LuisN
tried the old google search nothing really comes up. is there a way to get an alert pull data from a different location for info? ex servers info not just IP, service down, name etc

Re: Nagios Alerts :Custom

Posted: Wed Feb 06, 2019 2:19 pm
by scottwilkerson
LuisN wrote:tried the old google search nothing really comes up. is there a way to get an alert pull data from a different location for info? ex servers info not just IP, service down, name etc
What type of information are you looking for?

Re: Nagios Alerts :Custom

Posted: Wed Feb 06, 2019 2:28 pm
by LuisN
I am currently setting up a dev env where we use DCIM app for host information - contact info thats updated on the fly, metric data URL that is on a different system ( not using perf data ) , and insert graphical data from a different source as well. i have API's in all the other platforms , just looking to see if i can utilize that info all in 1 Notification

Re: Nagios Alerts :Custom

Posted: Wed Feb 06, 2019 2:39 pm
by scottwilkerson
You can modify your notification command to collect this external data and inject it into the message.

Re: Nagios Alerts :Custom

Posted: Wed Feb 06, 2019 2:41 pm
by LuisN
Is there an example of such?
would i be able to run another command_line param ?

Re: Nagios Alerts :Custom

Posted: Wed Feb 06, 2019 2:56 pm
by scottwilkerson
So the default notification command looks something like this

Code: Select all

define command {
    command_name    notify-host-by-email
    command_line    /usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
You can change this to run your own script, such as

Code: Select all

define command {
    command_name    notify-host-by-email
    command_line    /path/to/your/custom/handler.sh "$NOTIFICATIONTYPE$" "$HOSTNAME$" "$HOSTSTATE$" "$HOSTADDRESS$" "$HOSTOUTPUT" "$LONGDATETIME$" "$CONTACTEMAIL$"
}
Then inside of /path/to/your/custom/handler.sh you parse the arguments passed from nagios, and add in whatever you need to collect the other information from the external system.

Re: Nagios Alerts :Custom

Posted: Wed Feb 06, 2019 3:06 pm
by LuisN
Yeah thats how i figured id do it. thanks for the confirmation!

Re: Nagios Alerts :Custom

Posted: Wed Feb 06, 2019 3:11 pm
by scottwilkerson
LuisN wrote:Yeah thats how i figured id do it. thanks for the confirmation!
Sounds good, locking thread