Nagios strips quotes from command arguments
Paul Lathrop
paul at zicasso.com
Fri Dec 14 23:12:08 CET 2007
On Dec 14, 2007 2:08 PM, Andrew Cruse <andrew at profitability.net> wrote:
> Paul Lathrop wrote:
> > Hi all,
> >
> > I've been banging my head against this for days, and Googled my eyes
> > out to no avail, so I think it is time to bring this to the list.
> >
> > I have written a plugin in Python which connects to a database on
> > another host, runs an arbitrary query, and (depending on the options
> > passed to it) returns an appropriate Nagios return code. Here is a
> > typical invocation of this script from the command line:
> >
> > nagios at monitor:~$ /usr/local/lib/nagios/plugins/dbmon.py -H 10.0.2.9
> > -u monitor -p password -d testdb -w 10: -c 20: "select count(*) from
> > users"
> > OK: 24
> >
> > As you can see, I'm running this as the Nagios user with no problems.
> >
> > Here is my command definition:
> >
> > define command{
> > command_name check-db-count
> > command_line /usr/local/lib/nagios/plugins/dbmon.py
> > -H $HOSTADDRESS$ -u $USER3$ -p $USER4$ -d $ARG1$ -w $ARG3$ -c $ARG4$
> > $ARG2$
> > }
> >
> > $USER3$ and $USER4$ are set in resource.cfg to the appropriate values.
> >
> > Here is my service definition:
> >
> > define service{
> > use generic-service
> > host_name data.zicasso.com
> > service_description Example DB Monitor
> > check_command check-db-count!testdb!"select count(*)
> > from users"!10:!20:
> > contact_groups sysadmin
> > }
> >
> > I would expect this to work, but the plugin returns '(No output!)'
> > Basic debugging step is to make sure the command is being run the way
> > I think it is. So I changed my command definition to:
> >
> > define command{
> > command_name check-db-count
> > command_line echo
> > /usr/local/lib/nagios/plugins/dbmon.py -H $HOSTADDRESS$ -u $USER3$ -p
> > $USER4$ -d $ARG1$ -w $ARG3$ -c $ARG4$ $ARG2$ >> /tmp/nagios.log
> > }
> >
> > And here is what I see:
> >
> > /usr/local/lib/nagios/plugins/dbmon.py -H 10.0.2.9 -u monitor -p
> > password -d testdb -w 10: -c 20: select count(*) from users
> >
> > Somewhere, the quotes around the SQL statement disappear. And no
> > amount of backslashing, double-quoting, or anything else will convince
> > nagios to pass those quotes along to the plugin! I am using Nagios 2.6
> > on Debian Etch.
> >
> > I'm also going somewhat nuts over this issue. Any help would be much
> > appreciated.
>
>
> How about putting the quotes in your command definition?
>
>
> define command{
> command_name check-db-count
> command_line /usr/local/lib/nagios/plugins/dbmon.py -H
> $HOSTADDRESS$ -u $USER3$ -p $USER4$ -d $ARG1$ -w $ARG3$ -c $ARG4$ "$ARG2$"
>
>
> aNDREW
Andrew,
Sorry, I forgot to post everything I tried. I have put the quotes in
my command definition. This gives me the same result (when I also
remove the quotes from the service definition). If I leave the quotes
in the service definition AND the command definition, I get the same
output, but instead of an OK state I get a WARNING state.
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
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