Writing Monitors for the Event Monitoring Service (December 1999)
Chapter 3 115
Creating a Resource Monitor
Processing a Resource Update Event
rm_get(obj, RmResourceName, &resource_name, &error_code);
/*************************************************************************/
/* Check that the resource value requested is one we support. */
/*************************************************************************/
if (strcmp(resource_name, “/samples/enum”) == 0) {
/***********************************************************************/
/* Resource-specific function. (This one always returns “UP”). */
/***********************************************************************/
get_resource_value(state);
/***********************************************************************/
/* The resource is an Enumerated Type, so we must use the State */
/* object to store the data. */
/* */
/* The mapping of state names and values is as follows: */
/* UP = 0 */
/* DOWN = 1 */
/* UNKNOWN = 2 */
/***********************************************************************/
state_obj = rm_create(RM_RESOURCE_STATE_OBJECT, &error_code);
rc = rm_set(state_obj, RmStateName, state, &error_code);
if (rc == -1) {
rm_perror(“Error in rm_set“, error_code);
return -1;
}
rc = rm_set(obj, RmResourceType, RM_ENUMERATED_TYPE, &error_code);
if (rc == -1) {
rm_perror(“Error in rm_set“, error_code);
return -1;
}
rc = rm_set(obj, RmResourceValue, &state_obj, &error_code);
if (rc == -1) {
rm_perror(“Error in rm_set“, error_code);
return -1;
}