check_mysql_query

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
garazh317
Posts: 7
Joined: Tue Sep 29, 2015 11:35 am

check_mysql_query

Post 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?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: check_mysql_query

Post by tmcdonald »

I need to ask the obvious question here, but are you actually putting <-----> in your configs?
Former Nagios employee
garazh317
Posts: 7
Joined: Tue Sep 29, 2015 11:35 am

Re: check_mysql_query

Post 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.
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: check_mysql_query

Post 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.
garazh317
Posts: 7
Joined: Tue Sep 29, 2015 11:35 am

Re: check_mysql_query

Post 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.
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: check_mysql_query

Post by hsmith »

By chance do you have any special characters in your password?
Former Nagios Employee.
me.
garazh317
Posts: 7
Joined: Tue Sep 29, 2015 11:35 am

Re: check_mysql_query

Post 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'
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: check_mysql_query

Post by hsmith »

What is the output of a grep '$USER1' /usr/local/nagios/etc/resource.cfg command?
Former Nagios Employee.
me.
garazh317
Posts: 7
Joined: Tue Sep 29, 2015 11:35 am

Re: check_mysql_query

Post by garazh317 »

hsmith wrote:What is the output of a grep '$USER1' /usr/local/nagios/etc/resource.cfg command?
$USER1$=/usr/lib64/nagios/plugins
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: check_mysql_query

Post 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?
Former Nagios Employee.
me.
Locked