Check mysql query


#1

hi all,

I use check_mysql_query and it works only on services page when I click on status page its (null) and its possible to save performance data from the result ?

I already checked the : Performance data process performance data checkbox, but I dont see the icon on the services site

thanks in advance,

Regards
Neeloj


#2

If the plugin doesn’t return performance data you’ll have to add it yourself (i.e. using a wrapper script).


#3

thanks for your answer @Wolfgang

but I use here only rule with:
check_mysql_query -H $HOSTADDRESS$ -P 3306 -u -p -d -c 0 -q "SELECT COUNT(*) FROM vm "

and output is:

QUERY CRITICAL: ‘SELECT COUNT(*) FROM vm;’ returned 22.000000


(Philipp Näther) #4

Why don’t you use the cmk active check for checking SQL databases?


#5

I did that and I get :

22 is the return value of the statement,


(Philipp Näther) #6

Check this topic. Pretty much everything you need to know about the sql active check is in there:


#7

thank you @TheLucKy

Ill read that :slight_smile:


#8

@TheLucKy
I use the check_sql but I get:
select count(*), ‘VMs’,0 from vm
output:
UNKNOWN - <34> is not a state, and no levels given

and when I change the statement to:
select 0,0,count(*) from vm;

output:
OK - 0

I want to save the output of 34 as performance data.

thanks again


(Philipp Näther) #9

Read the help text of the active check:

This check connects to the specified database, sends a custom SQL-statement or starts a procedure, and checks that the result has a defined format containing three columns, a number, a text, and performance data. Upper or lower levels may be defined here. If they are not defined the number is taken as the state of the check. If a procedure is used, input parameters of the procedures may by given as comma separated list. This check uses the active check check_sql.

If you want performance data you have to add a second count(*) as third value.


#10

or :
The SQL-statement or proceduslight_smile: name which is executed on the DBMS. It must return a result table with one row and at least two columns. The first column must be an integer and is interpreted as the state (0 is OK, 1 is WARN, 2 is CRIT). Alternatively the first column can be interpreted as number value and you can define levels for this number. The second column is used as check output. The third column is optional and can contain performance data.

thank you so much @TheLucKy :slight_smile: