Page 1 of 1

$HOSTALIAS$ not displaying correctly in email notifications

Posted: Wed Jun 08, 2011 11:20 am
by HelpDesk
I've got Nagios Core v3.2.3 running on a CentOS machine. I have email notifications set up for a service. The notifications are coming through just fine however the "Host:" portion is wrong. This is what I receive:

***** Nagios *****

Notification Type: PROBLEM

Service: Check Web Site
Host: Virtual Development Site
Address: x.x.x.x
State: CRITICAL

Date/Time: Wed Jun 8 09:05:48 PDT 2011


And here is my host definition:

define host{
use linux-box
host_name devsite
alias Virtual Development Site (devsite)
parents switch1,switch2
address x.x.x.x
}


My question is in my email notification why doesn't Host: say "Virtual Development Site (devsite)"

Re: $HOSTALIAS$ not displaying correctly in email notificati

Posted: Wed Jun 08, 2011 2:34 pm
by mguthrie
Can you post your host notification command? It might be calling the $HOSTNAME$ macro instead of the $HOSTALIAS$.

Re: $HOSTALIAS$ not displaying correctly in email notificati

Posted: Wed Jun 08, 2011 4:42 pm
by HelpDesk
I think this is what you're asking for. Forgive me, I am but a Nagios newbie :)

# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}


I should explain what I want to happen. I want to receive an email when my Check Web Site service goes critical. If it goes critical then my httpd is down and I need to know about that. I don't really need any notification about the host itself, just the service. All I really want to do is make Host say "Host: Virtual Development Site (devsite)" because other people who get this email know the server as devsite. Thanks!

Re: $HOSTALIAS$ not displaying correctly in email notificati

Posted: Thu Jun 09, 2011 8:52 pm
by mguthrie
If you change out the $HOSTNAME$ macro with $HOSTALIAS$ this should give you what you need. You can disable host notifications, and also set the "notification_options" to "c" in the service definition, and that will make it so that you only receive notifications for the http service if it goes to a critical state.

Re: $HOSTALIAS$ not displaying correctly in email notificati

Posted: Fri Jun 10, 2011 1:00 pm
by HelpDesk
Thank you for your reply. I am receiving critical service emails, not host emails. This is exactly what I want. The notify-host-by-email command has nothing to do with what I'm doing here. I'm only concerned with notify-service-by-email. And I verified this. In notify-service-by-email I changed $HOSTALIAS$ to $HOSTNAME$ and this is what I got:

***** Nagios *****

Notification Type: PROBLEM

Service: Check Web Site
Host: devsite
Address: x.x.x.x
State: CRITICAL


Exactly what I expected. It displays the name of the host. I changed $HOSTNAME$ back to $HOSTALIAS$ and I get "Host: Virtual Development Site" even though this is what my host config looks like:

define host{
use linux-box
host_name devsite
alias Virtual Development Site (devsite)
parents switch1, switch2
address x.x.x.x
}


I can change alias to anything and it doesn't update. I changed it to "I AM AWESOME" and it still displays "Host: Virtual Development Site." What gives?!

Re: $HOSTALIAS$ not displaying correctly in email notificati

Posted: Tue Jun 14, 2011 3:04 am
by bushi
See http://support.nagios.com/forum/viewtop ... f=7&t=2304

@mguthrie - will this bug be fixed?

Re: $HOSTALIAS$ not displaying correctly in email notificati

Posted: Tue Jun 14, 2011 3:16 pm
by HelpDesk
Heyyy! It worked! Thanks for that. Except it removed all my info regarding enabled/disabled notifications on hosts and services. I had to go and set those all over again on every host which kinda sucked. I can't use the global "Notifications Disabled" button on the Tactical Overview page because I need notifications on only 1 service per host, not even the host itself. Setting all that up manually is a bit of a pain so if anyone has any ideas I'm all ears!

Also, when's that bug getting fixed? I'm running 3.2.3 which I believe is the latest.