From the manual;

    CHECK PROGRAM <unique name> PATH <executable file> [TIMEOUT <number>
    SECONDS]

    <path> is the absolute path to the executable program or script. The
    status test allows one to check the program's exit status. If the
    program does not finish executing within <number> seconds, Monit
    will terminate it. The default program timeout is 300 seconds (5
    minutes). The output of the program is recorded and made available
    in the User Interface and in alerts, by default up to 512 bytes. You
    can change the output limit using the set limits statement).”


Two things to note here, you program must end with a call to exit and
it should exit 0 if all is okay and exit 1 if error. You then write the test as 
follows:

check program checkUSB with path "/usr/local/sbin/checkUSB.sh"
   if status != 0 then alert

Ps .The content test i primarily for testing file content. 

> On 1 Apr 2022, at 08:38, Tino Hendricks <t.hendri...@interpool.de> wrote:
> 
> Dear list,
> 
> I’m trying to monitor an USB port.
> 
> The script „checkUSB.sh“ returns „error“ or „exists“ (successfully tested in 
> Terminal as root).
> 
> Monit runs as root but with
> 
> check program checkUSB with path "/usr/local/sbin/checkUSB.sh"
>     if content != "exists" then alert
> 
> never returns. The process runs forever and is then killed by timeout.
> 
> Apr  1 08:19:01 asterisk monit[5301]: 'checkUSB' program timed out after 
> 5.017 m. Killing program with pid 5321
> Apr  1 08:19:01 asterisk monit[5301]: 'checkUSB' content match on program 
> output:#012#012
> Apr  1 08:24:02 asterisk monit[5301]: 'checkUSB' program timed out after 
> 5.017 m. Killing program with pid 5527
> Apr  1 08:24:02 asterisk monit[5301]: 'checkUSB' content match on program 
> output:#012#012
> Apr  1 08:29:03 asterisk monit[5301]: 'checkUSB' program timed out after 
> 5.017 m. Killing program with pid 5560
> Apr  1 08:29:03 asterisk monit[5301]: 'checkUSB' content match on program 
> output:#012#012
> 
> What could be wrong here?
> 
> Thanks in advance!
> 
> Tino


Reply via email to