- edited description
Check process - run script as a test
Hello,
First of all I would like to say that monit is a great program and it helps me a lot in one of my projects, so thank you all for doing such a great work.
I was wondering if it would be possible to check a daemon (process) by running a bash script instead of all the standard tests.
My use case is the following: I have a server running on port 8888 that uses a binary encoded communication protocol. I initially added a "check process entry", and besides checking for PID existence and defining start and stop commands, I also added a port check. But the problem was that checking the port was creating a resource leak (multiple sockets that were lingering) and I had to create a script that was connecting to the server. So now I check my program with:
check program myscript with path /usr/local/bin/myscript.sh
if status != 0 then <ACTION>
I looked in the documentation and I couldn't find the info that would tell me how to define a "check process" entry and run custom scripts as tests. I was expecting to find something like:
if failed "/path/my_script.sh" then restart
or
if failed "/path/my_script.sh" for 3 cycles then restart
or
if failed "/path/my_script.sh" then exec "/path/another_script.sh"
I would prefer monitoring my daemon with "check process" because I get some nice info like process uptime and it would help me to spot problems with a specific installation.
Thank you very much and keep up the excellent work, Bogdan
Comments (2)
-
reporter -
repo owner - changed status to closed
Hello Bogdan,
you can can combine a "check process" service entry to test the process itself + add a "check program" entry to extend it by custom script.
Example:
check process myprocess with pidfile /var/run/myprocess.pid check program myprocess_script with path /usr/local/bin/myscript.sh if status != 0 then <ACTION> depends on myprocess
- Log in to comment