Sun Cluster Geographic Edition System Administration Guide

Creating an Action Shell Script for Loss of Heartbeat

You can create an action shell script that is executed when the local cluster detects a loss of heartbeat with the partner cluster. The script is executed with root permissions, so the file must have root ownership and execution permissions.

If you have configured the Notification_actioncmd property, the action command is executed with arguments that provide information about the event in the following command line:


# custom-action-command-path -c local-cluster-name -r remote-cluster-name -e 1 \
-n node-name -t time
custom-action-command-path

Specifies a path to the action command you have created

-c local-cluster-name

Specifies the name of the local cluster

-p remote-cluster-name

Specifies the name of the remote partner cluster

-e1

Specifies that HBLOST=1, meaning that a heartbeat-loss event has occurred

-nnode-name

Specifies name of the cluster node that sent the heartbeat-loss event notification

-t timestamp

Specifies the time of the heartbeat-loss event as the number of milliseconds since January 1, 1970, 00:00:00 GMT


Caution – Caution –

You can use this script to perform an automatic takeover on the secondary cluster. However, such an automated action is risky. If the heartbeat loss notification is caused by a total loss of all heartbeat connectivity on both the primary and secondary clusters, such an automated action could lead to a situation where two primary clusters exist.



Example 12–11 How a Notification Action Script Parses the Command-Line Information Provided by the Sun Cluster Geographic Edition Software

This example shows the event information that is provided in the command-line being parsed in a notification action shell script.


#!/bin/sh

set -- `getopt abo: $*`
if [ $? != 0]
then
      echo $USAGE
      exit 2

fi
for i in $*
do

      case $i in
      -p)      PARTNER_CLUSTER=$1; shift;;
      -e)      HB_EVENT=$2; shift;;
      -c)      LOCAL_CLUSTER=$3; shift;;
      -n)      EVENT_NODE=$4; shift;;
      esac
done