Hi there,
I've in the processing of sorting all of my hosts into their respective Host Groups right now. While I am making the host groups, I have populated the Hostgroup "Description" field with the Customer/Site address, and the "Notes URL" field with a URL that links to the company/site page within my Sharepoint library.
I'd like to pass these fields as variables in the email notification for when a host alert is generated, but in reading the notifications variable document, I cannot seem to come up with a way to pass host group fields as variables.
This is the doc I'm referring to:
https://assets.nagios.com/downloads/nag ... iables.pdf
Notification Variable Question
-
jdalrymple
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Notification Variable Question
Hostgroups secondary purpose is for sorting. The primary purpose is to form linkage between services and hosts from a host perspective. Without hostgroups, the only place you can define a host for a service is in the service definition. This way you can define a service for a host within the host definition.
What you need to do is create templates for your geographical locations - assign them to the proper hosts, and withing that template you can also define the hostgroup for organizational purposes if you see fit.
What you need to do is create templates for your geographical locations - assign them to the proper hosts, and withing that template you can also define the hostgroup for organizational purposes if you see fit.
Re: Notification Variable Question
What is the purpose of the notes URL and action URL fields on the host group definition then? I guess I don't understand the use of those fields correctly.
Re: Notification Variable Question
Basically the same as with a host - to provide a link to information about that hostgroup, and a URL that might have a relevant action. They are more often used for individual hosts, but I could see a case where you might have a Production and Development hostgroup, and each will have different notes on how to handle certain problems.
Former Nagios employee
Re: Notification Variable Question
That was my understanding as well. But with a host, I can populate the Notes URL and pass it as a variable in an email notification. With a hostgroup, I cannot.tmcdonald wrote:Basically the same as with a host - to provide a link to information about that hostgroup, and a URL that might have a relevant action. They are more often used for individual hosts, but I could see a case where you might have a Production and Development hostgroup, and each will have different notes on how to handle certain problems.
My logic was this:
Create a hostgroup for Customer A, populate notes URL etc in the host group that sends me to a page that displays all of their assets, address info etc and pass it as a variable in an alert notification, so my technicians have all that information handy without having to login to Nagios to obtain it. This way, if any host within that hostgroup generated an alert, information common to the hosts (aka the information I've populated in the hostgroup) would be passed along in the alert.
Am I just crazy, or does this seem like a valid train of thought? The idea of using the templates to populate the same info over and over and over again for multiple hosts seems overly redundant and unnecessary.
Re: Notification Variable Question
That really should work. What do you have for your notification command that this cannot be passed through? You should just need something like "--hostgroupnotes=$HOSTGROUPNOTES$" and then references it in your email template as "%hostgroupnotes%".
Former Nagios employee
Re: Notification Variable Question
Yep, that does work.tmcdonald wrote:That really should work. What do you have for your notification command that this cannot be passed through? You should just need something like "--hostgroupnotes=$HOSTGROUPNOTES$" and then references it in your email template as "%hostgroupnotes%".
However, how can I handle this if the host is a member of 2 hostgroups?
For example: We're a small ISP, so I have a Hostgroup called "DSL Customers" and then each business that pays us for monitoring has their own hostgroup. NAGIOS take the primary hostgroup and pass it in the hostgroupalias variables, etc. How do I determine what is considered as the 'primary' hostgroup? I've tried removing the host from both groups, adding it to the one I Want to report on, then adding it to the second hostgroup, but that did not work.
Re: Notification Variable Question
Figured this out. Had my host group hierarchy all wrong. Works as expected now