How to get Monit to re-monitor a service it has unmonitored?
After doing some digging, it turns out Monit stores system monitoring data in a “state” file. And this “state” file keeps track of what services are being monitored/unmonitored.
So while this is a bit “brute force”-ish, it definitely works. If a service becomes “unmonitored” due to something like a timeout, then just remove the Monit state file from the system like this:
sudo rm /var/lib/monit/state
And then restart Monit like this and all should be good:
sudo service monit restart
FWIW, on other systems/setups the Monit “state” file might be saved as state
or monit.state
or even .monit.state
(with a dot/period .
prepending it) in another directory. Be sure to determine exactly where that “state” file is being saved when you actually attempt to implement this fix.
Monit includes commands to enable and disable monitoring of all or specific services.
If a service has become unmonitored you can re-enable monitoring with e.g. monit monitor mysql
or monit monitor all
.
Note you must have the Monit HTTP interface enabled for these commands to work.