Nagios strips quotes from command arguments
Paul Lathrop
paul at zicasso.com
Fri Dec 14 22:57:38 CET 2007
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.
Thanks,
Paul
-------------------------------------------------------------------------
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