'$' symbol being appended to command_line?
Marc Powell
marc at ena.com
Wed Jan 7 05:56:13 CET 2009
On Jan 6, 2009, at 10:16 PM, Alexis Hazell wrote:
> Hi all,
>
> i've been having major problems getting email notifications to work
> with nagios 3.0.6 on Mandriva Linux 2009.0. As part of my attempts
> to isolate the problem, i've modified commands.cfg thus:
>
> 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$"
> | cat > /var/log/nagios/mail-$(date +%k:%M.%N).log
> }
>
> This produces the required .log file with the request contents -
> but oddly, the name of the file has an '$' symbol appended to it. If
> '$' is being appended to the end of the command line, that might
> well explain why email notifications aren't working:
This is only happening in your test case because you have an
unbalanced, un-escaped $ in the command_line (/var/log/nagios/mail-$
(date...)) Nagios uses $'s as macro boundaries. To use a literal $ in
a command_line, use $$ instead. (/var/log/nagios/mail-$$(date...)).
As for your notification problem, does nagios.log show a notification
being sent? Does your mail log on the nagios host show the message
being received and then sent further on? Can you run the command_line
above, substituting in reasonable values for the $MACROS$, as the
nagios user successfully?
--
Marc
------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
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