Monit can't detect MySQL, but I can

'mysqld' failed, cannot open a connection to INET[localhost:3306] via TCP

This error shows that monit is trying to connect to port 3306 on localhost, which is the IP address 127.0.0.1

tcp 0 0 173.230.135.241:3306 0.0.0.0:* LISTEN 14357/mysqld

This netstat output shows that mysqld is listening on the IP address mentioned. It is not listening on localhost.

You either need to make mysqld listen on localhost as well, or you need to tell monit to check the specific IP address, rather than defaulting to localhost.


This works for me - using the mysql socket rather than its port (on a debian machine):

check process mysql with pidfile /var/run/mysqld/mysqld.pid
   group database
   start program = "/etc/init.d/mysql start"
   stop program = "/etc/init.d/mysql stop"
   #if failed host 192.168.1.222 port 3306 protocol mysql then restart
   if failed unix "/var/run/mysqld/mysqld.sock" protocol mysql then restart
   depends on mysql_bin
   depends on mysql_rc

 check file mysql_bin with path /usr/bin/mysql
   group database
   if failed checksum then unmonitor
   if failed permission 755 then unmonitor
   if failed uid root then unmonitor
   if failed gid root then unmonitor

 check file mysql_rc with path /etc/init.d/mysql
   group database
   if failed checksum then unmonitor
   if failed permission 755 then unmonitor
   if failed uid root then unmonitor
   if failed gid root then unmonitor