/[monit]/monit/p.y
ViewVC logotype

Diff of /monit/p.y

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.100 by martinp, Wed Aug 6 13:10:51 2003 UTC revision 1.101 by martinp, Wed Aug 6 14:51:13 2003 UTC
# Line 110  Line 110 
110    };    };
111    
112    struct TimestampSet {    struct TimestampSet {
     char *pathname;  
113      int  operator;      int  operator;
114      int  time;      int  time;
115      int  test_changes;      int  test_changes;
# Line 155  Line 154 
154     SSL_VERSION_AUTO, NULL, NULL, NULL, NULL, ACTION_ALERT, NET_TIMEOUT};     SSL_VERSION_AUTO, NULL, NULL, NULL, NULL, ACTION_ALERT, NET_TIMEOUT};
155    static struct ResourceSet resourceset= {0, 0, OPERATOR_EQUAL, 1,    static struct ResourceSet resourceset= {0, 0, OPERATOR_EQUAL, 1,
156      ACTION_ALERT};      ACTION_ALERT};
157    static struct TimestampSet timestampset= {NULL, OPERATOR_EQUAL, 0, 0,    static struct TimestampSet timestampset= {OPERATOR_EQUAL, 0, 0, ACTION_ALERT};
     ACTION_ALERT};  
158    static struct SizeSet sizeset= {OPERATOR_EQUAL, 0, 0, ACTION_ALERT};    static struct SizeSet sizeset= {OPERATOR_EQUAL, 0, 0, ACTION_ALERT};
159    static struct DeviceSet deviceset= {0, OPERATOR_EQUAL, -1, -1, ACTION_ALERT};    static struct DeviceSet deviceset= {0, OPERATOR_EQUAL, -1, -1, ACTION_ALERT};
160    
# Line 166  Line 164 
164    static void addmail(char *, Mail_T, unsigned int);    static void addmail(char *, Mail_T, unsigned int);
165    static void createservice(int, char *, char *);    static void createservice(int, char *, char *);
166    static void adddependant(char *);    static void adddependant(char *);
167    static void addchecksum(char *, char *);    static void addchecksum(char *);
168    static void addport(struct PortSet *);    static void addport(struct PortSet *);
169    static void addresource(struct ResourceSet *);    static void addresource(struct ResourceSet *);
170    static void addtimestamp(struct TimestampSet *);    static void addtimestamp(struct TimestampSet *);
# Line 276  optproc         : start Line 274  optproc         : start
274                     portset.action= $<number>5;                     portset.action= $<number>5;
275                     addport(&portset);                     addport(&portset);
276                    }                    }
                 | timestamp {  
                    addtimestamp(&timestampset);  
                   }  
277                  | timeout                  | timeout
278                  | every                  | every
279                  | alert                  | alert
                 | checksum  
280                  | autostart                  | autostart
281                  | mode                  | mode
282                  | group                  | group
# Line 674  every           : EVERY NUMBER { Line 668  every           : EVERY NUMBER {
668                   }                   }
669                  ;                  ;
670    
671  checksum        : CHECKSUM checksumlist { current->def_checksum= TRUE; }  checksum        : CHECKSUM               { addchecksum(NULL); }
672                  ;                  | CHECKSUM EXPECT STRING { addchecksum($3); }
   
 checksumlist    : program  
                 | checksumlist program  
                 ;  
   
 program         : PATH { addchecksum($1, NULL); }  
                 | PATH EXPECT STRING { addchecksum($1, $3); }  
673                  ;                  ;
674    
675  autostart       : AUTOSTART {  autostart       : AUTOSTART {
# Line 778  resourcecycle   : /* EMPTY */ Line 765  resourcecycle   : /* EMPTY */
765                  | NUMBER { resourceset.max_cycle= $1; }                  | NUMBER { resourceset.max_cycle= $1; }
766                  ;                  ;
767    
768  timestamp       : TIMESTAMP PATH operator NUMBER time action {  timestamp       : TIMESTAMP operator NUMBER time action {
769                      timestampset.pathname= $2;                      timestampset.operator= $<number>2;
770                      timestampset.operator= $<number>3;                      timestampset.time= ($3 * $<number>4);
771                      timestampset.time= ($4 * $<number>5);                      timestampset.action= $<number>5;
                     timestampset.action= $<number>6;  
772                      timestampset.test_changes= FALSE;                      timestampset.test_changes= FALSE;
773                    }                    }
774                  | TIMESTAMP PATH CHANGED action {                  | TIMESTAMP CHANGED action {
                     timestampset.pathname= $2;  
775                      timestampset.test_changes= TRUE;                      timestampset.test_changes= TRUE;
776                      timestampset.action= $<number>4;                      timestampset.action= $<number>3;
777                    }                    }
778                  ;                  ;
779    
# Line 1052  static void adddependant(char *dependant Line 1037  static void adddependant(char *dependant
1037    
1038  /*  /*
1039   * Add a filename and its associated md5 checksum   * Add a filename and its associated md5 checksum
1040   * to the current service checksumlist   * to the current service
1041   */   */
1042  static void addchecksum(char *filename, char *sum) {  static void addchecksum(char *sum) {
1043    
1044    Checksum_T c;    if(sum) {
1045    
1046    ASSERT(filename);      current->md5= xstrdup(sum);
1047    
1048    NEW(c);    } else if( !(current->md5= get_md5sum(current->path)) ) {
   c->file= filename;  
     
   if(sum) {  
       
     c->md5= sum;  
1049    
       
   } else if(! set_md5sum(&c->md5, filename)) {  
       
1050      log("%s: Cannot compute a checksum for %s at line %d\n",      log("%s: Cannot compute a checksum for %s at line %d\n",
1051          prog, filename, lineno-1);          prog, current->path, lineno-1);
1052      cfg_errflag++;      cfg_errflag++;
1053    
1054    }    }
1055    
1056        if(current->md5 != NULL)
1057    if (c->md5 != NULL) {      cleanup_md5_string(current->md5);
     
     cleanup_md5_string(c->md5);  
   
   }  
   
   c->next= current->checksumlist;  
   current->checksumlist= c;  
1058    
1059  }  }
1060    
# Line 1235  static void addtimestamp(struct Timestam Line 1205  static void addtimestamp(struct Timestam
1205    ASSERT(ts);    ASSERT(ts);
1206    
1207    NEW(t);    NEW(t);
   t->pathname= ts->pathname;  
1208    t->operator= ts->operator;    t->operator= ts->operator;
1209    t->time= ts->time;    t->time= ts->time;
1210    t->action= ts->action;    t->action= ts->action;
1211    t->test_changes= ts->test_changes;    t->test_changes= ts->test_changes;
1212    
1213    if(t->test_changes) {    if(t->test_changes) {
1214      if(!exist_file(t->pathname)) {      if(!exist_file(current->path)) {
1215        log("%s: The path '%s' used in the TIMESTAMP statement at line %d "        log("%s: The path '%s' used in the TIMESTAMP statement at line %d "
1216            "does not exist\n", prog, t->pathname, lineno-1);            "does not exist\n", prog, current->path, lineno-1);
1217        cfg_errflag++;        cfg_errflag++;
1218      } else if(!(t->timestamp= get_timestamp(t->pathname, S_IFDIR|S_IFREG))) {      } else if(!(t->timestamp= get_timestamp(current->path, S_IFDIR|S_IFREG))) {
1219        log("%s: Cannot get the timestamp for '%s' at line %d -- %s\n",        log("%s: Cannot get the timestamp for '%s' at line %d -- %s\n",
1220            prog, t->pathname, lineno-1, STRERROR);            prog, current->path, lineno-1, STRERROR);
1221        cfg_errflag++;        cfg_errflag++;
1222      }      }
1223    }    }
# Line 1769  static void reset_runmail() { Line 1738  static void reset_runmail() {
1738   */   */
1739  static void reset_timestampset() {  static void reset_timestampset() {
1740    
   timestampset.pathname= NULL;  
1741    timestampset.operator= OPERATOR_EQUAL;    timestampset.operator= OPERATOR_EQUAL;
1742    timestampset.time= 0;    timestampset.time= 0;
1743    timestampset.test_changes= 0;    timestampset.test_changes= 0;

Legend:
Removed from v.1.100  
changed lines
  Added in v.1.101

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26