Monit Updates and Release Notes documents a "repeat every cycle" option that does not parse

Issue #1042 resolved
Mike Timm created an issue

For the 5.16.0 release changes this is documented:


  • Fixed: The exec action is now executed only once on state change, the same way as the alert action. The new repeat option can be used to repeat the exec action after a given number of cycles if the error persists. Syntax:

    ``` if <test> then exec <script> [repeat every [x] cycle(s)]

    ```

    If you want the old behaviour, use "repeat every cycle". Example:

    if failed port 1234 then exec "/usr/bin/myscript.sh" repeat every cycle


The example should have a 1 between “every” and “cycle.” If you try the example as it is written it does not parse:

[myuser@myhost ~]$ sudo monit -t /etc/monit.d/test.conf
/etc/monit.d/test.conf:2: invalid every format 'c'
/etc/monit.d/test.conf:2: syntax error 'ycle'
[myuser@myhost ~]$

Comments (4)

  1. Lutz Mader

    Hello,
    the manual explain the syntax correct, see chapter “Service Tests”, “Action”.
    The release/fix documentation does not fit only.

    Lutz

  2. Lutz Mader

    Hello,
    you are right, this is a little bug in l.l to handle "every cycle".

    In p.y, "repeat" is defined with

    repeat          : /* EMPTY */ {
                            repeat = 0;
                      }
                    | REPEAT EVERY CYCLE {
                            repeat = 1;
                      }
    

    Unfortunately in l.l, "cycle" is not handled because

    every             {
                        BEGIN(EVERY_COND);
                        return EVERY;
                      }
    :
    
    <EVERY_COND>{
    
      {ws}            ;
    
    :
    ==>> new code
      cycle(s)?       {
                        BEGIN(INITIAL);
                        return CYCLE;
                      }
    <<==
      .               {
                          BEGIN(INITIAL);
                          yyerror("invalid every format");
                      }
    
    }
    

    "every" switch to condition "every_cond" but "cycle(s)?" is handled in the normal state only. But with an additional "cycle(s)?" in the state "every_cond" every thing works, "repeat every cycle" work like suggested in the release/fix documentation.

    Nice to see, I’ll add a pull request to fix this.

    Lutz

  3. Log in to comment