monit-general
[Top][All Lists]
Advanced

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

Re: syntax error 'then"


From: Rafael Torres
Subject: Re: syntax error 'then"
Date: Thu, 30 Jul 2015 02:15:58 -0400

what if I want to check for the existance of a file? for example:

check file mongod.lock with path /var/lib/mongodb/mongod.lock
    
    if  exist then exec “ /bin/rm /var/lib/mongodb/mongod.lock”
    
will this work?

Rafael L. Torres Jr. MSIA, CISSP, S +, N+
1509 Lowell Ct.
Crofton, MD 21114
Cell: 757-876-1986

On Wed, Jul 29, 2015 at 1:45 AM, Martin Pala <address@hidden> wrote:
You need to specify full test/condition … for example if you want to execute the command if process doesn’t exist:

check process mongod with pidfile /data/db/mongodb.pd
    start program = “/etc/init.d/mongod start"
    stop program = “/etc/init.d/mongod stop"
    if does not exist then exec “ /bin/rm /var/lib/mongodb/mongod.lock”

Note that this will override the default restart action when the process doesn’t exist => you’ll need to add implicit restart command too, either:

check process mongod with pidfile /data/db/mongodb.pd
    start program = “/etc/init.d/mongod start"
    stop program = “/etc/init.d/mongod stop"
    if does not exist then exec “/bin/bash -c ‘/bin/rm /var/lib/mongodb/mongod.lock && /etc/init.d/mongod restart’”

or:

check process mongod with pidfile /data/db/mongodb.pd
    start program = “/etc/init.d/mongod start"
    stop program = “/etc/init.d/mongod stop"
    if does not exist then exec “ /bin/rm /var/lib/mongodb/mongod.lock”
    if does not exist then restart

Regards.
Martin


> On 29 Jul 2015, at 06:16, Rafael Torres <address@hidden> wrote:
>
> Can someone help me with my syntax error. this is what the config looks like:
>
> check process mongod with pidfile /data/db/mongodb.pd
>     start program = "/etc/init.d/mongod start"
>     stop program = "/etc/init.d/mongod stop "
> if failed then exec " /bin/rm  /var/lib/mongodb/mongod.lock"
>
> but I keep getting syntax error then, what am I doing wrong?
>
> Rafael L. Torres Jr. MSIA, CISSP, S +, N+
> 1509 Lowell Ct.
> Crofton, MD 21114
> Cell: 757-876-1986
> --
> 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]