0

I'm trying to check mysql queries output and compare the result with some values for my Nagios services checks.
It can be that there is a better way to resolve this (and if so - please share :))... For now, I'm trying this method:

./check_mysql_health --username root --password MyPassw0rd --mode sql --name 'show variables like 'max_connections'' --name2 "max_connections 4096"

PS: my max_connections is 4096

mysql -Bse "show variables like 'max_connections';"
max_connections 4096

The output is:

Use of uninitialized value $value in numeric gt (>) at ./check_mysql_health line 1237.
    Use of uninitialized value $value in numeric gt (>) at ./check_mysql_health line 1238.
    OK - max_connections 4096:

And if I change the value in name2 to something not equal to "max_connections 4096", like "G1Li" the output returns with OK status.

    ./check_mysql_health --username root --password MyPassw0rd --mode sql --name 'show variables like 'max_connections'' --name2 "G1Li" 
Use of uninitialized value $value in numeric gt (>) at ./check_mysql_health 

line 1237.
    Use of uninitialized value $value in numeric gt (>) at ./check_mysql_health line 1238.
    OK - g1li:
# echo $?
0

Any ideas?

Gili

Gili Lapid
  • 53
  • 2
  • 6
  • Probably this: `--name 'show variables like 'max_connections''`. The quotes "inside" that sql are terminating the bash string, so `--name` parameter ENDS at `like`, making max_connections etc... something completely separate. – Marc B Sep 20 '16 at 15:07

1 Answers1

0

I am also new to this this may help,

./check_mysql_health --username root --password MyPassw0rd --mode sql \
--name 'show 1,variables like 'max_connections'' --name2 "status max_connections 4096"

We are using this for Oracle. I am not sure about that status, but that 1 is correct.

Or you can customize like adding some more mode(There are two major parts one is for remote/local execution of sql query and another is parsing the result data for nagios/icinga ) in that plugin as you want!! That will be a better solution.

saravanakumar
  • 1,747
  • 4
  • 20
  • 38