Writing Monitors for the Event Monitoring Service (December 1999)

Chapter 3 105
Creating a Resource Monitor
Processing a Monitor Request Event
else if (strcmp(resource_name, "/samples/enum") == 0)
{
/*************************************************************************/
/* The "enum" resource instance is an enumerated type resource that */
/* can assume the values "UP", "DOWN", and "UNKNOWN". */
/*************************************************************************/
rc = rm_set(obj, RmResourceType, RM_ENUMERATED_TYPE, &error_code);
if (rc == -1) {
rm_perror("", error_code);
return -1;
}
}
else {
/***********************************************************************/
/* This is not a resource we support. */
/***********************************************************************/
error_reply = 1;
rc = rm_set(obj, RmMonitorReply, RM_RESOURCE_NOT_SUPPORTED, &error_code);
if (rc == -1) {
rm_perror("", error_code);
return -1;
}
}
/*************************************************************************/
/* Check the polling interval for the resources we support. */
/* The sampmon resources above enforce a minimum polling interval of */
/* 5 seconds. If something less is requested, the request will be */
/* rejected and the minimum will be supplied in the reply. */
/*************************************************************************/
if (!error_reply) {
rm_get(obj, RmPollingInterval, &polling_int, &error_code);
if (polling_int < POLLING_MINIMUM) {
rc = rm_set(obj, RmMonitorReply, RM_POLLTIME, &error_code);
if (rc == -1) {
rm_perror("", error_code);
return -1;
}
rc = rm_set(obj, RmPollingMinimum, POLLING_MINIMUM, &error_code);
if (rc == -1) {
rm_perror("", error_code);
return -1;
}
}
}