monit-general
[Top][All Lists]
Advanced

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

Re: [monit] Character Limit in Start | Stop Program Directive?


From: Damien Bargiacchi
Subject: Re: [monit] Character Limit in Start | Stop Program Directive?
Date: Tue, 17 Mar 2009 14:41:12 -0700

If the command copy and pasted from monit won't run when sudoed to
root and with that minimal environment, it won't work in monit (unless
I've made a mistake in that one liner). You need to adjust your script
(by setting environment variables maybe) so that is runs in that
environment.

If you're going to use su to run it from that environment, maybe it'll
work in monit too. Haven't tested that myself.

   ...Damien

On Tue, Mar 17, 2009 at 1:16 AM, Christopher Opena
<address@hidden> wrote:
> Oops sorry, mistake below.  The actual commands were:
>
> Failed
> # /bin/bash -c 'cd /path/to/the/script; LOCAL_VAR=my__var cd
> /path/to/the/script/my_script start -d'
>
> Succeeded
> # su - my__uid -c "/bin/bash -c 'cd /path/to/the/script; LOCAL_VAR=cd
> /path/to/the/script/my_script start -d'"
>
> On Tue, Mar 17, 2009 at 1:14 AM, Christopher Opena <address@hidden>
> wrote:
>>
>> Damien, thanks for the suggestion.  I tried the following while su'ed to
>> root after executing your monit emulation script:
>>
>> # /bin/bash -c 'cd /path/to/the/script; LOCAL_VAR=cd
>> /path/to/the/script/my_script start -d'
>>
>> The above failed with the message '/usr/bin/env: ruby: No such file or
>> directory' (which makes sense).  Since I'm actually doing the Start
>> directive as uid 'my__uid', I tested it with a su while logged in as root:
>>
>> # su - my__uid -c "/bin/bash -c 'cd /path/to/the/script; LOCAL_VAR=cd
>> /path/to/the/script/my_script start -d'"
>>
>> The above worked just fine.  Are you thinking that perhaps executing the
>> directive with the 'as uid my__uid and gid my__gid' is not working properly?
>>
>> Thanks again,
>> -Chris.
>>
>> On Mon, Mar 16, 2009 at 1:00 PM, Damien Bargiacchi
>> <address@hidden> wrote:
>>>
>>> Start up a bash session as the user that runs monit (usually root).
>>> Run the next little one liner. It sets up the environment to emulate
>>> monit.
>>>   for var in `env|cut -d '=' -f1`; do unset $var; done;export
>>> PATH=/bin:/usr/bin:/sbin:/usr/sbin
>>> Now copy-paste the start directive.
>>>
>>> Does that still work?
>>>
>>>   ...Damien
>>>
>>> On Sun, Mar 15, 2009 at 11:50 PM, Christopher Opena
>>> <address@hidden> wrote:
>>> > Hello all, I've been doing some fairly intensive testing of using monit
>>> > to
>>> > test out multiple applications on my server.  Each of the specific
>>> > services
>>> > I'm monitoring uses a "/bin/bash -c '/path/to/script -d'" as the Start
>>> > execution.  I've noticed in testing that when I stop one of the
>>> > services, it
>>> > starts up automatically.  The other one doesn't.  The monit log shows
>>> > it
>>> > attempting to start the service, but it fails.  I've double- and
>>> > triple-checked the Start directive to make sure that I didn't make any
>>> > syntax errors, and even copied the contents of the failing Start
>>> > directive
>>> > out into my bash session (that works fine).  The only difference I can
>>> > see
>>> > is that the path to the failing script is very long.
>>> >
>>> > Is there a character limit of some kind on the Start directive that I'm
>>> > not
>>> > aware of?  I tried checking the Monit manual and it doesn't mention any
>>> > character limit of any kind.  Below I'm pasting the contents of the two
>>> > Start scripts (with directories in Xs just so you can see the script
>>> > length
>>> > without revealing too much).
>>> >
>>> > --Successful Script--
>>> > start program = "/bin/bash -c 'cd /xxx/xxxxx/xxx/xxxxxxx;
>>> > LOCAL_VAR=xxxxxxxxxx /xxx/xxxxx/xxx/xxxxxxx/xxxxxx/xxx start -d'" as
>>> > uid
>>> > my__uid and gid my__gid with timeout 60 seconds
>>> >
>>> > --Failing Script--
>>> > start program = "/bin/bash -c 'cd
>>> > /xxx/xxxxx/xxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxx; LOCAL_VAR=xxxxxxxxxx
>>> > /xxx/xxxxx/xxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxx/xxx start -d'" as uid
>>> > my__uid
>>> > and gid my__gid with timeout 60 seconds
>>> >
>>> > I've also checked to make sure that directory ownership was the same on
>>> > the
>>> > two different log directories that the scripts write to - no problems
>>> > there.  I'm quite at my wits end to determine why one works and the
>>> > other
>>> > one doesn't - and they starting the exact same script for different
>>> > apps on
>>> > the same server!  Any help would be greatly appreciated.
>>> >
>>> > Thanks,
>>> > -Chris.
>>> >
>>> > --
>>> > To unsubscribe:
>>> > http://lists.nongnu.org/mailman/listinfo/monit-general
>>> >
>>>
>>>
>>> --
>>> To unsubscribe:
>>> http://lists.nongnu.org/mailman/listinfo/monit-general
>>
>
>
> --
> To unsubscribe:
> http://lists.nongnu.org/mailman/listinfo/monit-general
>




reply via email to

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