#!/bin/ksh
#
#pragma ident   "@(#)nfs_stat.sh 1.4 97/09/29"
#Copyright (C) 1997 Sun Microsystems, Inc.
#
#
# nfs_hastat.sh
#
# Usage: nfs_hastat <logical-host>
#
# This program is intended to be called as a subroutine by the hastat
# program, or by other higher-level admin programs.
#
# Prints on stdout one of the four following strings:
#
#	Ok - All Probes/Monitoring Are Ok.
#	NotOk - Monitoring Not going well.(but cannot somehow do a takeover)
#	Degraded - Some of the Filesystems/LogicalIP names cannot be used.
#	Unknown - May be a network problem and we cannot say for sure 
#		 as to who is the culprit or
#		 The logical host is not mastered or backuped on this node.
#
#	Produces results only if the logical host is mastered or not
#	mastered on this Node.
#
# XXX: In future we can have a CCD entry to display the status of logical host
#      by getting the result of all fault monitors and updating the entry.
#

cleanup()
{
	exit 0
}

PROG=$(/bin/basename $0)
# Get the Source of All the Common Utilities
INCLUDE=.
# include common utililites.
FMBIN=/opt/SUNWcluster/ha/nfs/
${INCLUDE} ${FMBIN}/nfs_common_util

ECH_TRAPSIGNALS="1 2 3 15"
trap "cleanup ; trap 0 ; exit 1" $ECH_TRAPSIGNALS

initnfsenv

USAGE="Usage: ${PROG} logicalhostnames"

if [ $# -lt 1 ]; then
    echo ${USAGE} 1>&2
    exit 1
fi

#
# Since we know the status-File and directory
# Just print the status.
# If it not exists then echo None.
#
for i in $*
do
STATUSDIR=${FMSTATUSDIR}/$i
STATUSFILE=${STATUSDIR}/status
 
if [ ! -f ${STATUSFILE} ]; then
        ANS="Unknown"
else
        ANS=`/bin/cat $STATUSFILE`
        if [ -z ${ANS} ]; then
                ANS="Unknown"
        fi
fi
echo "       On Logical Host ${i}:      ${ANS}"
done

exit 0
