Command.cfg, editing what is sent


I have searched this forum as well as Google, and haven’t been able to find the answer to my question.

I was wondering if you could have one email that is defined in commands.cfg send more information about the host. For instance, currently when we have a host down the email lists the hostname, I would like it to include the alias as well. I have played around with this, but haven’t been able to get it to work correctly. The reason why I want to include it in one defined command is to prevent multiple emails about the same host going down.

This is what my commands.cfg looks like

define command{
command_name notify-host-by-email
command_line /usr/bin/printf “%b” “Host: $HOSTNAME$ - $HOSTADDRESS$\nState: $HOSTSTATE$” | /bin/mail -s “** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ $Alias$ is $HOSTSTATE$ **” $CONTACTEMAIL$

define command{
command_name notify-service-by-email
command_line /usr/bin/printf “%b” “Service: $SERVICEDESC$\nHost: $HOSTNAME$ - $HOSTADDRESS$\nAdditional Info:\n$SERVICEOUTPUT$” | /bin/mail -s “** $NOTIFICATIONTYPE$ Service Alert: $HOSTNAME$-$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$

Example of one of my host.
define host{
use windows-server
host_name Test5
alias Test Alias
contact_groups networking

An email appears like this

** PROBLEM Host Alert: Test5 is DOWN **
Host: Test5 -
State: DOWN

What I would like is something similar to this,

** PROBLEM Host Alert: Test5 (TestAlias) is DOWN **
Host: Test5 (Test Alias) -
State: DOWN

Please Help. Thanks in advance.


check the MACROS section in the nagios docs… it should be there.



Thanks for the response. I assume you are referring to the following site: … #hostalias I see what it is telling me, but I am still unable to get the right combination to get it to send within one email.


command_line /usr/bin/printf “%b” “Host: $HOSTNAME$ ($HOSTALIAS$) - $HOSTADDRESS$\nState: $HOSTSTATE$” | /bin/mail -s “** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ ($HOSTALIAS$) is $HOSTSTATE$ **” $CONTACTEMAIL$

Hope this helps


[quote=“msmith4”]command_line /usr/bin/printf “%b” “Host: $HOSTNAME$ ($HOSTALIAS$) - $HOSTADDRESS$\nState: $HOSTSTATE$” | /bin/mail -s “** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ ($HOSTALIAS$) is $HOSTSTATE$ **” $CONTACTEMAIL$

Hope this helps[/quote]

that’s the one… thanks.
i couldn’t find it onòine and only had links to my own localhost server… would have been quite useless :slight_smile:


Thanks Guys, it works.