Page 1 of 1

Notification Variable Question

Posted: Mon Jun 22, 2015 2:11 pm
by derekb
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

Re: Notification Variable Question

Posted: Mon Jun 22, 2015 3:52 pm
by jdalrymple
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.

Re: Notification Variable Question

Posted: Mon Jun 22, 2015 4:11 pm
by derekb
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

Posted: Tue Jun 23, 2015 11:23 am
by tmcdonald
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.

Re: Notification Variable Question

Posted: Tue Jun 23, 2015 12:32 pm
by derekb
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.
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.

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

Posted: Tue Jun 23, 2015 4:44 pm
by tmcdonald
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%".

Re: Notification Variable Question

Posted: Sun Jun 28, 2015 3:27 pm
by derekb
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%".
Yep, that does work.

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

Posted: Sun Jun 28, 2015 8:38 pm
by derekb
Figured this out. Had my host group hierarchy all wrong. Works as expected now