Check number of MySQL databases

Hi,

I would like to monitor number of MySQL databases. I’m using the official 'check_mysql_query ’ plugin:

Nagios agent:

  • however it gives a very long output:

Is there any better solution/plugin for this purpose?

Thanks

running a shell script via check_by_ssh… but i don’t think it’s “better” in any way. (i would just run something like “mysql -u root -p ****** < ‘show databases’ | wc -l” )

Hi,

Thanks for your reply.

I’ve got one more question. I tried to create a simple test plugin and it works fine from the tested machine but not with from Nagios:

“test” plugin:

Location: `/var/lib64/nagios/plugins

[code]#!/bin/bash

db=$(mysql -e ‘SHOW DATABASES’ | wc -l)
echo $db[/code]

It works from the local machine:

# ./test 71

  • however when executed from Nagios server it displays “0”

NRPE config:

Nagios server:

# ./check_nrpe -H 192.168.1.10 -c "test" 0

Any ideas?

Reagrds

IN the script you are missing login and password. it probably works on the machine itslef as you are running it as root. chec the nagios user (is that what nrpe uses?)

either you put login and password in the script “mysql -u root -p ########”
or (better) you create a nagios user and give it only the few read permissions you need.

Luca

This is actually quite strange as it works on a different machine with exactly the same configuration.

I’ve got the mysql login details in “my.cnf” file so this is not the issue.

On a third machine it displays number “1” so it’s getting input from somwhere

EDIT:

Yeap, privileges on MySQL server. I forgot that I’ve added on the server that it works

Thanks

check the show databases output for the user nagios… it’s missing permissions in MySQL