Writing Monitors for the Event Monitoring Service (December 1999)
92 Chapter3
Creating a Resource Monitor
Processing a Subclass Request Event
/*************************************************************************/
/* 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 in rm_set“, error_code);
return -1;
}
/*************************************************************************/
/* Define the state called “UP”, which has a value of 0. */
/*************************************************************************/
state_obj = rm_create(RM_RESOURCE_STATE_OBJECT, &error_code);
if (!state_obj) {
rm_perror(“Error in rm_create“, error_code);
return -1;
}
rc = rm_set(obj, RmDescription, “This resource is always \”UP\”.”,
&error_code);
if (rc == -1) {
rm_perror(“Error in rm_set“, error_code);
return -1;
}
rc = rm_set(state_obj, RmStateValue, UP_STATE_VALUE, &error_code);
if (rc == -1) {
rm_perror(“Error in rm_set“, error_code);
return -1;
}
rc = rm_set(state_obj, RmStateName, UP_STATE_NAME, &error_code);
if (rc == -1) {
rm_perror(“Error in rm_set“, error_code);
return -1;
}
rc = rm_set(obj, RmStateObject, state_obj, &error_code);
if (rc == -1) {
rm_perror(“Error in rm_set“, error_code);
return -1;
}