#! /bin/ksh
#
# ident "@(#)lotus_status.shi	1.1	99/08/03 SMI"
#
# Copyright (c) 1999 by Sun Microsystems, Inc.
# All rights reserved.
#
#
# Usage: lotus_status LogicalHosts
#
# Called from hastat to get status of LOTUS

nodeloghosts="$1"

# source in ha-services common utilities
. /opt/SUNWcluster/bin/hads_utilities

SYSLOG_PREFIX="SUNWcluster.ha.lotus"

# Set varible for the HA-LOTUS configuration file
HALOTUS_CONFIG_FILE=/etc/opt/SUNWsclts/hadsconf

if [ ! -f "${HALOTUS_CONFIG_FILE}" ]; then
	lmsg1=`gettext "      LOTUS is not yet configured"`
	printf "${lmsg1}\n"
	exit 0
fi

#
# Call the parser to handle the config file.
#
source_env_file $HALOTUS_CONFIG_FILE
if [ $? -ne 0 ]; then
	lmsg1=`gettext "       LOTUS is not configured properly"`
	printf "${lmsg1}\n"
        exit 0
fi

for i in $_INST_LIST; do
    
	# Check Logical Host
	instloghost=`get_config_param $i LOGICAL_HOST`

	is_member "${instloghost}" "${nodeloghosts}"
	if [ $? -ne 0 ]; then
		# The LOTUS loghost is not mastered here
		lmsg1=`gettext "       LOTUS Instance %s is not being managed on this system"`
		printf "${lmsg1}\n" "${i}"
		continue
	fi

	ha_svc_not_running "${i}.probe"
	if [ $? -eq 0 ]; then
		lmsg1=`gettext "       LOTUS Instance %s is not monitored"`
		printf "${lmsg1}\n" "${i}"
	else
		lmsg1=`gettext "       LOTUS Instance %s is monitored"`
		printf "${lmsg1}\n" "${i}"
	fi

done

exit 0
