monit-dev
[Top][All Lists]
Advanced

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

Re: environment variables


From: Jan-Henrik Haukeland
Subject: Re: environment variables
Date: Mon, 30 Jun 2003 04:39:12 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Civil Service, linux)

Jan-Henrik Haukeland <address@hidden> writes:

> BTW, when I write this a couple of things occurs to me to fine tune
> stuff.
>
>  1) The Alert_T object should be renamed to Event_T

Ehh no, that would be wrong. Alert_T is *not* an event. Alert_T is a
placeholder for registering those events you are interested in. For
instance if you are interested in a checksum event Alert.do_checksum
is TRUE. An event is simply an integer e.g. #define DO_TIMEOUT 0

Optionally we could make a really Event_T object like this

typedef struct myevent {
  int id; // The event type [DO_STOP, DO_TIMEOUT ...]
  Service_T source; // The Service the event occured on
  char message[STRLEN]; // Optional descripton of the event
} Event_T;

handle_event would then have this signature:

int handle_event(Event_T event);


and calling code will look like this


    Service_T s;
     
    ...

    Event_T e;
    
    e.id= TIMEOUT; // Skipping the DO_ prefix. Maybe call it EVENT_TIMEOUT?
    e.source= s;
    strncpy(e.message, "Process timed out", STRLEN);

    // Send the event
    handle_event(e);
    
 
In handle event the code could look like:

int handle_event(Event_T event) {

   ASSERT(e);

   // Handle actions
   switch(e.id) {

     case TIMEOUT: e.source->do_validate= FALSE;
     case STOP:    check_service(e.source->name, "stop");
     case start:   check_service(e.source->name, "start");  


   }

   // Handle alert
   if(e.source->maillist) { as before }

   //Handle exec
   if(e.source->execlist) { spawn every Command_T in the list }

}



Beautiful?

-- 
Jan-Henrik Haukeland




reply via email to

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