Page 1 of 1

check_mysql_query and sent content

Posted: Fri Aug 02, 2019 2:49 am
by PatrickNagios2019
Hi,

I run into the following problem.

The idea is to check the contents of a mysql database table via a check_mysql_query plugin and if there is any content, you can report this and preferably send the content.

when there is content in the table, a notification is already made, but the question is whether there is an option to place the content directly in the notification (by mail).

I am using now the code below to do the check

command[check_mysql]=/usr/lib64/nagios/plugins/check_mysql_query -H 127.0.0.1 -d callanalysis -u user -p pass -q "select length(results) from runs order by id desc limit 1" -c 100:10000 -w 0:1

Thanks in advance!

Re: check_mysql_query and sent content

Posted: Mon Aug 05, 2019 3:57 pm
by ssax
What is the full output of this command from the command line?

Code: Select all

/usr/lib64/nagios/plugins/check_mysql_query -H 127.0.0.1 -d callanalysis -u user -p pass -q "select length(results) from runs order by id desc limit 1" -c 100:10000 -w 0:1
My assumption is that it just returns an integer, correct? It should display it but what specifically are you trying to have in the message, the integer from the length(results) or something else?

Re: check_mysql_query and sent content

Posted: Tue Aug 06, 2019 7:29 am
by PatrickNagios2019
Hi,
Thanks for your help and input.
The exact output right now is:

QUERY WARNING: 'select length(results) from runs order by id desc limit 1' returned 1024.000000 | result=1024.000000;1.000000;;

which is valid but it results in email being sent with this in the mail body:

***** Nagios *****
Notification Type: PROBLEM
Service: POSSIBLE HACK suspicious calls
State: WARNING
Date/Time: Thu Aug 1 15:06:40 CEST 2019
Additional Info:
QUERY WARNING: select length(results) from runs order by id desc limit 1 returned 1396.000000

But we would like to see the results text in the email, which is a text describing why the warning goes off. Is there any way to accomplish this?
Thx in advance

Re: check_mysql_query and sent content

Posted: Tue Aug 06, 2019 7:49 am
by scottwilkerson
the result of your plugin is this

Code: Select all

QUERY WARNING: select length(results) from runs order by id desc limit 1 returned 1396.000000
Your email contains this:
PatrickNagios2019 wrote: QUERY WARNING: select length(results) from runs order by id desc limit 1 returned 1396.000000
There is no way for Nagios to know any more details than the plugin returns.

If you want more information, you would need to write a plugin that contains the detailed information.