Writing Monitors for the Event Monitoring Service (December 1999)
130 Chapter3
Creating a Resource Monitor
Deļ¬ning an Internal Timeout
void ems_wait_for_request (int *status)
{
rm_object_addr obj; /* EMS object address */
rm_return_type ems_response; /* EMS response to rm_get_next_event */
rm_error_type error_code; /* Error returned from EMS API calls */
rm_select_type registered_fds; /* File descriptor bit mask for select() */
rm_select_type select_data; /* Contains timeout & fds for select() */
struct timeval timer; /* Polling interval timeout */
time_t start_time; /* Time when the last interval started */
time_t timeout; /* polling interval */
int done = FALSE; /* "while loop" breakout variable */
int ev_status; /* evlib return status */
int ev_pipe_fd; /* The pipe file desc for the diag FIFO */
static int reported_nohw=FALSE; /* Flag for reporting no-hw only once */
/* initialize the set of file descriptors passed to the select */
/* */
FD_ZERO (®istered_fds.writefds);
FD_ZERO (®istered_fds.exceptfds);
FD_ZERO (®istered_fds.readfds);
timeout = (time_t)LGtimerval;
/* get the diaglogd pipe file descriptor */
/* */
get_filedes (&ev_pipe_fd);
/* add calls to FD_SET for other fd's of interest at this point */
/* in this case, we want to break out of the rm_get_next_event when */
/* diaglogd has log data on the pipe (fifo). */
/* */
if (ev_pipe_fd >= 0)
{
FD_SET ((unsigned)ev_pipe_fd, (fd_set *)®istered_fds.readfds);
}
/*
** Initialize the timer with the desired internal timeout interval.
*/
select_data.timeout = (struct timeval *)NULL;
if (timeout > 0)
{