Escape \ in nagios config files?
Kevin Keane
subscription at kkeane.com
Tue Apr 7 00:17:28 CEST 2009
Actually, this is not just in Nagios; this is standard Unix escaping.
And it's not really 3 \. Rather, what is going on is that standard Unix
escaping is applied twice - first when parsing the config file, and
again when passing the arguments to the plugin.
In Unix, normally when you put a \ anywhere, it escapes the following
character. For instance, a \ before a space means "the next character
isn't really a space, don't treat it as the end of the path". And a \
before a \ means "the second backslash isn't really an escape character,
but rather I want a literal backslash". So in order to get a single \ in
the plugin, on the command line you need to escape it with another \.
You found that out when you ran check_nrpe2 from the command line.
Now when Nagios parses the config file, it uses the same escaping
mechanism. So when you simply put \\ into the config file, Nagios
interprets the first one as "escape" and the second one as "escaped to
be literal" - thus, you'd end up with a single \ in the command line.
But you wanted two \. So you need to tell Nagios to do the same thing
twice: \\\\ -> \\ in the command line -> \ for the plugin to see.
And where you needed the plugin to actually see \\ (before the
localhost), you need to do the same thing yet again, for a total of
eight consecutive backslashes.
Janet Sullivan wrote:
> Of course, right after I sent that, I found a solution. It seems I can
> use 3 \s to escape a \. My path in the service definition becomes:
>
> \\\\\\\\localhost\\\\_definst_\\\\mp3\\\\mn_mp3_08_07\\\\streams
>
> ...and it works.
>
> Is there a list of all the ways to escape special characters in Nagios?
> The only reason I came up with the three \ escape sequence was because I
> noticed that my \\\\localhost was being seen as \localhost in the error
> message. I haven't found any mention of that sequence on google. :-/
>
> -----Original Message-----
> From: Janet Sullivan
> Sent: Monday, April 06, 2009 1:56 PM
> To: 'nagios-users at lists.sourceforge.net'
> Subject: Escape \ in nagios config files?
>
> I want to check the disk space of a UNC path -
> \\localhost\_definst_\mp3\mn_mp3_08_07\streams
>
> >From the command line, I can check it fine (using check_nrpe2) if I
> escape each \ like this:
>
> \\\\localhost\\_definst_\\mp3\\mn_mp3_08_07\\streams
>
> But when I try to use configure Nagios to check it, it strips out all
> the \ characters. I've tried single quotes, double quotes, and escaping
> each \ - no luck. How can I tell Nagios about this path in a service
> definition without it stripping out the special characters? Is there an
> escape method I'm missing?
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> High Quality Requirements in a Collaborative Environment.
> Download a free trial of Rational Requirements Composer Now!
> http://p.sf.net/sfu/www-ibm-com
> _______________________________________________
> 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
>
--
Kevin Keane
Owner
The NetTech
Find the Uncommon: Expert Solutions for a Network You Never Have to Think About
Office: 866-642-7116
http://www.4nettech.com
This e-mail and attachments, if any, may contain confidential and/or proprietary information. Please be advised that the unauthorized use or disclosure of the information is strictly prohibited. The information herein is intended only for use by the intended recipient(s) named above. If you have received this transmission in error, please notify the sender immediately and permanently delete the e-mail and any copies, printouts or attachments thereof.
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
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