Page 1 of 1

Adding host groups to the email subject / body

Posted: Tue Feb 03, 2015 9:09 pm
by tonyleatwork
Hi -

Our helpdesk uses host groups to properly assess the system's SLA and corrective action as part of their escalation procedure. Is there a way to display all of the host groups that a particular host is a part of ?

Re: Adding host groups to the email subject / body

Posted: Tue Feb 03, 2015 9:44 pm
by Box293
You should be able to use the macro $HOSTGROUPNAMES$ for this:

Code: Select all

http://nagios.sourceforge.net/docs/3_0/macrolist.html#hostgroupnames

Re: Adding host groups to the email subject / body

Posted: Tue Feb 03, 2015 11:26 pm
by tonyleatwork
Thanks. I just made changes to my email template and clicked "set as default"

I noticed the variables used there are with % while this macro uses $ sign.

I specified both:

$HOSTGROUPNAMES$ and %HOSTGROUPNAMES% just in case.

Re: Adding host groups to the email subject / body

Posted: Wed Feb 04, 2015 12:21 am
by tonyleatwork
Didn't work :(

Can these macros work inside notifications?

Here is what I got as a notification (look at the bottom)

Code: Select all

***** Nagios XI Alert *****

Nagios has detected this service has recovered.

Notification Type: RECOVERY

Service: /boot Disk Usage
Host: nwd2op5.corp.analog.com
Address: nwd2op5.corp.analog.com
State: OK
Info:
DISK OK - free space: /boot 425 MB (92% inode=99%):
Date/Time: 2015-02-04 00:20:01

Respond: http://nwd2ng01.corp.analog.com/nagiosxi/rr.php?uid=49-8527-0d7d78f060b30bbb5ed6e3fdb8465c24
Nagios URL: http://nwd2ng01.corp.analog.com/nagiosxi/

Host is part of the hostgroups:

$HOSTGROUPNAMES$ %HOSTGROUPNAMES% 

Re: Adding host groups to the email subject / body

Posted: Wed Feb 04, 2015 12:39 am
by tonyleatwork
Ok - I googled Nagios XI notifications and I guess you wanted me to add that macro to the email event handler. I just tried that and I'm waiting for the system to kick me an email from an alert (I have really high load but thats a separate issue). Will report back with the results.

Re: Adding host groups to the email subject / body

Posted: Wed Feb 04, 2015 1:03 am
by tonyleatwork
It worked! In the future, if you can dumb it down for me I'd greatly appreciate it :D
  • Step 1 - Find the macro you want from this list
    Step 2 - Assign the macro to the command (Nagios CCM > Command > xi_host_notification_handler and xi_service_notification_handler)
    Step 2b - Assign a macro to a variable by giving the variable the name you want and the macro as the source - i.e. --hostgroupnames=$HOSTGROUPNAMES$ - detailed here: http://assets.nagios.com/downloads/nagi ... iables.pdf
    Step 3 - Modify your notifications in Admin > Notification Management to include your new variable (in my case %hostgroupnames% - CASE SENSITIVE!!)

Re: Adding host groups to the email subject / body

Posted: Wed Feb 04, 2015 9:34 am
by cmerchant
We'll go ahead and close the thread. Thanks.