Mysql – monit thesql server blocked because of too many bad connections

debianmonitMySQL

Is there any tweak for monit or another way to monitor whether one server can access mysql on another server?

I tried it with monit but as you probably know, after 10 attempts, mysql blocks the server.

check host db1.server with address db1.server
   if failed port 3306 protocol mysql then alert

.

mysqli: host <host> is blocked because of many connection errors; unblock with mysqladmin flush-hosts

Best Answer

Edit (total new answer)

I have Googled a bit about this issue and found some clue :

Seems that MySql does not really like when :

  • a connection is made on port 3306 without authentication
  • a socket is openened and then dropped without any SQL handshaking

So, a workaround could be to perform a real MySql connection and run a query.

Here is a way to do it. You will need to install mysql-client on the monitoring server and grant correct access on MySql server.

Monit check setup :

check program mysql with path "/root/mysql_check.sh"
  if status != 0 then alert

Script mysql_check.sh :

#!/bin/sh
mysql -u<user> -p<password> --host=xx.xx.xx.xx <<END
SHOW VARIABLES LIKE "%version%";
END

Script mysql_check.sh should also be valid for a custom Nagios check.


I have tested this successfully (means can run the query remotely), but as far as i cannot reproduce the blocked host issue on my MySql 5.5 server i cannot tell if this actually solves the issue.

Give it a try and tell me what the result is.


My references :