Writing Monitors for the Event Monitoring Service (December 1999)
Chapter 3 63
Creating a Resource Monitor
Writing the Monitor
Log File Recommendations
To log error messages, log to the api.log using the rm_log() function.
Startup and Initialization Considerations
This section describes the startup and initialization sequence performed
by EMS. For proper operation of your resource monitor, ensure that your
monitor does not conflict with the actions of the Registrar.
Registrar Considerations
The registrar is started via inetd(1M). To allow this to happen, the
registrar needs a known port number assignment.
At installation, the Registrar’s reserved port number is added to the
/etc/services file. The entry is as follows:
registrar 1712/tcp # resource monitoring service
registrar 1712/udp # resource monitoring service
NOTE The registrar does not actually use its UDP listening port. It is included
only because the Internet Assigned Numbers Authority (IANA) prefers
to assign ports in pairs
If the appropriate resource monitor process is not found, the registrar
starts the process and waits until the resource monitor can communicate
with the registrar. The resource monitor is ready to communicatewhen it
has called rm_monitor_start() and rm_get_next_event().
In order to minimize potential timeouts when communicating with a
monitor, call rm_monitor_start and rm_get_next_event (in that order)
as soon as possible in your monitor code.
EMS starts a new instance of a resource monitor if no running processes
exactly match the path name and arguments specified after the MONITOR
keyword in the resource dictionary. EMS hashes the complete command
line into a unique number. A named pipe is created in
/etc/opt/resmon/pipe with this number as its name. When the
registrar needs to communicate with a monitor, it checks to see whether
any process is reading from the corresponding named pipe. If so, it begins
communicating with that process. Otherwise, it starts the monitor in a
way that causes the monitor to open a named pipe. For this reason,