monit-dev
[Top][All Lists]
Advanced

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

Re: syntax change proposal


From: Martin Pala
Subject: Re: syntax change proposal
Date: Wed, 31 Mar 2004 01:55:39 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040312 Debian/1.6-3

Here is the solution. If you agree, i can sync it. This patch solves the only drawback in new event engine which i knew about.

I have implemented variable test rule types in addition to constant types for 'size', 'checksum' and 'timestamp' tests only.

I think variable rule is not needed for other types, such as 'uid', 'gid' and 'permission' - however it is easy to implement it for these tests too, if you want to.

Taken from new CHANGES.txt:

--8<--
NEW FEATURES AND FUNCTIONS:
...
*  Monit now supports variable and constant object tests. Constant
   object tests are related to failed/passed state and usualy beggins
   with 'IF FAILED' statement. Variable objects beggins with
  'IF CHANGED' statement and serves for monitoring of object, which
   property can change legaly - you can use it just for alert or
   to involve some automatic action, as for example to reload monitored
   process after its configuration file was changed. Variable tests
   are supported for 'checksum', 'size' and 'timestamp' tests only,
   if you consider that other tests can be useful in variable form
   too, please let us know.
...

BACKWARD INCOMPATIBLE CHANGES:
*  Syntax and behavior of 'checksum' test changed.
   Monit supports two classes of these tests: either constant or variable.
   Old syntax:
     IF FAILED [hashtype] CHECKSUM [EXPECT STRING] THEN action
   New constant test syntax:
     IF FAILED [hashtype] CHECKSUM [EXPECT STRING] THEN action
    [ELSE IF RECOVERED THEN action]
   New variable rule syntax:
     IF CHANGED [hashtype] CHECKSUM THEN action
   It affects following construct:
     CHECK FILE httpd.conf WITH PATH /usr/local/apache/conf/httpd.conf
IF FAILED CHECKSUM THEN EXEC "/usr/local/apache/bin/apachectl graceful"
   In previous monit version this configuration caused the apache reload
   on monitored configuration file change. Then the value was reseted so
   the test passed next cycles until the file was changed again. Refactored
event engine monitors for checksum value recovery, i.e whether it changed
   to the original value - in such case it will evaluate recovery action,
   otherwise the test keeps failed state. Because the value in this
   usage context will not correspond to the original, monit will evaluate
   action (reload apache) each cycle until the checksum will recover
   (which is unlikely for configuration file).
   New syntax have to be used for the same result:
     CHECK FILE httpd.conf WITH PATH /usr/local/apache/conf/httpd.conf
IF CHANGED CHECKSUM THEN EXEC "/usr/local/apache/bin/apachectl graceful"

*  Syntax and behavior of 'size' test changed.
   Old syntax:
     IF SIZE {CHANGED|operator NUMBER size} THEN action
   New constant test syntax:
     IF FAILED SIZE [operator NUMBER unit] THEN action
    [ELSE IF RECOVERED THEN action]
   New variable rule syntax:
     IF CHANGED SIZE THEN action
The behavior relationship is similar as described for checksum test above.

*  Syntax and behavior of 'timestamp' test changed.
   Old syntax:
     IF TIMESTAMP {CHANGED|operator NUMBER time} THEN action
   New constant test syntax:
     IF FAILED TIMESTAMP [operator NUMBER time] THEN action
    [ELSE IF RECOVERED THEN action]
   New variable rule syntax:
     IF CHANGED TIMESTAMP THEN action
The behavior relationship is similar as described for checksum test above.
--8<--


Martin

Martin Pala wrote:
Hi,

i though about solution of event refactoring side effect - it is described in CHANGES.txt (in cvs):

--8<--
Monit doesn't reset checksum, timestamp, size, uid, gid or permission
value after detected failure. This way monit is able to watch for
value recovery - on the other side following construct behavior
changed:

CHECK FILE httpd.conf WITH PATH /usr/local/apache/conf/httpd.conf
 IF FAILED CHECKSUM THEN EXEC "/usr/local/apache/bin/apachectl graceful"

In previous monit version this configuration caused the apache reload
on monitored configuration file change. Then the value was reseted so
the test passed next cycles until the file was changed again.
Refactored event engine monitors for checksum value recovery, i.e whether it changed to the original value - in such case it will evaluate recovery action, otherwise the test keeps failed state. Because the value in this usage context will not correspond to the original, monit will evaluate action (reload apache) each cycle until the checksum will recover (which is unlikely for configuration file).
--8<--

Problem is in present syntax. I think it will be good to strictly separate 'changes' and 'failed' aimed tests, and generaly consolidate syntax like this:

(1) IF FAILED rule THEN action [ELSE IF RECOVERED THEN action]
(2) IF CHANGED rule THEN action

... in the case (1) will monit watch constant value of 'rule' in the failed/passed state sense.

... in the case (2) is monit aimed to changes only, i.e. the rule variable value is reseted and action evaluated each time its change is detected.


This will involve syntax change of 'checksum', 'size' and 'timestamp' tests syntax, which are ommiting FAILED word in the rule definition currently.

For example suppose timestamp test:

PRESENT SYNTAX:
  IF TIMESTAMP [CHANGED|operator NUMBER value] THEN action
 [ELSE IF RECOVERED THEN action]

PROPOSED SYNTAX:
1.) constant value test:
  IF FAILED TIMESTAMP [operator NUMBER value] THEN action
 [ELSE IF RECOVERED THEN action]

2.) variable value test (aimed to testing changes - value is reseted):
  IF CHANGED TIMESTAMP THEN action


What do you think?

Martin


_______________________________________________
monit-dev mailing list
address@hidden
http://mail.nongnu.org/mailman/listinfo/monit-dev

Attachment: test_changes.patch
Description: application/unknown


reply via email to

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