monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Execute Command by Monit Unsuccessful


From: Martin Pala
Subject: Re: Execute Command by Monit Unsuccessful
Date: Fri, 12 Sep 2014 20:19:14 +0200

Hi,

another problem is the "&" character ... Monit doesn't run the command in 
shell, so it won't work. Monit runs the problem is a sandbox - older Monit 
versions purged the environment and set only spartan PATH, so if your program 
depends on some environment or custom path, it will fail.

You can log the program output this way:
        if does not exist then exec "/bin/bash -c '/usr/local/bin/liquidsoap 
/home/jay/scripts/spa.liq > /tmp/liquidsoap.log 2>>&1'" as uid jay and gid jay

The process existence check is implicit, so you can just specify the start/stop 
program instad of existence test:

--8<--
check process stream matching "spa.liq"
    start program = "/bin/bash -c '/usr/local/bin/liquidsoap 
/home/jay/scripts/spa.liq > /tmp/liquidsoap.log 2>>&1'" as uid jay and gid jay
--8<--


Regards,
Martin



On 25 Sep 2014, at 23:39, Jay Nicholas <address@hidden> wrote:

> Martin,
> 
> Thank you for your email! I took your advice and made the change; however, it 
> still doesn't work. Here's what the configuration looks like now:
> 
>       check process stream matching "spa.liq"
>       if does not exist then exec "/usr/local/bin/liquidsoap 
> /home/jay/scripts/spa.liq &" as uid jay and gid jay
> 
> Here is what I see in the log file when I kill the process:
> 
>       [CDT Sep 25 16:28:23] error    : 'stream' process is not running
>       [CDT Sep 25 16:28:25] info     : 'stream' exec: 
> /usr/local/bin/liquidsoap
>       [CDT Sep 25 16:30:25] error    : 'stream' process is not running
>       [CDT Sep 25 16:30:25] info     : 'stream' exec: 
> /usr/local/bin/liquidsoap
> 
> You can see it executes the command. Although the log only shows the first 
> portion of the command before the space. If I execute this identical command 
> on the command line it works with no problem.
> 
> Jay
> 
> On Sep 25, 2014, at 2:31 PM, Martin Pala <address@hidden> wrote:
> 
> Hi,
> 
> you have to use full path for the "liquidsoap" command (Monit doesn't use 
> shell to execute the command). You can get the path by "which liquidsoap" 
> command (provided it is in your PATH).
> 
> Regards,
> Martin
> 
> 
> On 25 Sep 2014, at 20:49, Jay Nicholas <address@hidden> wrote:
> 
>> Hello, all!
>> 
>> I need some advice and I'm hoping someone can assist.
>> 
>> I have a process that runs on my server that I would like to have monitored 
>> by monit. The only thing that doesn't work is the following lines in the 
>> config file:
>> 
>>  check process stream matching "spa.liq"
>>  if does not exist then exec "liquidsoap /home/me/scripts/spa.liq &" as uid 
>> jay and gid jay
>> 
>> It is able to find the "spa.liq" process because I can see it from the monit 
>> web page. However, if I kill the process to test that it starts up it 
>> doesn't work. The log files show that it executes the command but it never 
>> runs so it just keeps trying.
>> 
>> In addition, this process cannot run as root so I added the "as uid jay and 
>> gid jay" so that it runs under my username.
>> 
>> There must be something wrong with this configuration but I can't figure out 
>> what it is.
>> 
>> Thanks,
>> 
>> Jay
>> 
>> --
>> To unsubscribe:
>> https://lists.nongnu.org/mailman/listinfo/monit-general
> 
> 
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general




reply via email to

[Prev in Thread] Current Thread [Next in Thread]