passing arguments with spaces

Litwin, Matthew mlitwin at stubhub.com
Fri Sep 11 22:06:13 CEST 2009


I am having the same problem as you and tried what you suggest but I am
getting this error when I try the double backslash:

 

Sep 11 20:02:02 sjvp00dbs001.stubhub.com Sep 11 20:02:02 nrpe[4988]: [ID
494588 daemon.error] Error: Request contained illegal metachars!

 

Did you encounter this?

 

________________________________

From: Noel Platzke [mailto:neufpas at gmail.com] 
Sent: Friday, September 11, 2009 8:11 AM
To: nagios List
Subject: Re: [Nagios-users] passing arguments with spaces

 

I managed to figure this out with what I'm considering to be a terrible
hack. When the arguments are passed from the service definition to the
command, escaped characters are translated into their unescaped form. So
when I try to pass the argument "this\ is\ a\ string" it becomes "this
is a string" when it's passed to the command. And from there it gets
passed to my script which fails to parse it as a single argument. To
address this, I'm passing the string "this\\ is\\ a\\ string" so that
the first time it gets passed the escaped backslashes are translated
into regular backslashes and then it passes escapes spaces.

Hopefully this will be useful to someone else.



On Fri, Sep 11, 2009 at 10:26 AM, Noel Platzke <neufpas at gmail.com>
wrote:

It still doesn't work. I've tried single quotes, double quotes, escaping
the quotes, escaping the spaces. Somewhere along the line nagios is
stripping things out that need to be passed to the script.






On Thu, Sep 10, 2009 at 5:29 PM, Marc Powell <marc at ena.com> wrote:


On Sep 10, 2009, at 3:14 PM, Noel Platzke wrote:

> I've tried everything possible.
> I am completely lost.
> I want to throw my keyboard through a window.
> How in god's name do I get nagios to accept an argument that
> includes spaces?
>
> I have a service that uses the check_by_ssh plugin to run a script
> on a remote server. The script takes an argument that is wrapped in
> quotes and can potentially contain spaces.

> So I defined a new command...
>
> command_name        my_custom_script
> command_line           /usr/lib/nagios/plugins/check_by_ssh -H
> $HOSTADDRESS --command="/my/custom/script '$ARG1$'"
>
> and set up a new service...
>
> my_custom_script!"this is my argument"

Don't use quotes here. You're effectively canceling the quotes you
have above, leaving the arguments with spaces bare. The command line
that nagios is trying to run as a result is --

/usr/lib/nagios/plugins/check_by_ssh -H <someaddress> --command="/my/
custom/script '"this is my argument"'"

--
Marc


------------------------------------------------------------------------
------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008
30-Day
trial. Simplify your report design, integration and deployment - and
focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
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

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20090911/48a7046c/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
-------------- next part --------------
_______________________________________________
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