Common subdirectories: monit-2.5.orig/contrib and monit-2.5/contrib Common subdirectories: monit-2.5.orig/doc and monit-2.5/doc Common subdirectories: monit-2.5.orig/http and monit-2.5/http diff -u monit-2.5.orig/monitor.h.in monit-2.5/monitor.h.in --- monit-2.5.orig/monitor.h.in Thu Jul 11 13:44:55 2002 +++ monit-2.5/monitor.h.in Thu Jul 11 17:51:42 2002 @@ -136,6 +136,7 @@ typedef struct mychecksum { char *file; /**< A filename to compute a md5 checksum for */ char *md5; /**< A md5 checksum computed for the file */ + time_t last_ctime; /**< The ctime of the file when checked last time */ /** For internal use */ struct mychecksum *next; /**< next checksum in chain */ diff -u monit-2.5.orig/p.y monit-2.5/p.y --- monit-2.5.orig/p.y Wed Jul 10 22:48:44 2002 +++ monit-2.5/p.y Fri Jul 12 10:13:04 2002 @@ -40,6 +40,7 @@ #include #include #include +#include #include "net.h" #include "monitor.h" @@ -523,18 +524,33 @@ static void addchecksum(char *filename, char *sum) { Checksum_T c= NEW(c); + struct stat stat_buf; + c->file= filename; if ( sum ) { c->md5= sum; - + } else if ( ! set_md5sum(&c->md5, filename) ) { error("%s: Cannot compute a checksum for %s at line %d\n", prog, filename, lineno-1); cfg_errflag++; + + } + + if ( stat(filename, &stat_buf) != 0 ) { + + error("%s: Cannot stat %s at line %d\n", + prog, filename, lineno-1); + cfg_errflag++; + c->last_ctime=0; + + } else { + + c->last_ctime=stat_buf.st_ctime; } Common subdirectories: monit-2.5.orig/protocols and monit-2.5/protocols diff -u monit-2.5.orig/util.c monit-2.5/util.c --- monit-2.5.orig/util.c Thu Jul 11 13:59:00 2002 +++ monit-2.5/util.c Fri Jul 12 10:38:04 2002 @@ -301,6 +301,7 @@ Port_T n; Mail_T r; Checksum_T c; + char *buf = xmalloc(STRLEN); printf("%-21s = %s\n", "Process Name", p->name); printf(" %-20s = %s\n", "Group", is_str_defined(p->group)); @@ -311,6 +312,8 @@ for (c= p->checksumlist; c; c= c->next) { printf(" %-20s = %s %s\n", "Checksum", c->md5, c->file); + strftime(buf, STRLEN,"%Y/%m/%d %H:%M", localtime(&c->last_ctime)); + printf(" %-20s = %s %s\n", "Last File Change", buf, c->file); } @@ -374,7 +377,8 @@ printf(" %-20s = %s\n", "Autostart", p->do_validate?"yes":"no"); printf("\n"); - + + free(buf); } diff -u monit-2.5.orig/validate.c monit-2.5/validate.c --- monit-2.5.orig/validate.c Sun Jul 7 21:48:15 2002 +++ monit-2.5/validate.c Fri Jul 12 10:09:42 2002 @@ -25,6 +25,7 @@ #include #include #include +#include #include "monitor.h" #include "net.h" @@ -383,6 +384,7 @@ static int check_checksum(Process_T p) { Checksum_T c; + struct stat stat_buf; if ( !p->def_checksum ) { @@ -391,7 +393,43 @@ } for ( c= p->checksumlist; c; c= c->next ) { - + + if ( stat(c->file, &stat_buf) != 0 ) { + + /* No stat no file! */ + + if ( Run.debug ) { + + log("'%s' is not statable\n", c->file); + + } + + return TRUE; + + } + + if ( stat_buf.st_ctime == c->last_ctime ) { + + if ( Run.debug ) { + + log("'%s' ctime is still the same %d\n", c->file, stat_buf.st_ctime); + + } + + return FALSE; + + } else { + + if ( Run.debug ) { + + log("'%s' ctime has changed \n", c->file); + + } + + c->last_ctime = stat_buf.st_ctime; + + } + if ( ! checksum_helper(p, c->file, c->md5) ) { return TRUE;