Nagios Alerts :Custom

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.
Locked
LuisN
Posts: 40
Joined: Thu May 24, 2012 10:47 am

Nagios Alerts :Custom

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Nagios Alerts :Custom

Post 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?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
LuisN
Posts: 40
Joined: Thu May 24, 2012 10:47 am

Re: Nagios Alerts :Custom

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Nagios Alerts :Custom

Post by scottwilkerson »

You can modify your notification command to collect this external data and inject it into the message.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
LuisN
Posts: 40
Joined: Thu May 24, 2012 10:47 am

Re: Nagios Alerts :Custom

Post by LuisN »

Is there an example of such?
would i be able to run another command_line param ?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Nagios Alerts :Custom

Post 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.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
LuisN
Posts: 40
Joined: Thu May 24, 2012 10:47 am

Re: Nagios Alerts :Custom

Post by LuisN »

Yeah thats how i figured id do it. thanks for the confirmation!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Nagios Alerts :Custom

Post by scottwilkerson »

LuisN wrote:Yeah thats how i figured id do it. thanks for the confirmation!
Sounds good, locking thread
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked