Reputation: 2533
I am trying to monitor the MySQL process in another system using Monit. The system is connected to the same network connection as mine. I am using this code (inside the configuration file, monitrc) :
check process mysql with pidfile /var/run/mysqld/mysqld.pid
group database
start program = "/etc/init.d/mysql restart"
stop program = "/etc/init.d/mysql stop"
if failed host 192.168.0.189 port 3306 then restart
if 5 restarts within 5 cycles then timeout
Status appears to be "Not monitored". What seems to be the problem?
Upvotes: 2
Views: 960
Reputation:
I'd like to expand this answer, as I had a similar problem.
1) Edit MySQL config (/etc/mysql/my.cnf) and set the bind address to whatever address it should listen to, such as 0.0.0.0 (global address), or an actual IP address. Also note the listening port.
2) Edit monit config file to use the same address as 'host' for the MySQL service. Make sure the port number also matches the MySQL config port.
3) Since I was using iptables rules for my firewall, I had to add the lines to my rules:
# allow connection to monit's http server
-A INPUT -p tcp -m tcp --dport 2812 -j ACCEPT
# allow connect to mysql server
-A INPUT -s <listening address> -p tcp -m tcp --dport <listening port> -j ACCEPT
Then reload the firewall rules:
sudo iptables-reload < /path/to/iptables.rules.file
Lastly, restart monit service, or reload configuration.
Upvotes: 1
Reputation: 2533
Solved the problem. Had to change the bindaddress in my.conf file of mysql. Set it to 0.0.0.0 from localhost (127.0.0.1) to allow connections from all hosts in the network.
Upvotes: 0