monit-dev
[Top][All Lists]
Advanced

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

Re: environment variables


From: Martin Pala
Subject: Re: environment variables
Date: Mon, 30 Jun 2003 16:30:53 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225

Jan-Henrik Haukeland wrote:

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?

Looks good (and +1 for it). I though about the same structure (Event_T) too during event driven model discussion - i think it is as simple as possible.

Btw. the change of DO_* to EVENT_* is good - i'm +1 with proposed changes

Martin







reply via email to

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