diff --exclude CVS -ur monit/event.c monit.orig/event.c
--- monit/event.c 2005-07-29 12:25:27.000000000 +0200
+++ monit.orig/event.c 2005-01-06 21:51:49.000000000 +0100
@@ -59,7 +59,6 @@
{EVENT_PERMISSION, "Permission failed", "Permission passed"},
{EVENT_RESOURCE, "Resource limit matched", "Resource limit passed"},
{EVENT_SIZE, "Size failed", "Size passed"},
- {EVENT_MATCH, "Regex match", "No regex match"},
{EVENT_TIMEOUT, "Timeout", "Timeout recovery"},
{EVENT_TIMESTAMP, "Timestamp failed", "Timestamp passed"},
{EVENT_UID, "UID failed", "UID passed"},
diff --exclude CVS -ur monit/event.h monit.orig/event.h
--- monit/event.h 2005-07-29 12:24:29.000000000 +0200
+++ monit.orig/event.h 2005-01-06 21:51:49.000000000 +0100
@@ -38,7 +38,6 @@
#define EVENT_EXEC 0x1000
#define EVENT_CHANGED 0x2000
#define EVENT_ICMP 0x4000
-#define EVENT_MATCH 0x8000
#define EVENT_DESCRIPTION(E) Event_get_description(E)
#define IS_EVENT_SET(value, mask) ((value & mask) != 0)
diff --exclude CVS -ur monit/gc.c monit.orig/gc.c
--- monit/gc.c 2005-08-02 17:58:37.000000000 +0200
+++ monit.orig/gc.c 2005-01-24 02:04:36.000000000 +0100
@@ -50,7 +50,6 @@
static void _gc_inf(Info_T *);
static void _gcpdl(Dependant_T *);
static void _gcso(Size_T *);
-static void _gcmatch(Match_T *);
static void _gcchecksum(Checksum_T *);
static void _gcperm(Perm_T *);
static void _gcuid(Uid_T *);
@@ -174,9 +173,6 @@
if((*s)->sizelist)
_gcso(&(*s)->sizelist);
- if((*s)->matchlist)
- _gcmatch(&(*s)->matchlist);
-
if((*s)->checksum)
_gcchecksum(&(*s)->checksum);
@@ -439,27 +435,6 @@
}
-static void _gcmatch(Match_T *s) {
-
- ASSERT(s);
-
- if((*s)->next)
- _gcmatch(&(*s)->next);
-
- if((*s)->action)
- _gc_eventaction(&(*s)->action);
-
- if((*s)->regex_path)
- FREE((*s)->regex_path);
- if((*s)->regex_string)
- FREE((*s)->regex_string);
- if((*s)->regex_comp)
- FREE((*s)->regex_comp);
-
- FREE(*s);
-
-}
-
static void _gcchecksum(Checksum_T *s) {
diff --exclude CVS -ur monit/http/cervlet.c monit.orig/http/cervlet.c
--- monit/http/cervlet.c 2005-08-02 17:16:04.000000000 +0200
+++ monit.orig/http/cervlet.c 2005-04-05 21:52:57.000000000 +0200
@@ -111,7 +111,6 @@
static void print_service_rules_timestamp(HttpResponse, Service_T);
static void print_service_rules_device(HttpResponse, Service_T);
static void print_service_rules_size(HttpResponse, Service_T);
-static void print_service_rules_match(HttpResponse, Service_T);
static void print_service_rules_checksum(HttpResponse, Service_T);
static void print_service_rules_process(HttpResponse, Service_T);
static void print_service_params_port(HttpResponse, Service_T);
@@ -122,7 +121,6 @@
static void print_service_params_timestamp(HttpResponse, Service_T);
static void print_service_params_device(HttpResponse, Service_T);
static void print_service_params_size(HttpResponse, Service_T);
-static void print_service_params_match(HttpResponse, Service_T);
static void print_service_params_checksum(HttpResponse, Service_T);
static void print_service_params_process(HttpResponse, Service_T);
static void print_status(HttpRequest, HttpResponse);
@@ -776,7 +774,6 @@
print_service_params_timestamp(res, s);
print_service_params_device(res, s);
print_service_params_size(res, s);
- print_service_params_match(res, s);
print_service_params_checksum(res, s);
print_service_params_process(res, s);
@@ -789,7 +786,6 @@
print_service_rules_timestamp(res, s);
print_service_rules_device(res, s);
print_service_rules_size(res, s);
- print_service_rules_match(res, s);
print_service_rules_checksum(res, s);
print_service_rules_process(res, s);
@@ -1309,8 +1305,6 @@
out_print(res, "Resource ");
if(IS_EVENT_SET(r->events, EVENT_SIZE))
out_print(res, "Size ");
- if(IS_EVENT_SET(r->events, EVENT_MATCH))
- out_print(res, "Match ");
if(IS_EVENT_SET(r->events, EVENT_TIMEOUT))
out_print(res, "Timeout ");
if(IS_EVENT_SET(r->events, EVENT_TIMESTAMP))
@@ -1576,28 +1570,6 @@
}
}
-static void print_service_rules_match(HttpResponse res, Service_T s) {
-
- if(s->matchlist) {
-
- Match_T ml;
- EventAction_T a;
-
- for(ml= s->matchlist; ml; ml= ml->next) {
-
- a= ml->action;
-
-
- out_print(res,
- "
Associated regex | If %s match "
- "\"%s\" then %s |
",
- ml->not?"not ":"", ml->regex_string,
- actionnames[a->failed->id]);
-
- }
- }
-}
-
static void print_service_rules_checksum(HttpResponse res, Service_T s) {
@@ -1991,25 +1963,6 @@
}
}
-static void print_service_params_match(HttpResponse res, Service_T s) {
-
- if(s->type == TYPE_FILE) {
-
- if(!Util_hasServiceStatus(s)) {
-
- out_print(res,
- "Match regex | - |
");
-
- } else {
-
- out_print(res,
- "Match regex | %s |
",
- (s->error & EVENT_MATCH)?" color='#ff0000'":"",
- (s->error & EVENT_MATCH)?"yes":"no");
- }
- }
-}
-
static void print_service_params_checksum(HttpResponse res, Service_T s) {
diff --exclude CVS -ur monit/l.l monit.orig/l.l
--- monit/l.l 2005-08-02 16:23:23.000000000 +0200
+++ monit.orig/l.l 2005-04-03 13:56:51.000000000 +0200
@@ -234,9 +234,6 @@
perm(ission)? { return PERMISSION; }
exec(ute)? { return EXEC; }
size { return SIZE; }
-match { return MATCH; }
-not { return NOT; }
-ignore { return IGNORE; }
connection { return CONNECTION; }
unmonitor { return UNMONITOR; }
icmp { return ICMP; }
diff --exclude CVS -ur monit/monit.pod monit.orig/monit.pod
--- monit/monit.pod 2005-08-02 18:32:39.000000000 +0200
+++ monit.orig/monit.pod 2005-04-05 21:52:57.000000000 +0200
@@ -1237,56 +1237,7 @@
check file su with path /bin/su
if size != 95564 then exec "/sbin/ifconfig eth0 down"
-=head2 SPACE TESTING
-
-The match statement allows to check lines of file content against
-a regular expression (regex). In case of a match a action like
-an alarm is triggered. Syntax (keywords are in capital):
-
-=over 4
-
-=item IF [NOT] MATCH {regex|path} THEN action
-
-=back
-
-I is a string containing the extended regular expression.
-See also regex(7).
-
-I is an absolute path to a file containing extended
-regular expression on every line. See also regex(7).
-
-I is a choice of "ALERT", "RESTART", "START", "STOP",
-"EXEC" or "UNMONITOR".
-
-You can use the I statement to invert a match.
-
-The content is only being checked every cycle. If content is
-being added and removed during between two check they are
-unnoticed.
-
-On startup the read position is the file end. Upon file size
-decrease and inode change the read position is set to the file
-start.
-
-Only lines ending with a newline character are inspected. Thus,
-lines are being ignored until they have been completed with this
-character.
-
-Only the first 511 characters of a line are inspected any
-following is omitted.
-
-=over 4
-
-=item IGNORE [NOT] MATCH {regex|path}
-
-=back
-
-Lines matching an I are not inspected for later matches.
-I has always precedence over I.
-In first all I statements are evaluated in the
-order of there appearance. In second all I statements
-are evaluated.
=head2 SPACE TESTING
@@ -3449,8 +3400,7 @@
=head1 SEE ALSO
-GNU text utilities; md5sum(1); sha1sum(1); openssl(1); glob(7);
-regex(7)
+GNU text utilities; md5sum(1); sha1sum(1); openssl(1); glob(7)
=cut
diff --exclude CVS -ur monit/monitor.h monit.orig/monitor.h
--- monit/monitor.h 2005-08-02 16:27:47.000000000 +0200
+++ monit.orig/monitor.h 2005-04-23 02:48:40.000000000 +0200
@@ -553,21 +553,6 @@
EventAction_T action; /**< Description of the action upon event occurence */
} *Perm_T;
-/** Defines match object */
-typedef struct mymatch {
- int ignore; /**< Ignore match */
- int not; /**< Invert match */
- char *regex_string; /**< Match string */
- char *regex_path; /**< File with matching rules */
-#ifdef HAVE_REGEX_H
- regex_t *regex_comp; /**< Match compile */
-#endif
- EventAction_T action; /**< Description of the action upon event occurence */
-
- /** For internal use */
- struct mymatch *next; /**< next match in chain */
-} *Match_T;
-
/** Defines uid object */
typedef struct myuid {
@@ -603,7 +588,6 @@
mode_t st_mode; /**< Permission */
uid_t st_uid; /**< Owner's uid */
gid_t st_gid; /**< Owner's gid */
- ino_t st_ino; /**< Inode */
time_t timestamp; /**< Timestamp */
/* Device specific */
@@ -621,8 +605,6 @@
/* File specific */
size_t st_size; /**< Size */
- size_t readpos; /**< Position for regex matching */
- ino_t st_ino_prev; /**< Previous inode for regex matching */
char *cs_sum; /**< Checksum */
/* Process specific */
@@ -639,6 +621,7 @@
int cpu_percent; /**< pecentage * 10 */
int total_cpu_percent; /**< pecentage * 10 */
time_t uptime; /**< Process uptime */
+
} *Info_T;
@@ -677,7 +660,6 @@
Port_T portlist; /**< Portnumbers to check, either local or at a host */
Resource_T resourcelist; /**< Resouce check list */
Size_T sizelist; /**< Size check list */
- Match_T matchlist; /**< Content Match list */
Timestamp_T timestamplist; /**< Timestamp check list */
Uid_T uid; /**< Uid check */
diff --exclude CVS -ur monit/monitrc monit.orig/monitrc
--- monit/monitrc 2005-07-29 17:28:55.000000000 +0200
+++ monit.orig/monitrc 2005-04-01 10:07:33.000000000 +0200
@@ -121,8 +121,6 @@
#
# size -- Must be followed by compare operator, number, optional
# a size unit and an action.
-#
-# match -- Must be followed by a regular expression and an action.
#
# every -- Only check the service at every n cycles.
#
diff --exclude CVS -ur monit/p.y monit.orig/p.y
--- monit/p.y 2005-08-02 18:24:50.000000000 +0200
+++ monit.orig/p.y 2005-04-03 13:56:51.000000000 +0200
@@ -150,7 +150,6 @@
static struct myuid uidset;
static struct myperm permset;
static struct mysize sizeset;
- static struct mymatch matchset;
static struct myicmp icmpset;
static struct mymail mailset;
static struct myport portset;
@@ -189,8 +188,6 @@
static gid_t get_gid(char *, gid_t);
static void addchecksum(Checksum_T);
static void addperm(Perm_T);
- static void addmatch(Match_T, int);
- static void addmatchpath(Match_T, int);
static void adduid(Uid_T);
static void addgid(Gid_T);
static void addeuid(uid_t);
@@ -260,7 +257,7 @@
%token TIMESTAMP CHANGED SECOND MINUTE HOUR DAY
%token SSLAUTO SSLV2 SSLV3 TLSV1 CERTMD5
%token BYTE KILOBYTE MEGABYTE GIGABYTE
-%token INODE SPACE PERMISSION SIZE MATCH NOT IGNORE
+%token INODE SPACE PERMISSION SIZE
%token EXEC UNMONITOR ICMP ICMPECHO NONEXIST INVALID DATA RECOVERED
%token URL CONTENT PID PPID
%token URLOBJECT
@@ -328,7 +325,6 @@
| gid
| checksum
| size
- | match
| mode
| group
| depend
@@ -974,7 +970,6 @@
| PERMISSION { eventset |= EVENT_PERMISSION; }
| RESOURCE { eventset |= EVENT_RESOURCE; }
| SIZE { eventset |= EVENT_SIZE; }
- | MATCH { eventset |= EVENT_MATCH; }
| TIMEOUT { eventset |= EVENT_TIMEOUT; }
| TIMESTAMP { eventset |= EVENT_TIMESTAMP; }
| UID { eventset |= EVENT_UID; }
@@ -1254,43 +1249,8 @@
}
;
-match : IF matchflagnot MATCH PATH THEN action1 {
- matchset.ignore= FALSE;
- matchset.regex_path= xstrdup($4);
- matchset.regex_string= NULL;
- addmatchpath(&matchset, $6);
- }
- | IF matchflagnot MATCH STRING THEN action1 {
- matchset.ignore= FALSE;
- matchset.regex_path= NULL;
- matchset.regex_string= xstrdup($4);
- addmatch(&matchset, $6);
- }
- | IGNORE matchflagnot MATCH PATH {
- matchset.ignore= TRUE;
- matchset.regex_path= xstrdup($4);
- matchset.regex_string= NULL;
- addmatchpath(&matchset, ACTION_IGNORE);
- }
- | IGNORE matchflagnot MATCH STRING {
- matchset.ignore= TRUE;
- matchset.regex_path= NULL;
- matchset.regex_string= xstrdup($4);
- addmatch(&matchset, ACTION_IGNORE);
- }
- ;
-
-matchflagnot : /* empty */ {
- matchset.not= FALSE;
- }
- | NOT {
- matchset.not= TRUE;
- }
- ;
-
-
size : IF SIZE operator NUMBER unit THEN action1 recovery {
- sizeset.operator= $4;
+ sizeset.operator= $3;
sizeset.size= ((unsigned long)$4 * $5);
addeventaction(&(sizeset).action, $7, $8);
addsize(&sizeset, FALSE);
@@ -1937,98 +1897,6 @@
}
-/*
- * Set Match object in the current service
- */
-static void addmatch(Match_T ms, int actionnumber) {
-
- Match_T m;
- Match_T ml;
- int reg_return;
-
- ASSERT(ms);
-
-#ifdef HAVE_REGEX_H
- NEW(m);
- NEW(m->regex_comp);
-
- m->regex_string= ms->regex_string;
- m->regex_path= ms->regex_path;
- m->action= ms->action;
- m->not= ms->not;
- m->ignore= ms->ignore;
- m->next=NULL;
-
- addeventaction(&(m->action), actionnumber, ACTION_IGNORE);
-
- reg_return= regcomp(m->regex_comp, ms->regex_string, REG_NOSUB|REG_EXTENDED);
-
- if (reg_return!=0) {
- char errbuf[STRLEN];
- regerror(reg_return, ms->regex_comp, errbuf, STRLEN);
- yyerror2("regex parsing error:%s", errbuf);
- }
-
- if (current->matchlist) {
- /* Find the end of the list */
- for(ml=current->matchlist; ml->next; ml=ml->next);
-
- ml->next= m;
-
- } else {
-
- current->matchlist= m;
-
- }
-
-#else
- yyerror2("regex matching requires regex support!", );
-#endif
-}
-
-static void addmatchpath(Match_T ms, int actionnumber) {
-
- FILE *handle;
- char buf[STRLEN];
-
- ASSERT(ms->regex_path);
-
- handle=fopen(ms->regex_path, "r");
-
- if ( handle==NULL ) {
-
- yyerror2("cannot read regex match file (%s)", ms->regex_path);
-
- }
-
- while (!feof(handle)) {
-
-
- if (! fgets(buf, STRLEN, handle)) {
-
- continue;
-
- }
-
- if (strlen(buf)==0 || buf[0]=='\n') {
-
- continue;
-
- }
-
- if(buf[strlen(buf)-1]=='\n') {
-
- buf[strlen(buf)-1]=0;
-
- }
-
- ms->regex_string= xstrdup(buf);
- addmatch(ms, actionnumber);
- }
-
- fclose(handle);
-
-}
/*
* Set Uid object in the current service
diff --exclude CVS -ur monit/util.c monit.orig/util.c
--- monit/util.c 2005-08-02 17:17:36.000000000 +0200
+++ monit.orig/util.c 2005-04-12 00:27:53.000000000 +0200
@@ -603,7 +603,6 @@
Resource_T q;
Timestamp_T t;
Size_T sl;
- Match_T ml;
Dependant_T d;
char string[STRLEN];
@@ -759,15 +758,6 @@
}
- for(ml= s->matchlist; ml; ml= ml->next) {
- EventAction_T a= ml->action;
-
- printf(" %-20s = if%s match \"%s\" then %s\n",
- "Regex", ml->not?" not":"",ml->regex_string,
- actionnames[a->failed->id]);
-
- }
-
for(dl= s->devicelist; dl; dl= dl->next) {
EventAction_T a= dl->action;
@@ -1539,12 +1529,10 @@
*/
void Util_resetInfo(Service_T s) {
memset(s->inf, 0, sizeof *(s->inf));
- s->inf->_pid= -1;
- s->inf->_ppid= -1;
- s->inf->pid= -1;
- s->inf->ppid= -1;
- s->inf->st_ino_prev= 0;
- s->inf->readpos= 0;
+ s->inf->_pid= -1;
+ s->inf->_ppid= -1;
+ s->inf->pid= -1;
+ s->inf->ppid= -1;
}
diff --exclude CVS -ur monit/validate.c monit.orig/validate.c
--- monit/validate.c 2005-08-02 17:33:29.000000000 +0200
+++ monit.orig/validate.c 2005-05-11 23:28:02.000000000 +0200
@@ -102,7 +102,6 @@
static void check_gid(Service_T);
static void check_size(Service_T);
static void check_perm(Service_T);
-static void check_match(Service_T);
static int check_skip(Service_T);
static int check_timeout(Service_T);
static void check_checksum(Service_T);
@@ -119,7 +118,6 @@
ProcessTree_T *oldptree=NULL;
int oldptreesize=0;
-#define MATCH_LINE_LENGTH 512
/* ---------------------------------------------------------------- Public */
@@ -284,13 +282,6 @@
return FALSE;
} else {
s->inf->st_mode= stat_buf.st_mode;
- if (s->inf->st_ino==0) {
- s->inf->st_ino_prev= stat_buf.st_ino;
- s->inf->readpos= stat_buf.st_size;
- } else {
- s->inf->st_ino_prev= s->inf->st_ino;
- }
- s->inf->st_ino= stat_buf.st_ino;
s->inf->st_uid= stat_buf.st_uid;
s->inf->st_gid= stat_buf.st_gid;
s->inf->st_size= stat_buf.st_size;
@@ -328,9 +319,6 @@
if(s->timestamplist)
check_timestamp(s);
- if(s->matchlist)
- check_match(s);
-
return TRUE;
}
@@ -962,162 +950,6 @@
}
}
-/**
- * Match content
- */
-static void check_match(Service_T s) {
- Match_T ml;
- char line[MATCH_LINE_LENGTH];
- FILE *file;
- int regex_return;
- int inode_checked=FALSE;
- int advance=0;
- int ignore;
-
- ASSERT(s && s->matchlist);
-
- /* did inode change -> read position = 0 */
- if((inode_checked==FALSE) && (s->inf->st_ino != s->inf->st_ino_prev)) {
- s->inf->readpos= 0;
- }
- inode_checked= TRUE;
-
- /* did file decrease (readpos > file_size) -> read position = 0 */
- if(s->inf->readpos > s->inf->st_size) {
- s->inf->readpos= 0;
- }
-
- /* Do we need to match? (readpos < file_size) */
- if(!(s->inf->readpos < s->inf->st_size)){
- return;
- }
-
- /* Open the file */
- if(NULL==(file=fopen(s->path, "r"))) {
- /* We can't open the file */
- DEBUG("FILE: cannot open file %s: %s!\n", s->path, strerror(errno));
- return;
- }
-
- while (TRUE) {
- ignore=FALSE;
-
- /* Seek to the read position */
- if (fseek(file, s->inf->readpos, SEEK_SET)!=0) {
- /* We can not seek to the read position */
- DEBUG("FILE: cannot seek file %s: %s!\n", s->path, strerror(errno));
- goto final;
- }
-
- if(NULL==fgets(line, MATCH_LINE_LENGTH, file)) {
- /* We can not read the content! */
- if (!feof(file)) {
- DEBUG("FILE: cannot read file %s: %s!\n", s->path, strerror(errno));
- }
- goto final;
- }
-
- /* Close the file */
-
- /* Empty line? Should not happen... but who knows */
- if (strlen(line) == 0) {
- /* ==> ERROR */
- goto final;
- }
-
- /* Complete line oder just beginning? (igore full buffers) */
- if ((strlen(line)<(MATCH_LINE_LENGTH)-1) &&
- (line[strlen(line)-1] != '\n')) {
- /* we gonna read it next time */
- goto final;
- }
-
- advance=strlen(line);
-
- /*
- Does this line end with '\n'? Otherwise ignore and check it
- as soon as it is complete
- */
- if (strlen(line)==(MATCH_LINE_LENGTH)-1) {
- int rv=0;
-
- while (((unsigned char) rv != '\n') && (rv!=EOF)) {
- rv=fgetc(file);
- advance++;
- }
-
- if (rv==EOF) {
- break;
- }
- }
-
- /* Set read position to the end of last read */
- s->inf->readpos+=advance;
-
- /* Remove appending newline */
- if (line[strlen(line)-1] == '\n') {
- line[strlen(line)-1] = 0;
- }
-
- /* Check ignores */
- for(ml= s->matchlist; ml; ml= ml->next) {
- if (ml->ignore) {
- regex_return=regexec(ml->regex_comp,
- line,
- 0,
- NULL,
- 0);
-
- if((regex_return==0) ^ (ml->not)) {
- /* We match! -> line is ignored! */
- DEBUG("FILE: Regular expression %s\"%s\" "
- "ignore match on content line\n",
- ml->not?"not ":"",
- ml->regex_string);
- ignore=TRUE;
- break;
- }
- }
- }
-
- if(ignore)
- continue;
-
- /* Check rest */
- for(ml= s->matchlist; ml; ml= ml->next) {
- if (!(ml->ignore)) {
- regex_return=regexec(ml->regex_comp,
- line,
- 0,
- NULL,
- 0);
-
- if((regex_return==0) ^ (ml->not)) {
- /* We match! */
- Event_post(s, EVENT_MATCH, TRUE, ml->action,
- "'%s' content line matches regular expression!\n"
- "Regular expression:\n"
- "%s\n"
- "Content:\n"
- "%s",
- s->name, ml->regex_string, line);
-
- /* ==> more talkative! */
- } else {
- DEBUG("FILE: Regular expression %s\"%s\" "
- "does not match on content line\n",
- ml->not?"not ":"",
- ml->regex_string);
- }
- }
- }
-
- }
-
- final:
-
- fclose(file);
-}
/**
* Device test