I would like to make Monit's "check process" work conditionally based on an env variable.
Here's the pseudo-code of what I would like to achieve(not a valid monit config syntax):
[ -n "$run_foo" ] && check process foo ....
My use case: I have a docker image that starts monit process like this:
CMD ["/bin/monit", "-c","/config/monit.conf"]
Monit then starts various daemons.
Now, I would like to be able to tell at run time which daemons I want to start in a particular container created from this image, like this:
docker run --env="run_foo=1;run_bar=1" ...
I am aware of monit unmonitor, and similar args, however I believe they don't serve my purpose.
Thought about something like this:
start program="/bin/bash -c '[ -n \"$run_foo\" ] && /bin/foo .."
However, seems like it will cause monit to spin continuously trying to start and monitor things that shouldn't be started.
I am aware of possibility of using different monit config files, or using different docker images - these don't qualify as an answer.
Other ideas appreciated.