[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

dat attachment in email alert



This isn't a question but I am just submitting to the list that when using
the linux 'mail' as most people do, it will sometimes send emails with blank
body's and the actual content in a subject_line.dat file. This is due to
carriage returns not being stripped from certain alert output (like HTTP or
CPU status from Windows machines). The 'mail' command does not know how to
deal with this and will not send properly.

To get rid of this issue you need to create a custom alert script and pipe
the output through translate to remove any carriage returns (because they
are not native to *nix ascii text). An simple example would be (\015
represents a CR):

echo -e "STATUS: RECOVERED\nDATE: `date`\nSYSTEM: $BBHOSTSVC\nDURATION:
$DOWNSECS\nINFO: $BBH_DESCRIPTION\n\n--\n\n$BBALPHAMSG\n\n" | tr -d '\015' |
/usr/bin/mail -s "RECOVERED: $BBHOSTSVC" $RCPT

OR more simply

echo "alert body whatever you want" | tr -d '\015' | /usr/bin/mail -s
"subject of email" recipient_of_email

The important part is the [ tr -d '\015' ] to delete all CR's in the message
before it's piped to mail.