I am using nagios, and when I get alerts, the body contaions only a $ instead of the information about the alert. My mail server is qmail.
This is the format of the definition in the misccommands.cfg
‘notify-by-email’ command definition
define command{
command_name notify-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: $DATETIME$\n\nAdditional Info:\n\n$OUTPUT$" | /bin/mail -s " $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$
}
So, try the command by hand, and see what you get. You can modify the command by changing the $whatever variable to something like this is hostaddress.
In other words change the above from $NOTIFICATIONTYPE$ to NOTIFICATIONTYPEtest and $SERVICEDESC$ to servicedesctest etc and so on. You should get an email with the text you supply. Remember, I’m not saying to change your .cfg file definition, just suggesting that you first run the command from a linux command line, and substitute real words and not variables, just to make sure it works like that. If it does, then we can t’shoot further and see where it breaks.
Edited Fri Sep 16 2005, 10:20AM ]
Awesome, thanks. I’ll fix it up now.
Ok, so this is working now, what I did was copy the declaration in /etc/nagios/misccommands.cfg in to command-plugins.cfg and it worked – I am not sure why it was using command-plugins.cfg or what was wrong with the original, but this is the before and after:
before:
command_line /usr/bin/printf “$OUTPUT$” | /bin/mail -s ‘$SERVICESTATE$ alert for $HOSTALIAS$/$SERVICEDESC$’ $CONTACTEMAIL$
after:
command_line /usr/bin/printf “%b” “***** Nagios ***\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $DATETIME$\n\nAdditional Info:\n\n$OUTPUT$" | /bin/mail -s " $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$