Writing Monitors for the Event Monitoring Service (December 1999)
Chapter 3 87
Creating a Resource Monitor
Processing a Subclass Request Event
int send_subclass_reply(rm_object_addr obj)
{
rm_error_type error_code;
char *resource_name;
rm_object_addr subclass, state_obj;
int rc;
rm_get(obj, RmResourceName, &resource_name, &error_code);
/*************************************************************************/
/* Check that the resource requested is one we support. */
/*************************************************************************/
if (strcmp(resource_name, “/samples”) == 0) {
/***********************************************************************/
/* The resource name is the resource class we support. Set all of */
/* the required fields in the object, and create subclass children */
/* of this object. */
/***********************************************************************/
rc = rm_set(obj, RmDescription, “A sample resource class”, &error_code);
if (rc == -1) {
rm_perror(“Error in rm_set“, error_code);
return -1;
}
rc = rm_set(obj, RmResourceType, RM_RESOURCE_CLASS_TYPE, &error_code);
if (rc == -1) {
rm_perror(“Error in rm_set“, error_code);
return -1;
}
/***********************************************************************/
/* Define the names of the resource instances that exist below this */
/* resource class. */
/* */
/* One resource instance is called “string”. */
/***********************************************************************/
subclass = rm_create(RM_SUBCLASS_CHILD_OBJECT, &error_code);
if (!subclass) {
rm_perror(“Error in rm_create“, error_code);
return -1;
}