- changed status to closed
process actions in system checks
I would like to propose a feature that system checks can do actions on processes.
Suppose there is this system check:
check system $HOST
if memory usage > 90% for 3 cycles then alert
and this process:
check process my_process matching "..."
restart program = "..."
Currently, restarting a process is only available from within a `check process`, but it would be great to be able to restart a process if the system memory is too much and not have to specify a memory limit for the process itself.
I would like to propose this syntax for check system
:
if memory usage > 90% for 3 cycles then restart process my_process
(I also posted this as a StackOverflow question https://stackoverflow.com/questions/71558782/monit-can-i-restart-a-process-if-system-memory-is-too-much )
Comments (3)
-
repo owner -
Hello,
to find the answer faster and back to the sample.The command (start, stop, restart, ...) execute the proper command for the service itself only.
But you can use something like this.
check system $HOST if memory usage > 90% for 3 cycles then exec "/bin/bash -c '/usr/local/bin/monit restart my_process'"
To restart a service named "my_process".
With regards,
Lutz -
reporter Thanks for your answer!
- Log in to comment
The question/suggestion seems adequately answered on Stack Overflow