Sun Cluster 3.0 Data Services Developers' Guide

MONITOR_STOP Method

The RGM calls MONITOR_STOP method to stop execution of dns_probe when the sample data service is brought offline.

This section describes the major pieces of the MONITOR_STOP method for the sample application. This section does not describe functionality common to all methods, such as the parse_args function and obtaining the syslog facility, which are described in "Providing Common Functionality to All Methods".

For the complete listing of the MONITOR_STOP method, see "MONITOR_STOP Method Code Listing".

MONITOR_STOP Overview

This method uses the process monitor facility (pmfadm) to see if the probe is running, and if so, to stop it.

Stopping the Monitor

The MONITOR_STOP method uses pmfadm -q to see if the probe is running, and if so, uses pmfadm -s to stop it. If the probe is already stopped, the method exits successfully anyway, which guarantees the idempotency of the method.


# See if the monitor is running, and if so, kill it. 
if pmfadm -q $RESOURCE_NAME.monitor; then 
	pmfadm -s $RESOURCE_NAME.monitor KILL
	if [ $? -ne 0 ]; then 
			logger -p ${SYSLOG_FACILITY}.err \
				-t [$RESOURCETYPE_NAME,$RESOURCEGROUP_NAME,$RESOURCE_NAME] \
				"${ARGV0} Could not stop monitor for resource " \
				$RESOURCE_NAME
        	exit 1
	else
			# could successfully stop the monitor. Log a message.
			logger -p ${SYSLOG_FACILITY}.err \
				-t [$RESOURCETYPE_NAME,$RESOURCEGROUP_NAME,$RESOURCE_NAME] \
				"${ARGV0} Monitor for resource " $RESOURCE_NAME \
				" successfully stopped"
	fi
fi
exit 0


Caution - Caution -

Be certain to use the KILL signal with pmfadm to stop the probe and not a maskable signal such as TERM. Otherwise the MONITOR_STOP method can hang indefinitely and eventually time out. The reason for this problem is that the PROBE method calls scha_control when it is necessary to restart or fail over the data service. When scha_control calls MONITOR_STOP as part of the process of bringing the data service offline, if MONITOR_STOP uses a maskable signal, it hangs waiting for scha_control to complete and scha_control hangs waiting for MONITOR_STOP to complete.


MONITOR_STOP Exit Status

The MONITOR_STOP method logs an error message if it cannot stop the PROBE method. The RGM puts the sample data service into MONITOR_FAILED state on the primary node, which can panic the node.

MONITOR_STOP should not exit before the probe has been stopped.