Monit Updates and Release Notes documents a "repeat every cycle" option that does not parse
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)
-
-
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
-
Hello,
I create the pull request #128, Test option "repeat every cycle" is not handled
to fix the little glitch in the l.l file.
Lutz
-
repo owner - changed status to resolved
Fixed with PR from Lutz. Will be part of next release
- Log in to comment
Hello,
the manual explain the syntax correct, see chapter “Service Tests”, “Action”.
The release/fix documentation does not fit only.
Lutz