- attached test.awake
- attached output
- attached test_stop
- attached test_start
- attached Bug.md
- attached log
The Action STOP and UNMONITOR don't work at all
I installed monit() through entware on ASUS Router RT-AC68U(ASUS Merlin Firmware) and I find that the Action STOP and UNMONITOR don't work at all!!!
Case
- Create a service file /opt/etc/monit.d/test.awake
/opt/etc/monit.d/test.awake:
check program test path "/opt/etc/monit.d/test/test_start" every 2 cycles
start program = "/opt/etc/monit.d/test/test_start"
stop program = "/opt/etc/monit.d/test/test_stop"
if status != 0 then stop
- Create the test scripts "/opt/etc/monit.d/test/test_start" and "/opt/etc/monit.d/test/test_stop"
/opt/etc/monit.d/test/test_start:
#!/bin/sh
#
#TEST='OK'
TEST='TT'
#
if [ ${TEST} == "OK" ]
then
echo "$(date +%H:%M:%S) test_start exit 0" >> /opt/etc/monit.d/test/log
exit 0
else
echo "$(date +%H:%M:%S) test_start exit 1" >> /opt/etc/monit.d/test/log
exit 1
fi
/opt/etc/monit.d/test/test_stop:
#!/bin/sh
#
echo "$(date +%H:%M:%S) test_stop" >> /opt/etc/monit.d/test/log
-
Run
monit reload
and start program "test" from the web page. -
Finally I get the
/opt/etc/monit.d/test/log
as below
16:30:24 test_start exit 1
16:30:54 test_start exit 1
16:31:24 test_stop
16:31:54 test_start exit 1
16:32:24 test_stop
16:32:55 test_start exit 1
16:33:25 test_stop
16:33:55 test_start exit 1
16:34:25 test_stop
16:34:55 test_start exit 1
16:35:25 test_stop
16:35:55 test_start exit 1
16:36:25 test_stop
16:36:55 test_start exit 1
16:37:25 test_stop
16:37:55 test_start exit 1
16:38:25 test_stop
16:38:55 test_start exit 1
16:39:25 test_stop
16:39:56 test_start exit 1
16:40:26 test_stop
16:40:56 test_start exit 1
# Omitted below
- Check the status of service test using
monit status test
and I get this
Program 'test'
status OK
monitoring status Monitored
monitoring mode active
on reboot start
last exit value 1
last output -
data collected Thu, 26 Jul 2018 16:48:41
According to the Documentation
STOP stops the service by calling the service's registered stop method and send an alert. If Monit stops a service it will not be checked by Monit anymore nor restarted again later. To reactivate monitoring of the service again you must explicitly enable monitoring from the web interface or from the console.
It should stop the service at the first "stop" in the log and stop monitoring it. Apparently, the repetition in the log is so abnormal, and the action STOP doesn't work as expected. Neither does the action UNMONITOR.
PS: My monitrc is in the attachments
Comments (4)
-
-
I give it a test again. It turns out that:
-
If the code in folder monit.d contains the keyword every like
check program test path "/opt/etc/monit.d/test/test_start" every 2 cycles
Action STOP could not behave as the document states
If Monit stops a service it will not be checked by Monit anymore nor restarted again later.
-
If the code in folder monit.d doesn't contain the keyword "every" like
check program test path "/opt/etc/monit.d/test/test_start"
Action STOP and UNMONITOR could behave as the document states
If Monit stops a service it will not be checked by Monit anymore nor restarted again later.
-
-
repo owner - edited description
-
assigned issue to
-
repo owner - changed status to resolved
Fixed: Issue
#759: The "stop" action for "check program" has no effect if the "every" statement is used to skip monitoring in some cycles.→ <<cset 617cab011bb2>>
- Log in to comment
I see that the scripts are displayed messly. I'll add them in the attachments.
Plus, the action STOP and UNMONITOR could work when I click the button on the webpage or run them in shell, they just could not work in the included service file.