Page 1 of 1
Including LCON info in notifications
Posted: Wed Jul 17, 2013 8:58 am
by snapon_admin
I feel like I'm close to figuring this out, but before I give myself some sort of aneurysm, I figured I'd post here to see if I'm making this harder than it is. What I'm trying to do is configure host notifications in a way that they will include the information for the Local contact at the location where that host lives. Here's a little more detail about what I'm trying to do with some of the details on names changed just for clarity:
hostname: switch1
location: chicago
local contact info (listed as monitoring contact for host): contact: RS6449 contact alias: Rusty Shackleford contact address 1: 867-5309 (no need for address so I used phone number here)
contact group: network admins (includes 3 users that are not the same as the LCON), operations
Now, what I'm looking to do, is include the LCON's (Rusty Shackleford) information in the notification email for this host. Since our operations team gets the emails as well, and they operate 24/7/365, it would eliminate middle of the night calls to our network admins if we could include a line in the notification email that looks like
"Nagios has detected that switch1 is down. Please contact the local contact, Rusty Shackleford, at 867-5309 to verify that there is power at the site."
I am having a heck of a time getting this to work. If there is an easy way to do this I would love some guidance on that. Thanks!
Re: Including LCON info in notifications
Posted: Wed Jul 17, 2013 11:02 am
by lmiltchev
You can set up and custom notification macro, for example:
Code: Select all
Variable name: _LCON
Variable value: "Nagios has detected that switch1 is down. Please contact the local contact, Rusty Shackleford, at 867-5309 to verify that there is power at the site."
Modify the command (the notification handler you are using for this host/service) by adding at the end:
Then add a line under "Notification Messages":
Please, review how to customize your notification messages here:
http://assets.nagios.com/downloads/nagi ... iables.pdf
Re: Including LCON info in notifications
Posted: Wed Jul 17, 2013 12:43 pm
by snapon_admin
Would I have to do a separate Macro for each site, then, since it's a different LCON at each site? Or is there a way to make the variable value something like
Code: Select all
"Nagios has detected that %host% is down. Please contact the local contact, %contact%, at %contactnumber% to verify that there is power at the site."
so that it's dependant on whoever is assigned as the contact for a particular site? Currently if I use %contact% and %contactnumber% it will put the recipient of the message in for that, which is somewhat pointless since they're the ones receiving the email. So if the email was sent to Rusty, it would say to contact Rusty, if it was sent to me, it would say to contact me, etc.
I'm looking for a way to use variables to automatically call up a site contact and put that into an email notification, without having to make a custom variable for every single host (since that would be almost a thousand hosts). I'm not sure if what you're suggesting would do that or if it still requires a separate variable for each host. Thanks for your help!
Re: Including LCON info in notifications
Posted: Wed Jul 17, 2013 1:34 pm
by scottwilkerson
It is going to come down to Nagios will need to know who the contact information is for each host.
The free variables that abrist mentioned is one way to do it.
another way to do it would be to have a script the you can pass the hostname to (in the notification command) and have it print the output
like this (assumes you have created /tmp/get_lcon.sh)
Code: Select all
--lcon="`/tmp/get_lcon.sh $HOSTNAME$`"
you would have to craft the script to lookup the host and determine who the contact is, then in you message you would put
Code: Select all
"Nagios has detected that %host% is down. Please contact the local contact, %lcon% to verify that there is power at the site."
Re: Including LCON info in notifications
Posted: Wed Jul 17, 2013 1:47 pm
by sreinhardt
Unless I am missing it, which is possible, I don't see a local contact type setting available by default. If there is please point it out and I will look further into the notification options\macros. Otherwise you would be correct that you will need to create a custom variable for each and use the same name for them. I did look into the bulk modification tool to see if that could be done in groups for you, however it doesn't seem to allow free variable modification, I will have to discuss this as a modification. You may be should be able to define a template for each location that you can then define for your objects. Yes it will still be a fair amount of work, but you can then easily modify locations in the future and add to other objects as the need arises.
Re: Including LCON info in notifications
Posted: Wed Jul 17, 2013 2:33 pm
by snapon_admin
Well most of our contacts for corporate IT will be in contact groups (network admins, Unix admins, Windows admins, Operationsetc.). There is also a contact option, where you can assign an individual contact and, since all the other IT groups will be receiving their notifications by way of contact groups, my plan was to add each site's LCON as a monitoring contact, separate from the contact groups, and then use that to somehow attach to the host notifications. That way, contact group "Operations" would get an email alert at, say 1 am, that a router in Chicago or wherever has gone down and the alert would use be able to specify who the LCON for that site was so they know who to call first to verify if there is power, something the network admin team wouldn't be able to do anyway, as they are not located in chicago.
Re: Including LCON info in notifications
Posted: Thu Jul 18, 2013 10:33 am
by sreinhardt
AH I see, so you wanted a way to differentiate the single contact from contact groups. Unfortunately as you already stated, the contact macros are specific to the user being sent the notification, not the message as whole. I think the options presented above, either writing a secondary script to handle this, or using templates\groups with free variables is about the best way to handle it.
Re: Including LCON info in notifications
Posted: Thu Jul 18, 2013 11:26 am
by snapon_admin
I agree. It'll be a pain to get it in for every host, but only for the first time I have to add it. And at least I know there's a way to (sort of) do what I want. Thanks for all the info!
Re: Including LCON info in notifications
Posted: Thu Jul 18, 2013 2:08 pm
by sreinhardt
You are welcome! I am going to lock this up for now, if you need assistance again definitely open up a new thread!