8
1
While devising an answer to this question I ran into a snag while testing this MySQL Monit ruleset on an Ubuntu 12.04.5 setup:
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
group mysql
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"
if failed host 127.0.0.1 port 3306
with timeout 15 seconds
then restart
if 5 restarts within 5 cycles
then timeout
alert email_address@example.com only on { timeout, nonexist }
The issue is I was attempting to invoke start/stop items via /etc/init.d/
—which is more of a CentOS/RedHat system construct—instead of using /usr/sbin/service
which would be more appropriate for a Ubuntu/Debian system.
Okay, my bad… But the issue is you see that if 5 restarts within 5 cycles then timeout
part? That seems to have bit me hard. With the /etc/init.d/mysql start
command not able to work, the system attempted 5 restarts, failed 5 times and then timed out as a result. And the timeout condition seems to result in the MySQL service ruleset being ignored my Monit.
I’ve restarted the Monit service a few times and even rejiggered the ruleset to see if it helps but none of that seems to affect anything.
What can I do to get Monit to pay attention to rulesets it has “unmonitored” due to timeout conditions being met?
1On a related note, when trying to find this state file on amazon linux, I was (finally) able to find it at
/root/.monit.state
– Scott – 2017-06-26T14:58:39.757@Scott Good point! Adjusted my answer to reflect the fact that the “state” file might be located elsewhere with a different filename entirely. – JakeGould – 2017-06-26T18:15:05.580
1You should be able to find the location of your
statefile
in the Monit config file (/etc/monit/monitrc
) with e.g.grep statefile /etc/monit/monitrc
– user51928 – 2018-05-19T00:31:02.503