The following example makes use of the "resfault" event. This event type can be configured to mail predefined users about a resource that has failed. It can be set up as follows:
The following actions need to be performed on all nodes in a cluster:
1. Copy the trigger from /opt/VRTSvcs/bin/sample_triggers/resfault to /opt/VRTSvcs/bin/triggers/resfault
2. To set up mail notification, uncomment the following section at the end of the resfault file /opt/VRTSvcs/bin/triggers/resfault:
# put your code here...
#
# Here is a sample code to notify a bunch of users.
# @recipients=("username@servername.com");
#
# $msgfile="/tmp/resfault";
# ´echo system = $ARGV[0], resource = $ARGV[1] > $msgfile´;
# foreach $recipient (@recipients) {
# # Must have elm setup to run this.
# ´elm -s resfault $recipient < $msgfile´;
# }
# ´rm $msgfile´;
#
By default, the script, once uncommented, is designed to use elm to notify users. Some systems will not have elm. If not, the standard mailx utility can be used instead, as detailed below. Note the use of the "\", which is needed so that the "@" gets interpreted correctly by Perl:
# Here is a sample code to notify a bunch of users.
@recipients=("root\@anotherserver.com,root");
$msgfile="/tmp/resfault";
´echo system = $ARGV[0], resource = $ARGV[1] > $msgfile´;
foreach $recipient (@recipients) {
# Must have mailx to run this.
´mailx -s resfault $recipient < $msgfile´;
}
´rm $msgfile´;
This is all that has to be done. When a resource next fails, a message similar to the following will be seen in the relevant person's mailbox:
From: Super-User
Message-Id: <200012241016.KAA03694@sptsun****.uk.veritas.com>
To: root
Subject: resfault
Content-Length: 42
system = sptsun****, resource = nfsdg_nfs