I am using version 2.0 last modified 2-7-2006.
The notification by e-mail doesn’t have the $SERVICEOUTPUT$. Here is my misccommands.cf entry:
‘notify-by-email’ command definition
define command{
command_name notify-by-email
command_line /usr/bin/printf “%b” “***** Nagios ***\n\nNotificat
ion Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAdd
ress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdd
itional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/mail -s " $NOTIFICATIONTYPE$ al
ert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$
}
(The above is one continuous line.)
How do I troubleshoot this? I know the service commands are producing output because I see it on the web pages.
Thanks for any direction on how to solve this.
Mike B.
some interesting information…
I changed the command to say:
define command{
command_name test-notify-by-email
command_line /usr/bin/printf “%b” “***** TEST *****\n\nAdditional
Info: $SERVICESTATE$\n\n$SERVICEOUTPUT$ \n\nafter: $SERVICESTATE$” | /usr/bi
n/mail -s " $SERVICESTATE$ " $CONTACTEMAIL$
}
and now the SERVICEOUTPUT variable is shown, but the after part does not…what would be causing that?
Mike B.
SOLVED!
It looks like you just need to ensure that the varialbe $SERVICEOUTPUT$ has a space, newline, or other text. For example:
BAD FORMAT
define command{
command_name test-notify-by-email
command_line /usr/bin/printf “%b” “***** TEST *****\n\nAdditional
Info: $SERVICESTATE$\n\n$SERVICEOUTPUT$” | /usr/bin/mail -s " $SERVICESTATE$ "
$CONTACTEMAIL$
}
GOOD FORMAT
define command{
command_name test-notify-by-email
command_line /usr/bin/printf “%b” “***** TEST *****\n\nAdditional
Info: $SERVICESTATE$\n\n$SERVICEOUTPUT$\n” | /usr/bin/mail -s " $SERVICESTATE$ "
$CONTACTEMAIL$
}
Notice the newline after $SERVICEOUTPUT$.
Maybe that’s a bug?
Also, it means the misccommands.cfg-sample notify-by-email is broken.
Thanks for listening! 
It’s not a bug, it’s how you send mail when using the “mail” command.
If doing it by hand, you send mail with a CTRL-D at the end of a “NEW LINE”. So, that’s why you need the \n
Thanks. That makes sense.
Interestingly, adding a space after $SERVICEOUTPUT$ also worked even though there weren’t any new lines.
Mike B.
I see, I was wondering about that, since my command only had a space.