Including LCON info in notifications
- snapon_admin
- Posts: 952
- Joined: Mon Jun 10, 2013 10:39 am
- Location: Kenosha, WI
- Contact:
Including LCON info in notifications
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!
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
You can set up and custom notification macro, for example:
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
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."Code: Select all
--lcon="$_HOSTLCON$"Code: Select all
LCON: %lcon%http://assets.nagios.com/downloads/nagi ... iables.pdf
Be sure to check out our Knowledgebase for helpful articles and solutions!
- snapon_admin
- Posts: 952
- Joined: Mon Jun 10, 2013 10:39 am
- Location: Kenosha, WI
- Contact:
Re: Including LCON info in notifications
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
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!
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."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!
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Including LCON info in notifications
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)
you would have to craft the script to lookup the host and determine who the contact is, then in you message you would put
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$`"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."-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Including LCON info in notifications
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.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
- snapon_admin
- Posts: 952
- Joined: Mon Jun 10, 2013 10:39 am
- Location: Kenosha, WI
- Contact:
Re: Including LCON info in notifications
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.
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Including LCON info in notifications
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.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
- snapon_admin
- Posts: 952
- Joined: Mon Jun 10, 2013 10:39 am
- Location: Kenosha, WI
- Contact:
Re: Including LCON info in notifications
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!
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Including LCON info in notifications
You are welcome! I am going to lock this up for now, if you need assistance again definitely open up a new thread!
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.