Mysql query error
Posted: Mon Aug 22, 2016 7:05 am
Hi,
I'm trying to run a query "SELECT (TIMEDIFF(Now(), created_at)) as diff FROM db.table WHERE status != '1' ORDER BY created_at desc"
Im, using this command
$USER1$/check_mysql_query -q "$ARG1$" -w "$ARG2$" -c "$ARG3$" -d "$ARG4$" -H "$ARG5$" -u "$ARG6$" -p "$ARG7$"
And I get this error:
COMMAND: /usr/local/nagios/libexec/check_mysql_query -q "SELECT TIME_TO_SEC\(TIMEDIFF\(Now\(\), created_at\)\) FROM db.table WHERE status = '1' ORDER BY created_at DESC LIMIT 1" -w "50" -c "100" -d "DD" -H "abc.xyz" -u "nagios" -p "xxxxx"
OUTPUT: QUERY CRITICAL: Error with query - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\(TIMEDIFF\(Now\(\), created_at\)\) FROM db.table WHERE statu' at line 1
When I run it locally, I get a normal output:
[XXX@XXX ~]$ /usr/lib64/nagios/plugins/check_mysql_query -q "SELECT TIME_TO_SEC(TIMEDIFF(Now(), created_at)) FROM db.table WHERE status != '1' ORDER BY created_at DESC LIMIT 1" -w '50' -c '100' -d db' -H 'abc.xyz' -u 'nagios' -p 'xxxxx'
QUERY CRITICAL: 'SELECT TIME_TO_SEC(TIMEDIFF(Now(), created_at)) FROM db.table WHERE status != '1' ORDER BY created_at DESC LIMIT 1' returned 413.000000
I'm trying to run a query "SELECT (TIMEDIFF(Now(), created_at)) as diff FROM db.table WHERE status != '1' ORDER BY created_at desc"
Im, using this command
$USER1$/check_mysql_query -q "$ARG1$" -w "$ARG2$" -c "$ARG3$" -d "$ARG4$" -H "$ARG5$" -u "$ARG6$" -p "$ARG7$"
And I get this error:
COMMAND: /usr/local/nagios/libexec/check_mysql_query -q "SELECT TIME_TO_SEC\(TIMEDIFF\(Now\(\), created_at\)\) FROM db.table WHERE status = '1' ORDER BY created_at DESC LIMIT 1" -w "50" -c "100" -d "DD" -H "abc.xyz" -u "nagios" -p "xxxxx"
OUTPUT: QUERY CRITICAL: Error with query - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\(TIMEDIFF\(Now\(\), created_at\)\) FROM db.table WHERE statu' at line 1
When I run it locally, I get a normal output:
[XXX@XXX ~]$ /usr/lib64/nagios/plugins/check_mysql_query -q "SELECT TIME_TO_SEC(TIMEDIFF(Now(), created_at)) FROM db.table WHERE status != '1' ORDER BY created_at DESC LIMIT 1" -w '50' -c '100' -d db' -H 'abc.xyz' -u 'nagios' -p 'xxxxx'
QUERY CRITICAL: 'SELECT TIME_TO_SEC(TIMEDIFF(Now(), created_at)) FROM db.table WHERE status != '1' ORDER BY created_at DESC LIMIT 1' returned 413.000000