monit-general
[Top][All Lists]
Advanced

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

Re: Syntax for else if


From: Guillaume François
Subject: Re: Syntax for else if
Date: Thu, 16 Jun 2016 17:48:05 +0200

Hello,

it seems, from my test some lines are working while other not. Tried with monit v5.16.

Could it be that not all [test] accept a "succeeded" condition ?

"does not exist" is working

also there is a "if" missing after the else of the "memory" test

This is ok on my side

  if does not exist then exec "/bin/echo"                                         else if succeeded then exec "/bin/echo"
  if does not exist for 3 times in 10 cycles then exec "/bin/echo frontendlogger" else if succeeded then exec "/bin/echo frontendlogger"
#  if 2 restarts within 10 cycles then exec "/bin/echo frontendlogger" else if succeeded then exec "/bin/echo frontendlogger"
#  if changed pid for 3 times in 10 cycles then exec "/bin/echo frontendlogger" else if succeeded then exec "/bin/echo frontendlogger"
  if memory > 70 MB for 3 cycles then exec "/bin/echo frontendlogger" else if succeeded then exec "/bin/echo frontendlogger"
  if cpu > 1% for 3 cycles then exec "/bin/echo frontendlogger" else if succeeded then exec "/bin/echo frontendlogger"

Best Regards,


2016-06-16 16:59 GMT+02:00 Mehul Ved <address@hidden>:

Here's what I have configured:


  if 2 restarts within 10 cycles then exec "/usr/local/bin/pagerduty-trigger frontendlogger"
  else if succeeded then exec "/usr/local/bin/pagerduty-trigger frontendlogger"

but when I do monit validate it throws following error:

  /etc/monit/conf.d/frontendLogger.conf:19: syntax error 'else'


The else in the above configuration is the 19th line.

Here's the whole file, in case it helps

----- START -----
check process frontendLogger matching frontendLogger
  start program = "/bin/systemctl start frontendLogger"
  stop program = "/bin/systemctl stop frontendLogger"
  restart program = "/bin/systemctl restart frontendLogger"
  group nodejs
  if failed host 127.0.0.1 port 10500 protocol http
    request /ping
    content = "PONG"
    with timeout 2 seconds
    for 2 times in 4 cycles
    then restart
  if failed host vr.com port 443 type TCPSSL protocol http
    request /logger/ping
    content = "PONG"
    with timeout 2 seconds
    for 2 times within 4 cycles
    then restart
  if 2 restarts within 10 cycles then exec "/usr/local/bin/pagerduty-trigger frontendlogger"
  else if succeeded then exec "/usr/local/bin/pagerduty-trigger frontendlogger"
  if does not exist for 3 times in 10 cycles then exec "/usr/local/bin/pagerduty-trigger frontendlogger"
  else if succeeded then exec "/usr/local/bin/pagerduty-trigger frontendlogger"
  if changed pid for 3 times in 10 cycles then exec "/usr/local/bin/pagerduty-trigger frontendlogger"
  else if succeeded then exec "/usr/local/bin/pagerduty-trigger frontendlogger"
  if memory > 70 MB for 3 cycles then exec "/usr/local/bin/pagerduty-trigger frontendlogger"
  else succeeded then exec "/usr/local/bin/pagerduty-trigger frontendlogger"
  if cpu > 1% for 3 cycles then exec "/usr/local/bin/pagerduty-trigger frontendlogger"
  else if succeeded then exec "/usr/local/bin/pagerduty-trigger frontendlogger"
----- END -----


From: monit-general <monit-general-bounces+mehul.ved=address@hidden> on behalf of Rui Lapa <address@hidden>
Sent: Thursday, June 16, 2016 4:49 PM
To: This is the general mailing list for monit
Subject: Re: Syntax for else if
 
ELSE IF SUCCEEDED THEN
not
ELSE IF <test> THEN

On Thu, Jun 16, 2016 at 11:17 AM, Mehul Ved <address@hidden> wrote:

Hello,

  I am configuring pagerduty integration with monit and have run into a roadblock while setting it up. As per the pagerduty documentation,

- to trigger a new incident, we need to add

if does not exist for 3 cycles
        then exec "/etc/monit/pagerduty-trigger crond"
which works fine.


- to automatically mark the issue as resolved, we need to add

    else if passed for 3 cycles
        then exec "/etc/monit/pagerduty-resolve crond"
but this causes syntax error.


So, I looked up the monit documentation at https://mmonit.com/monit/documentation/monit.html and it shows the following syntax:

IF <test> THEN <action> [ELSE IF SUCCEEDED THEN <action>]
and this causes validation error as well.

I went through the changelog as well as the issue list on bitbucket but failed to find any information on the same. Has anything changed? Did I miss something here?

Version 5.18. NAME; SYNOPSIS; DESCRIPTION; WHAT TO MONITOR? GENERAL OPERATION. Options; Arguments; THE MONIT CONTROL FILE. Service checks. Process; File; Fifo; Filesystem


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general



--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/IT d(+) s++:- a C++$ ULC(+)>+++$ !P--- L+>$ !E---? W+++$ !N* !o-- K--? w(+) !O---? !M- !V--? PS+? !PE Y+ PGP++>+++ !t-- !5 !X- R(+)>++* tv-? b(-) DI !D- G(+)>+ e+++ h--() r->$ y?*
------END GEEK CODE BLOCK------

reply via email to

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