Writing Monitors for the Event Monitoring Service (December 1999)

68 Chapter3
Creating a Resource Monitor
Writing the Monitor
Sample Code
int register_me(int argc, char **argv)
{
rm_error_type error_code;
if (rm_monitor_start(argc, argv, &error_code) == -1) {
rm_perror(“Error in rm_monitor_start“, error_code);
return -1;
}
/* Supply information about this monitor to EMS. Use the rm_monitor_info */
/* global variable for this purpose. */
if (rm_set(rm_monitor_info, RmMonitorTitle, “Sample Monitor”,
&error_code) == -1) {
rm_perror(“Couldn’t set RmMonitorTitle”, error_code);
return -1;
}
if (rm_set(rm_monitor_info, RmMonitorVersionString, “A.01.00.00”,
&error_code) == -1) {
rm_perror(“Couldn’t set RmMonitorVersionString”, error_code);
return -1;
}
if (rm_set(rm_monitor_info, RmMonitorVendorName, “Hewlett-Packard Co.”,
&error_code) == -1) {
rm_perror(“Couldn’t set RmMonitorVendorName”, error_code);
return -1;
}
/* Note that the next call to rm_set() uses a feature of ANSI/ISO C
* in which multiple character strings are concatenated by the compiler
* into one string.
*/
if (rm_set(rm_monitor_info, RmMonitorDescription,
“The sample monitor provides a template that can be used by resource\n”
“monitor developers to speed the development of resource monitors using\n”
“the Event Monitoring Service (EMS) framework.\n”
“\n”
“This program can monitor five resources. The resource names are:\n”
“string, sbit32, ubit32, float, and enum. The values that are supplied\n”
“for these resources provide examples of each of the resource types\n”
“that are supported by EMS. A resource monitor developer should be\n”
“able to quickly develop a resource monitor based on one or more of\n”
“these sample resources.\n”,
&error_code) == -1) {
rm_perror(“Couldn’t set RmMonitorDescription”, error_code);
return -1;
}
return 0;
}