Page 1 of 2

check_mysql_query

Posted: Tue Sep 29, 2015 11:46 am
by garazh317
Hi all! Does anybody use subj?
I get NULL everytime from that plugin. Here are my configs

define command{.
command_name<-->check_mysql_query
command_line<-->$USER1$/check_mysql_query -H a.b.c.d -P 3306 -d database -u user -p password -q 'SELECT COUNT(`post_name`) FROM wp_posts;' -w $ARG1$ -c $ARG2$
}.

define service{
<------>use<---><------><------>generic-service
<------>host_name<-----><------>server
<------>service_description<--->costs
<------>check_command<-><------>check_mysql_query!10!20
<------>}


When I run command from cmd everything is ok and I get
usr/lib64/nagios/plugins/check_mysql_query H a.b.c.d -P 3306 -d database -u user -p password -q 'SELECT COUNT(`post_name`) FROM wp_posts;' -w 1 -c 2
QUERY CRITICAL: 'SELECT COUNT(`post_name`) FROM wp_posts;' returned 36,000000

Where is the problem?

Re: check_mysql_query

Posted: Wed Sep 30, 2015 11:08 am
by tmcdonald
I need to ask the obvious question here, but are you actually putting <-----> in your configs?

Re: check_mysql_query

Posted: Wed Sep 30, 2015 12:02 pm
by garazh317
I need to ask the obvious question here, but are you actually putting <-----> in your configs?
Not. I use mc, and <--> appear when I insert code there.

Re: check_mysql_query

Posted: Wed Sep 30, 2015 3:14 pm
by jdalrymple
The first troubleshooting step will be to try to run the same command from the cli while logged on as the nagios user.

Please try that and report back the results.

Re: check_mysql_query

Posted: Thu Oct 01, 2015 7:23 am
by garazh317
-bash-4.1$ /usr/lib64/nagios/plugins/check_mysql_query -H a.b.c.d -P 3306 -d database -u user -p password -q 'SELECT COUNT(`post_name`) FROM wp_posts;' -w 10 -c 20
QUERY CRITICAL: 'SELECT COUNT(`post_name`) FROM wp_posts;' returned 36,000000

When it run from the cli while logged as the nagios user everything looks fine with result.

Re: check_mysql_query

Posted: Thu Oct 01, 2015 10:08 am
by hsmith
By chance do you have any special characters in your password?

Re: check_mysql_query

Posted: Mon Oct 12, 2015 9:44 am
by garazh317
hsmith wrote:By chance do you have any special characters in your password?
I had, but now changed the password, and nothing happens. In cli `ok`, nagios has 'null'

Re: check_mysql_query

Posted: Mon Oct 12, 2015 11:22 am
by hsmith
What is the output of a grep '$USER1' /usr/local/nagios/etc/resource.cfg command?

Re: check_mysql_query

Posted: Mon Oct 12, 2015 11:40 am
by garazh317
hsmith wrote:What is the output of a grep '$USER1' /usr/local/nagios/etc/resource.cfg command?
$USER1$=/usr/lib64/nagios/plugins

Re: check_mysql_query

Posted: Mon Oct 12, 2015 11:51 am
by hsmith
Can you run a 'pre flight check?' /usr/lib64/nagios/bin/nagios -v /usr/lib64/nagios/etc/nagios.cfg

If that doesn't work, my paths may be slightly off. I am not used to that directory structure. How did you install Nagios? What OS is it running on?