check_mysql_query and sent content

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.
Locked
PatrickNagios2019
Posts: 2
Joined: Fri Aug 02, 2019 2:32 am

check_mysql_query and sent content

Post 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!
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_mysql_query and sent content

Post 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?
PatrickNagios2019
Posts: 2
Joined: Fri Aug 02, 2019 2:32 am

Re: check_mysql_query and sent content

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_mysql_query and sent content

Post 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.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked