/[monit]/monit/event.c
ViewVC logotype

Diff of /monit/event.c

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

revision 1.8 by hauk, Thu Jul 24 00:50:18 2003 UTC revision 1.9 by hauk, Fri Jul 25 12:19:57 2003 UTC
# Line 35  Line 35 
35  /**  /**
36   * Implementation of the event interface.   * Implementation of the event interface.
37   *   *
  * NOTE: Some event handlers are placed as functions in this file. In  
  * the future and if there is a need for more flexibility; It is easy  
  * to setup event handlers as callback functions and register them in  
  * this class. Every event handler will have this signature:  
  *  
  *   void handle_xxx_event(Event_T E);  
  *  
38   * @author Jan-Henrik Haukeland, <hauk@tildeslash.com>   * @author Jan-Henrik Haukeland, <hauk@tildeslash.com>
39   * @version \$Id$   * @version \$Id$
40   * @file   * @file
# Line 82  static void handle_start(Event_T E); Line 75  static void handle_start(Event_T E);
75  static void handle_restart(Event_T E);  static void handle_restart(Event_T E);
76  static void handle_timeout(Event_T E);  static void handle_timeout(Event_T E);
77  static void handle_checksum(Event_T E);  static void handle_checksum(Event_T E);
78  static void handle_exec_event(Event_T E);  static void handle_resource(Event_T E);
79    static void handle_timestamp(Event_T E);
80    
81    
82  /* ------------------------------------------------------------------ Public */  /* ------------------------------------------------------------------ Public */
# Line 220  static void handle_event(Event_T E) { Line 214  static void handle_event(Event_T E) {
214    ASSERT(E);    ASSERT(E);
215    
216    switch(E->id) {    switch(E->id) {
217    case EVENT_STOP:    handle_stop(E); break;    case EVENT_STOP:      handle_stop(E); break;
218    case EVENT_START:   handle_start(E); break;    case EVENT_START:     handle_start(E); break;
219    case EVENT_RESTART: handle_restart(E); break;    case EVENT_RESTART:   handle_restart(E); break;
220    case EVENT_TIMEOUT: handle_timeout(E); break;    case EVENT_TIMEOUT:   handle_timeout(E); break;
221    case EVENT_CHECKSUM: handle_checksum(E); break;    case EVENT_CHECKSUM:  handle_checksum(E); break;
222      case EVENT_RESOURCE:  handle_resource(E); break;
223      case EVENT_TIMESTAMP: handle_timestamp(E); break;
224    }    }
225        
226    if(E->id != EVENT_NULL) {    if(E->id != EVENT_NULL) {
     handle_exec_event(E);  
227      handle_alert_event(E);      handle_alert_event(E);
228    }    }
229        
# Line 299  static void handle_checksum(Event_T E) { Line 294  static void handle_checksum(Event_T E) {
294  }  }
295    
296    
297  /* ------------------------------------------------------------------------- */  static void handle_resource(Event_T E) {
   
   
 static void handle_exec_event(Event_T E) {  
298    
299      Resource_T r;
300    Service_T s= E->source;    Service_T s= E->source;
301    
302    if(Event_get_id(E) == EVENT_TIMESTAMP) {    /* Check for executables to run */
303      Timestamp_T t;    for(r= s->resourcelist; r; r= r->next) {
304      for(t= s->timestamplist; t; t= t->next) {      if(r->event_flag && r->exec != NULL) {
305        if(t->event_flag && t->exec != NULL) {        /* Reset the event_flag so the command is not executed again
306          /* Reset the event_flag so the command is not executed again         * unless the flag is explicit set */
307           * unless the flag is explicit set */        r->event_flag= FALSE;
308          t->event_flag= FALSE;        spawn(s, r->exec);
         spawn(s, t->exec);  
       }  
309      }      }
310    } else if(Event_get_id(E) == EVENT_RESOURCE) {    }
311      Resource_T r;  
312      for(r= s->resourcelist; r; r= r->next) {  }
313        if(r->event_flag && r->exec != NULL) {  
314          r->event_flag= FALSE;  
315          spawn(s, r->exec);  static void handle_timestamp(Event_T E) {
316        }  
317      Timestamp_T t;
318      Service_T s= E->source;
319      
320      /* Check for executables to run */
321      for(t= s->timestamplist; t; t= t->next) {
322        if(t->event_flag && t->exec != NULL) {
323          /* Reset the event_flag so the command is not executed again
324           * unless the flag is explicit set */
325          t->event_flag= FALSE;
326          spawn(s, t->exec);
327      }      }
328    }    }
329    
330  }  }
331    
332    
333    /* ------------------------------------------------------------------------- */
334    
335    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

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