Writing Monitors for the Event Monitoring Service (December 1999)
116 Chapter3
Creating a Resource Monitor
Processing a Resource Update Event
if (strcmp(state, UP_STATE_NAME) == 0) {
rc = rm_set(state_obj, RmStateValue, 0, &error_code);
if (rc == -1) {
rm_perror(“Error in rm_set“, error_code);
return -1;
}
}
else if (strcmp(state, DOWN_STATE_NAME) == 0) {
rc = rm_set(state_obj, RmStateValue, 1, &error_code);
if (rc == -1) {
rm_perror(“Error in rm_set“, error_code);
return -1;
}
}
else if (strcmp(state, UNKNOWN_STATE_NAME) == 0) {
rc = rm_set(state_obj, RmStateValue, 2, &error_code);
if (rc == -1) {
rm_perror(“Error in rm_set“, error_code);
return -1;
}
}
else {
/*********************************************************************/
/* This case would be used if get_resource_value returns */
/* an unexpected value. */
/*********************************************************************/
rc = rm_set(obj, RmResourceType, RM_ERROR_TYPE, &error_code);
if (rc == -1) {
rm_perror(“Error in rm_set“, error_code);
return -1;
}
}
}
else if (strcmp(resource_name, “/samples/string”) == 0) {
/*************************************************************************/
/* Get the current time. */
/*************************************************************************/