Check process - run script as a test

Issue #384 closed
B created an issue


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/
       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/" then restart
if failed "/path/" for 3 cycles then restart
if failed "/path/" then exec "/path/"

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)

  1. Tildeslash repo owner

    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.


    check process myprocess with pidfile /var/run/
    check program myprocess_script with path /usr/local/bin/
        if status != 0 then <ACTION>
        depends on myprocess
  2. Log in to comment