#!/usr/bin/ksh
#
#set -x
#
#################################################################
#                                                               #
#  Check hosts for status & configuration of RSC cards          #
#                                                               #
#  Steve Paige                                                  #
#  spaigejr@yahoo.com                                           #
#  v 1.0                                                        #
#                                                               #
#                                                               #
#################################################################

#OUTPUTFILE=/tmp/rsc_info

#################################################################
# 	Gather & display system information			                #
#################################################################
HOST=`/usr/bin/hostname`
PLATFORM=`/usr/platform/sun4u/sbin/prtdiag | /usr/bin/head -1 | awk '{print $7,$8}'`
OS=`/usr/bin/uname -r`
clear
echo "====================================================="
echo "     System information "
echo hostname: $HOST
echo platform: $PLATFORM
echo OS level: $OS
echo "====================================================="
#################################################
#						#
#		Check Packages			#
#						#
#		RSC Packages:			#
#		SUNWrsc                         #
#		SUNWrscd			#
#		SUNWrsj				#
#						#
#################################################
echo "     Package information"
CHECK_pkg()
{
if [ -f /var/sadm/pkg/$1/pkginfo ]; then
	VERSION=$(awk -F= '/^VERSION=/ {print $2}' /var/sadm/pkg/$1/pkginfo)
	NAME=$(awk -F= '/^NAME=/ {print $2}' /var/sadm/pkg/$1/pkginfo)	
	PHYLLIS=`pkginfo -l $1 | grep STATUS: | cut -d' ' -f 7-`
 echo "$PKGS - $NAME - $VERSION - $PHYLLIS"
else
echo PACKAGE NOT INSTALLED
fi
}
#################################################
#						#
#	add packages to next list="   "		#
#						#
#################################################
list="SUNWexplo SUNWrsc SUNWrscd SUNWrsj"
echo "Going to check for the following packages:"
echo  $list
echo
for PKGS in $list 
do
CHECK_pkg $PKGS 
done
echo "========================================================================"
#################################################
#	Check eeprom for proper settings	#
#	eeprom setting should be:		#
#	  diag-out-console=true			#
#         input-device=rsc-console		#
#         output-device=rsc-console		#
#################################################
echo "     EEPROM information "
echo OBP verison: `/usr/platform/sun4u/sbin/prtdiag -v | grep OBP`
echo `eeprom auto-boot?` 
echo
diag_out_console=`eeprom diag-out-console | nawk -F= '{ print $2 }'`
if [ "$diag_out_console" != "true" ]; then
    echo "diag-out-console is NOT set correctly for RSC."
else
    echo "diag-out-console is set correctly for RSC."
fi
input=`eeprom input-device | nawk -F= '{ print $2 }'`
if [ "$input" != "rsc-console" ]; then
    echo "input-device is NOT set correctly for RSC."
else
    echo "input-device is set correctly for RSC."
fi
output=`eeprom output-device | nawk -F= '{ print $2 }'`
if [ "$output" != "rsc-console" ]; then
    echo "output-device is NOT set correctly for RSC."
else
    echo "output-device is set correctly for RSC."
fi
echo "========================================================================"
echo "     RSC configuration"
if [ -x /usr/platform/`uname -i`/rsc/rscadm ]; then
	/usr/platform/`uname -i`/rsc/rscadm shownetwork | grep "IP Address"
	/usr/platform/`uname -i`/rsc/rscadm shownetwork | grep "Ethernet address"
	/usr/platform/`uname -i`/rsc/rscadm show | grep "hostname="
	/usr/platform/`uname -i`/rsc/rscadm status | grep "RSC Version"
else
	echo "Can't find rscadm - Are all the RSC packages installed?"
fi
echo "========================================================================"
echo "     $HOST complete"
echo "========================================================================"


##############################################################################
### This script is submitted to BigAdmin by a user of the BigAdmin community.
### Sun Microsystems, Inc. is not responsible for the
### contents or the code enclosed. 
###
###
### Copyright 2005 Sun Microsystems, Inc. ALL RIGHTS RESERVED
### Use of this software is authorized pursuant to the
### terms of the license found at
### http://www.sun.com/bigadmin/common/berkeley_license.html
##############################################################################


