Page 1 of 1

backslash in plugin response

Posted: Wed Jul 25, 2012 3:05 am
by gdeber
Hi everyone!
I'm a nagios happy user from Italy.
My centos server is running nagios core v3.4.1 and i'm using check_disk_smb plugin to check share free disk space. At some point in past plugin output change from:

Code: Select all

Disk ok - 3.8G (1%) free on 10.41.186.10 share: Dati
to:

Code: Select all

 Only 4.46G (1%) free on \\10.41.186.10\Dati
additional backslash in response message create a problem with service notification command because printf "%b" takes "\\10." and convert it as octal code (i think) and sendmail sent it as attachment.

Here is my command configuration:

Code: Select all

define command{
        command_name    notify-service-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: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n\n$NOTIFICATIONCOMMENT$" | /bin/mail -s"** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
        }
modify plugin's code doesn't seem the definitive solution.
There's a way to prevent this kind of problem in nagios side?

Thank you.
Bye
Debe

Re: backslash in plugin response

Posted: Wed Jul 25, 2012 9:31 am
by agriffin
You could just %b to %s. That might introduce other subtle bugs, though (nothing serious, you'll just notice notification text that's a little off). Unfortunately it can be hard to get quoting right in Nagios sometimes, since everything is always passed straight to a shell.

Re: backslash in plugin response

Posted: Wed Jul 25, 2012 9:50 am
by gdeber
Unfortunately, in that way, printf ignore all escape char, so also \n doesn't work anymore...
Seems that modify plugin code is the only solution.

anyway Thanx for the support!
Debe

Re: backslash in plugin response

Posted: Wed Jul 25, 2012 9:56 am
by agriffin
No problem, sorry there wasn't an easier solution.