Backslash problems in notifications

HENSHAW Brad Brad.Henshaw at qbuild.qld.gov.au
Thu Feb 10 04:34:05 CET 2005


This one has me stumped.

I have nagios configured to send e-mail alerts to various staff when
certain host and service issues arise.
One problem I've encountered however is a complication with dealing with
the output of check_disk_smb in that its output looks something like
this:

CRITICAL: Only 1.74G (5%) free on \\10.x.x.x\d$

The relevant line in misccommands.cfg looks something like this:

command_line    /usr/bin/printf "%b" "Alert\n-----------------\n\nIssue:
$NOTIFICATIONTYPE - $SERVICEDESC$ on $HOSTNAME$ ($HOSTALIAS$) is
$SERVICESTATE$\n\nDate/Time: $DATETIME$\n\nAdditional
Info:\n$OUTPUT$\n\n---\nBlah blah blah" | /usr/bin/mail -s "**
$NOTIFICATIONTYPE$ - $HOSTNAME$/$SERVICEDESC$ status is $SERVICESTATE$
**" -a "X-Priority: 1 (Highest)" $CONTACTEMAIL$

Now, for most alerts this works fine. But for the disk space alerts,
printf looks at the backslash followed by a one and reports it as being
an invalid escape sequence. The e-mail comes through but is truncated
from the word "on", thus blasting away the last half of the alert
message.

I had thought of piping the text to sed and doing a substitution on
backslashes followed by certain characters before passing to printf, but
I can't think of a way to do this since `echo` (which I could pipe to
sed) breaks in a similar fashion.

Has anyone figured out a way to deal with backslashes in command output
which screw up printf? (other than by modifying check_disk_smb)

Any input is appreciated!

Regards,
Brad

#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared 
by MailMarshal
For more information please visit www.marshalsoftware.com
#####################################################################################

#############################################################################
This electronic message and any attachments are supplied in good faith. 
QBuild accepts no responsibility for the damage or loss which may occur 
through the use or transmission of this message and attachments.

The contents of this electronic message and any attachments are intended
only for the addressee and may contain privileged or confidential information. 
If you are not the addressee, you are notified that any transmission, distribution, 
downloading, printing or photocopying of the contents of this message or attachments 
is strictly prohibited. The privilege of confidentiality attached to this message and 
attachments is not waived, lost or destroyed by reason of mistaken delivery to you. 

If you receive this message in error please notify the sender by return e-mail or telephone.
##############################################################################


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list