#!/bin/ksh93 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r714 src/43haes/usr/sbin/cluster/utilities/clmkSnmpErrnotify.sh 1.3 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 2007 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG ######################################################################### # # # Name: mkSnmpErrnotify.sh # # # # Description: This script is called to create an snmp # # errnotify stanza if necessary, or remove one # # if it already exists. # # # # Arguments: -u Remove snmp traps ernotify stanza if any # # -a Add snmp traps errnotify stanza if there # # are consistency group resources defined # # # # Returns: 0 success # # 1 failure # # # ######################################################################### # @(#)17 1.3 src/43haes/usr/sbin/cluster/utilities/clmkSnmpErrnotify.sh, hacmp.utils, 61haes_r714 5/31/07 16:10:57 [[ "$VERBOSE_LOGGING" = "high" ]] && set -x [[ "$VERBOSE_LOGGING" = "high" ]] && version='1.3' PROGNAME=$(basename ${0}) ADD_STANZA=0 DEL_STANZA=0 ERNADD="/tmp/hacmp_snmp_errnotify.add" ############################################################################### # # Name: usage # # This routine displays the usage message # # Arguments: none # Usage: usage # Returns: 1 - exit with error # ############################################################################### usage() { dspmsg scripts.cat 10060 "Usage: %s [-a][-u]\n" $PROGNAME exit 1 } ##################################################################### # # main starts here # ##################################################################### UNAME=$(uname -m) case $UNAME in ppc* | i* ) exit 0 ;; esac # ### Normalize the command arguments # set -- `getopt au $*` if [[ $? -ne 0 ]] then usage fi # ### Parse the command line. # if [[ $1 == -- ]] then usage fi while [ $1 != -- ] do case $1 in -a) # Add stanza if necessary ADD_STANZA=1 shift ;; -u) # Delete stanza if it is there DEL_STANZA=1 shift ;; *) usage ;; esac done # ### Search for name of snmp traps stanza # CUR_STANZA=`odmget -q "en_name='cl_snmp_trap_op'" errnotify` # ### Search for consistency group definitions # CUR_RESOURCE=`odmget HACMPpprcconsistgrp` # ### Are we adding or setting up to run # if [[ $ADD_STANZA == 1 ]] then # ### Is there a consistency group resource defined # if [[ "$CUR_RESOURCE" != "" ]] then # # There is a CG resource defined, so... # Is there currently a stanza defined # if [[ "$CUR_STANZA" == "" ]] then # # There isn't a stanza already defined, so... # Create the errnotify stanza # echo "errnotify:" > $ERNADD echo " en_pid = 0" >> $ERNADD echo " en_name = \"cl_snmp_trap_op\"" >> $ERNADD echo " en_persistenceflg = 1" >> $ERNADD echo " en_label = \"OPMSG\"" >> $ERNADD echo " en_crcid = 0" >> $ERNADD echo " en_class = \"O\"" >> $ERNADD echo " en_type = \"TEMP\"" >> $ERNADD echo " en_alertflg = \"\"" >> $ERNADD echo " en_resource = \"\"" >> $ERNADD echo " en_rtype = \"\"" >> $ERNADD echo " en_rclass = \"\"" >> $ERNADD echo " en_symptom = \"\"" >> $ERNADD echo " en_err64 = \"\"" >> $ERNADD echo " en_dup = \"\"" >> $ERNADD echo " en_method = \"/usr/es/sbin/cluster/diag/clreserror \$6 \$1 \$6 \$9\"" >> $ERNADD odmadd $ERNADD ((RC=RC+$?)) if ((RC != 0)) then dspmsg scripts.cat 10061 "ERROR: mkSnmpErrnotify failed to add SNMP Traps errnotify stanza\n" else # ### Remove the add file if the odmadd worked # rm -rf $ERNADD fi fi else # # There isn't a CG resource defined, so... # Is there currently a stanza defined # if [[ "$CUR_STANZA" != "" ]] then # # There is currently a stanza defined, so... # Delete it # odmdelete -o errnotify -q "en_name='cl_snmp_trap_op'" fi fi exit 0 fi # ### Are we being called from clstop to remove the errnotify stanza # if [[ $DEL_STANZA == 1 ]] then # ### Is there currently a stanza defined # if [[ "$CUR_STANZA" != "" ]] then # # There is currently a stanza defined, so... # Delete it # odmdelete -o errnotify -q "en_name='cl_snmp_trap_op'" fi exit 0 fi # ### Shouldn't get here # exit 1