#!/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/usr/sbin/cluster/utilities/err_object_list.sh 1.8 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 1998,2011 
# 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 
# @(#)40                      1.8  src/43haes/usr/sbin/cluster/utilities/err_object_list.sh, hacmp.utils, 61haes_r714 11/28/11 15:26:22
# this scripts finds all error labels to list from smit
# searches for non-null en_method and non-null en_name and non-null en_label.

PROGNAME=${0##*/}
export PATH="$(/usr/es/sbin/cluster/utilities/cl_get_path all)"
[[ $VERBOSE_LOGGING == high ]] && set -x
[[ $VERBOSE_LOGGING == high ]] && version='1.8 $Source: 61haes_r711 43haes/usr/sbin/cluster/utilities/err_object_list.sh 1$'

export ODMDIR=/etc/objrepos
#
:   Get the names of all non-null entries in the errnotify odm class
#
ENAMES=$(odmget -q "en_name != '' and en_method != '' and en_label != ''" errnotify | \
	 sed -n '/en_name =/s/.*"\(.*\)".*/\1/p' | sort -u)

#
:  Build an output line for each such entry
#
for name in $ENAMES
do
    #
    :	Get the error log entry label - that is, what kind of error log entry 
    :	for the given name
    #
    ELABEL=$(odmget -q "en_name=$name" errnotify | \
	     sed -n '/en_label =/s/.*"\(.*\)".*/\1/p')

    for label in $ELABEL 
    do

	case $label in

	    LVM_SA_QUORCLOSE )
		#
		:	LVM error log entry for close of a volume group due to lack of quorum
		:	This can drive selective fallover
		#
		ONLINE_VGS=$(lsvg -o | grep -v rootvg)
		for vg in $ONLINE_VGS ; do
		    printf "%-20s\t%s\n" $label $vg
		done

	    ;;

	    LVM_IO_FAIL )
		#
		:	LVM error log entry for write failure
		:	Can be used, indirectly, to drive selective fallover
		:	See clreserror
		#
		LC_ALL=C lspv | while read hdisk pvid vg_name state rest ; do
				    if [[ -n $state &&  $vg_name != rootvg && $vg_name != [Nn]one ]]
				    then
					printf "%-20s\t%s\n" $label $hdisk
				    fi
				done
	    ;;

	    * )
		#
		:	All other, non-HACMP entries
		#
		printf "%-20s\t%s\n" $label $name
	    ;;
	esac
    done
done
