#!/usr/bin/ksh

SYS_DIAG_VER='5.18'
######################################################################
#
#  Script Name :  sys_diag
#
#  Purpose/Function : To probe system(s), generating a configuration
#		      and/or performance 'snapshot' report for analysis
#			.... etc ...
#
#  Copyright 1999-2006  Todd A. Jobson 
#
#  Last Mod : 1/31/2006
#  Revision : 5.18
#
#  Created  : 08/23/99
#
##########################################################################
#
#  NOTE: As long as the comments and Copyright statements are left
#  ***** in-tact, Todd Jobson will grant an implicit right to use
#  ***** license for the following script in its entirety.  Any
#  ***** comments and/or enhancements can be directed to 
#  ***** todd.jobson@comcast.net for incorporation within future releases.
#
#  Note: As with all external Solaris utilities, Sun Support will not
# 	 support this utility, but all underlying OS commands are supported.
#  !*!*! Also note that any issues that result from installing, running,
#  !*!*! or modifying this script will be the Personal responsibility of 
#  !*!*! the individual that installed, modified, and/or ran this utility.
#
#  Note: This script has been run on most Sun system types (Sparc -> E25K).
#  ***** This script has been tested on Solaris 2.x -> Solaris 10
#  ***** However, given that caution is always the best policy, 
#  !*!*! test on a non-production system (Test/Staging/desktop..) first !!!!
#
#  Note: If you are having problems running this (weird errors..), do a
#	 cat -uvet ./sys_diag    to see if the file has gotten windows
#	 corrupted... aka.. added ^M 's to the end of every line.  If so,
#	 you can simply remove these within via as :1,$s/^V^M//g (where
#	 the ^'s listed are actually the Ctrl key, using Ctrl-V first to
#	 allow the entry of Ctrl-M as a character to substitute with nothing.
#
############################################################################
#
# BACKGROUND / INTRODUCTION :
# 
# sys_diag is a Solaris utility (ksh script) that can perform several 
# functions, most notably, system configuration 'snapshot' and reporting 
# (detailed or high-level), and performance characterization  via perf 
# data gathering (over some specified duration or time in point 'snapshot'), 
# high-level analysis, and reporting of findings/exceptions (based upon 
# perf thresholds that can be easily changed within the script header).   
# 
# The output is provided in a single .tar.Z of output and corresponding 
# data files, and a local sub-directory where report/data files are stored.  
# The report format is provided in .html, .txt, and .ps as a single file 
# for easy review (without requiring trudging through several subdirectories 
# of separate files to manually correlate and review).   
# 
# sys_diag runs on any Solaris 2.6 (or above) Sun platform, and even 
# includes reporting of new Solaris 10 capabilities (zone/containers, SVM, 
# zfspools, fmd, ipfilter/ipnat, link aggr, ...).   
# 
# Beyond the Sun configuration reporting commands [System/storage HW config, 
# OS config, kernel tunables, network/IPMP/Trunking/LLT config, FS/VM/NFS, 
# users/groups, security, NameSvcs, pkgs, patches, errors/warnings, and 
# system/network performance metrics...], sys_diag also captures relevant 
# application configuration details, such as Sun N1, Sun Cluster 2.x/3.x, 
# Veritas VCS/VM/vxfs.., Oracle .ora/listener files, etc.. detailed 
# configuration capture.
# 
# Of all the capabilities, the greatest benefits are found by being able 
# to run this on a system and do the analysis  from one single report/
# file... offline/elsewhere (in addition to being capable of  historically 
# archiving system configurations, for disaster recovery.. or to allow for 
# tracking system chgs over time.. after things are built/tested/certified).  
# One nice feature for performance analysis is that the vmstat and netstat 
# data is exported in a text format friendly to import and created graphs 
# from in StarOffice or Excell..
# 
# Although I'm a SunCS employee, this has been personally developed over many 
# years, in my spare time in order to make my life a lot easier and 
# more efficient.  Hopefully others will find this utility capable of 
# doing the same for them, also making use of it's legwork.. to streamline 
# the admin/analysis activities required of them.  This has been an invaluable
# tool used to diagnose / analyze hundreds of performance and/or configs issues
# 
# Regarding the system overhead, sys_diag runs all commands in a serial 
# fashion (waiting for each command to complete before running the next) 
# impacting system performance the same as if an admin were typing these 
# commands one at a time on a console.. with the exception of the background 
# vmstat/mpstat/iostat/netstat that's done when (-g) gathering performance 
# data over some interval for report/analysis (which generally has minimal 
# impact on a system, especially if the sample interval [-I] is not every 
# second).
# 
# sys_diag is generally run from /var/tmp as "sys_diag -l"  for creating 
# a detailed long report, or via "sys_diag -g -l " for gathering 
# performance data and generating a long/detailed config/analysis report), 
# however offers many command line parameters documented within the header, 
# or via "sysdiag -?".   ** READ the Usage below, as well as the Performance
# Parameters sections for futher enlightenment.. ;) **
#
############################################################################
###
#
#  Common Usage:  sys_diag -l
#
#		(Generate a "long"/detailed system config report.)
#		>**>    Note: the -l argument MUST be listed LAST if used.
#
#			This option creates text, HTML, and postscript
#			versions of the report file (.out,.html,.ps..)
#			in addition to tar'g and compressing all to .Z
###
#  	 	 sys_diag -g -l   (uses PERF_INTERVAL and PERF_SECS defaults
#				   sample interval secs/ data gathering time)
#
#		(The above syntax collects/Gathers diag/perf data
#		 according to PERF_INTERVAL sampling rate and total
#		 elapsed capture time as specified by PERF_SECS..
#		 in addition to generating a complete "long" system 
#		 configuration report.  In addition, it parses those
#		 performance files and identifies any preliminary
#		 discrepancies/findings based upon thresholds set.)
#
#**>		 sys_diag -g -I 3 -T 1800 -l
#
#			uses the cmdline parameter -I with a 3 second
#			sampling interval, -T with 1800 secs total
#			elapsed time for data collection, then -l for
#			long report. (No need to edit PERF_SECS, below *)
#
#		 *NOTE: See the Variable/parameter section inline below 
#			labeled "Performance Data Gathering Parameters"
#			for a detailed explanation of Perf Thresholds / Bounds
#			to test the data against and report exceptions for..
#			as well as the default settings for interval and durat
#			These parameters can be modified, but only affect -g
#
#### Other options...(see sys_diag -? for a complete listing.. or code below)
#
#		 -A
#			Runs ALL options, including data collection, asset
#				tracking, verbosity, etc..
#		 -D
#			Runs in DEBUG mode (echo ing all ksh to the cmd line)
#
#		 -t (track system changes)  Identify system configuration chgs
#			-> Save latest and previous copy of significant
#			config data + dir/file	listings and append 
#			any changes/diffs to logfile (reports CHANGES)
#			(see TRACK in the code for cfg.. data checked)
#		 -u
#			Turns off the default TAR creation/Compression of an
#			archive containing all report files generated...
#		 -V
#			Runs in VERBOSE mode (adding verbose data such as
#			/etc/path_to_inst, interface snoop, and network
#			device driver settings..tcp/ip/udp ... and longer 
#			message/error/log listings)
#
#		 -d base_directory (where datafiles/dirs should reside)
#			if not, use $SYSDIAG_HOME , else use the 
#			local directory, else (if cant write) PROMPT for path.
#
#		 -o output_filename (specify an output filename, otherwise
#					use the default sysd_.. naming)
#
##############################################################################
#
# RELEASE NOTES :
#
##############################################################################
#
#   R. 5.18	TJ 01/31/06	Extended System Profilng, introduced a new
#				html header section "System Perf. Dashboard"
#				reflecting color coded system perf summary and
#				links to config and perf. analysis findings..
#
#   R. 5.17	TJ 01/03/06	Removed RFE Notes/comments, Added Intro,
#				changed -v for version#, -V for Verbose, ..
#				Added System Profiling Output, IO dev Avgs
#
#   R. 5.16	TJ 12/29/05	Added busstat, vxstat samples, vxtunefs,
#				"failure" as errors, lockstat -IW, tuned perf,
#				added zfs config listings, ..
#
#   R. 5.15	TJ 09/23/05	Added S10 zfs pool list, S10 IPNAT, ipfilter,
#				in addition to other misc.. formatting of rpt
#
#   R. 5.14	TJ 09/20/05	Optimized cmd line args , added .gr.txt
#				files for export/import of vmstat/netstat perf 
#				data into a spreadsht/graph util, added
#				extra error checking for not running
#				S10/S9 cmds on S8, expanded rcap/project data,
#				moved long (-l) pkginfo & ps listings to files
#
#   R. 5.13	TJ 08/02/05	Added system cpu and network interface avgs, +
#				VCS LLT/ Oracle RAC/CRS net interconn perf data
#
#   R. 5.12	TJ 08/02/05	Additional Veritas and Oracle RAC data..
#
#   R. 5.11	TJ 03/09/05	Minor reformatting, Expanded Perf Analysis
#
#   R. 5.10	TJ 02/10/05	Added X.25 utilities, Added Perf Parameters
#
#   R. 5.08	TJ 12/10/04	Added S10 perf utilities, re-org output, ..., 
#				misc. enhancements.. comments..
#
#   R. 5.01	TJ 10/13/04	Added S10 zone/containers, SRM,
#				MPxIO,..Several Misc. enhancements.. comments..
#
#   R. 4.05	TJ 02/20/04	Added N1 PS config rptg
#				Sections, + Misc... 
# 
#   R. 4.04	TJ 01/18/04	Added Veritas VCS main.cf config reporting..
#				and expanded SC3.x reporting, SVM,..
#
# ... all other prior release notes have been removed as it's history now..
# 
##############################################################################
##############################################################################
#
# RFE NOTES : ( ADD / CHANGE / FIX / Test ...)    :
#
######################################################################
#
#  RFE Misc :	
#
#	(these notes are post 12/29/05. Prior RFE notes are external)
#
#  /usr/sbin/plockstat -A -p <pid>
#
#  /usr/sbin/cpustat -c <pic0=......> 
#
#  S10 u1 Nemo Link Aggr : laadm show stats | dlam show ..
#
#  scdidadm | scgdevs
#
#  scnad -p | scnasdir -p  .... NCA, etc..
#
######################################################################
######################################################################

############### Performance Data Gathering Parameters ##############
#
# NOTE: THE FOLLOWING PARAMETERS ONLY AFFECT the -g (PERF ANALYSIS)
#
# PERF_SECS is the total elapsed seconds for data collection and can
#	be overridden on the command line with -T <secs>
#
# PERF_INTERVAL is the sampling interval in seconds and can be overridden
#	via the command line interval -I <secs>

PERF_SECS=300	## Total data gathering Time; 300 secs= 5 mins, 1800=30 mins..
PERF_INTERVAL=2 ## (frequency in # of seconds that samples are taken)

## the following fields are the actual vmstat/mpstat/iostat
## Rules / Thresholds that are tested for and flagged if outside bounds

VMSTAT_RUNQ_GT=1	## vmstat entry flagged only if RUNQ field > X
VMSTAT_RQBLKD_GT=1	## vmstat entry flagged only if RUNQ field > X
VMSTAT_SCANRT_GT=0	## rate of system scanning for free mem pages
VMSTAT_PCTSYS_GT=40	## overall system cpu % SYS < X%
VMSTAT_PCTIDLE_LT=5	## overall system cpu % IDLE < X%
VMSTAT_PCT_YEL=9	## Vmstat CPU Warning Threshold > X% of samples
VMSTAT_PCT_RED=24	## Vmstat CPU Critical Threshold > X% of samples

MEM_PCT_YEL=3		## Vmstat MEM Warning Threshold > X% of samples
MEM_PCT_RED=15		## Vmstat MEM Critical Threshold > X% of samples
MEM_PCT_MIN=15		## % RAM avail Minimum Threshold < X%

SWAP_PCT_MIN=20		## % Vmem:SWAP avail Minimum Threshold < X%

MPSTAT_ICSW_GT=200	## involuntary context switches per cpu entry > X
MPSTAT_SMTX_GT=250	## shared mutexes used per cpu entry > X
MPSTAT_SYS_GT=50	## mpstat cpu % system calls > X
MPSTAT_PCTWT_GT=3	## mpstat cpu waiting > X% of its time
MPSTAT_PCTIDLE_LT=1	## mpstat cpu entry flagged only if PCTIDLE < X 
MPSTAT_PCT_YEL=15	## Mpstat Warning Threshold > X% of samples
MPSTAT_PCT_RED=30	## Mpstat Critical Threshold > X% of samples

IOSTAT_WAIT_GT=1	## iostat # transactions waiting on device
IOSTAT_SVCTM_GT=22	## iostat avg device time to service a rqst > Xms
IOSTAT_PCTWT_GT=3	## transactions waiting > X% of the time on device
IOSTAT_PCTBSY_GT=90	## device busy % > X% of its time
IOSTAT_PCT_YEL=5	## Iostat Warning Threshold > X% of samples
IOSTAT_PCT_RED=19	## Iostat Critical Threshold > X% of samples

NETSTAT_RX_GT=18000	## network interface incoming packets per interval
NETSTAT_RX_ERR_GT=0	## network interface incoming packet errors per interval
NETSTAT_TX_GT=20000	## network interface outgoing packets per interval
NETSTAT_TX_ERR_GT=0	## network interface outgoing packet errors per interval
NETSTAT_COLL_GT=0	## network interface # collisions per interval
NETSTAT_PCT_YEL=5	## Netstat Warning Threshold > X% of samples
NETSTAT_PCT_RED=18	## Netstat Critical Threshold > X% of samples
#
######################################################################
#

SYSDIAG_HOME=''

## NOTE: CHANGE The following vars to reflect your patch utility location..

PATCH_UTILITY_DIR='/var/tmp/patchdiag-1.0.4'
PATCH_UTILITY_CMD='patchdiag -l'

ALL=0
APPS=0
CONFIG=0
DEBUG=0
DURATION=0
EXTRACT=0		## Extract Config / Asset Mgmt
HA=0
INTERVAL=0
IO=0
LABEL=0
LONG=0
MENU=0
N1=0
NETWORK=0
ORACLE=0
PERF=0
PATCHMGT=0
PROMPT=0
SECURITY=0
POST=0
TAR=1
TRACK=0			## Capture and TRACK Config / Asset Mgmt chgs
VERBOSE=0

typeset -i sum1=0
typeset -i sum2=0
typeset -i xxxx=0

io_secs=0
snooppid=0
no_nis=0
nisd=0
num=0
sud=0

#Solaris_Rev=`uname -a | cut -d" " -f3`
Solaris_Rev=`uname -a | cut -d"." -f2 | cut -d" " -f1`

User_Name=`/usr/bin/who | cut -d" " -f1`
Up_Time=`uptime`

SYSDIAG_PID=$$
CMD_LINE=$*

filename=''
sysd_dir=''
home_dir=''
infile=''
interval_secs=0
duration_secs=0
duration_count=0
outfile=''
outfile_ps=''
html_file=''
afile_log=''
snoop_file=''
name_svc1=''
name_svc2=''


log_stamp='sys_diag:'`date '+%m%d_%H%M'`':'


if ( [ -z $SYSDIAG_HOME ] || ( ! [ -w `echo $SYSDIAG_HOME` ] ))
then
	home_dir='.'
else
	home_dir=$SYSDIAG_HOME
fi

SHELL=/bin/ksh;export SHELL



##################### PARSE COMMAND LINE ARGUMENTS ###################

if [ $# = 0 ]
then
	echo "$log_stamp  DEFAULT Report, Not LONG, No gathering PERF, No TAR\n"
	ALL=1
	TAR=0
else

   i=$#


   while [ $i -ge 1 ]
   do
	getopts acd:Df:gHI:lL:mnNo:pPRsST:tuvVxh?A arg

	case $arg in 

	    a )
		echo "$log_stamp  APPS"
		APPS=1
		ORACLE=1
		;;
	    c )
        	echo "$log_stamp  CONFIG"
        	CONFIG=1
		ALL=0
		;;
	    d )				# Data Directory / Base Dir. / Home
       		echo "$log_stamp  HOME/DATA DIRECTORY: \c"
        	DIR=1

   		if [ $i -ge 1 ]
		then
			home_dir=$OPTARG
			echo "$home_dir\n"
   			i=$(($i-2))
			continue
		else
			echo "\n"
		fi
		;;
	    D )
		echo "$log_stamp  DEBUG"
		DEBUG=1
		set -x
		;;
	    f )			# INPUT File (infile) ..TBD..
       		echo "$log_stamp  INPUT FILE: \c"
        	FILE=1

   		if [ $i -ge 1 ]
		then
			infile=$OPTARG
			echo "$infile\n"
   			i=$(($i-2))
			continue
		else
			echo "\n"
		fi
		;;
	    g )
       		echo "$log_stamp  GATHER PERFORMANCE DATA"
		IO=1
		PERF=1		# spawn gathering procs
		ALL=0
		;;

	    H )
       		echo "$log_stamp  HA"
        	HA=1
		ALL=0
		;;
	    I )
       		echo "$log_stamp  INTERVAL: \c"
        	INTERVAL=1

   		if [ $i -ge 1 ]
		then
			interval_secs=$OPTARG
			echo "$interval_secs\n"
   			i=$(($i-2))
			continue
		else
			echo "\n"
		fi
		;;
	    l )
		echo "$log_stamp  LONG"
		LONG=1
		ALL=1
		;;
	    L )			## Report header descriptive LABEL
		echo "$log_stamp  LABEL : \c"
		LABEL=1

   		if [ $i -ge 1 ]
		then
			label=$OPTARG
			echo "$label\n"
   			i=$(($i-2))
			continue
		else
			echo "\n"
		fi
		;;
	    m )			## TO BE ADDED ..for menu interface
       		echo "$log_stamp  MENU"
		MENU=1
		ALL=0
		;;
	    n )
		echo "$log_stamp  NETWORK"
		NETWORK=1
		ALL=0
		;;
	    N )
		echo "$log_stamp  N1"
		N1=1
		ALL=0
		;;
	    o )
		echo "$log_stamp  OUTPUT FILE: \c"
		OUTPUT=1

   		if [ $i -ge 1 ]
		then
			outfile=$OPTARG
			echo "$outfile\n"
   			i=$(($i-2))
			continue
		else
			echo "\n"
		fi
		;;
	    p )				# Generate POSTSCRIPT rpt also
		echo "$log_stamp  POSTSCRIPT"
		POST=1
		ALL=0
		;;
	    P )
		echo "$log_stamp  PATCHMGT"
		PATCHMGT=1
		ALL=0
		;;
	    R )
		echo "$log_stamp  ROOT prompt"
		PROMPT=1
		ALL=0
		;;
	    s )
		echo "$log_stamp  SECURITY"
		SECURITY=1
		ALL=0
		;;
	    S )
		echo "$log_stamp  SMS-SVC prompt"
		PROMPT=1
		ALL=0
		;;
	    T )
       		echo "$log_stamp  TIME Duration: \c"
        	DURATION=1

   		if [ $i -ge 1 ]
		then
			duration_secs=$OPTARG
			echo "$duration_secs\n"
   			i=$(($i-2))
			continue
		else
			echo "\n"
		fi
		;;
	    t )				## ASSET / CONFIG MGMT Tracking
		echo "$log_stamp  TRACK"
		TRACK=1
		;;
	    u )
		echo "$log_stamp  UNTARed"	## Turn off tar'ing..
		TAR=0
		;;
	    v )
		echo "\n\tSys_Diag version : $SYS_DIAG_VER"
		echo "\n\tCopyright 1999-2006 Todd A. Jobson"
		echo "\n\tfor command line usage, use -h or -?\n"
		exit
		;;
	    V )
		echo "$log_stamp  VERBOSE"
		VERBOSE=1
		LONG=1
		ALL=1
		;;
	    x )				## EXTRACT config files.. TBD..
		echo "$log_stamp  EXTRACT"
		EXTRACT=1
		;;
	    h | \? )
 
        	echo "\n\tCOMMAND USAGE :\t# sys_diag [ -a -A -c -g -l .... ]\n"
		echo "\n\t\t\t-a\tApplication details\n"
		echo "\t\t\t-A\tALL Options are turned on, except Debug and -u\n"
		echo "\t\t\t-c\tConfiguration details\n"
		echo "\t\t\t-d path   Base directory for data files\n"
		echo "\t\t\t-D\tDebug ksh mode\n"
#		echo "\t\t\t-f infile\tInput File\n"
		echo "\t\t\t-g\tGather performance data\n"
		echo "\t\t\t-h / -?   Help / Command Usage (this listing)\n"
		echo "\t\t\t-H\tHA config and stats\n"
		echo "\t\t\t-I secs   Perf Gathering Second Interval as -g -I 300 -l\n"
		echo "\t\t\t-l\tLong Listing (most details, but not -g,-V,-A,-t,-D)\n"
		echo "\t\t\t-L label_descr_nospaces\tDescriptive Label For Report\n"
#		echo "\t\t\t-m\tMenu driven interface\n"
		echo "\t\t\t-n\tNetwork configuration and stats\n"
		echo "\t\t\t-N\tN1 configuration\n"
		echo "\t\t\t-o outfile   Output filename (stored under sub-dir created)\n"
		echo "\t\t\t-p\tBasic Performance statistics (vmstat, mpstat, iostat, vxstat,..)\n"
		echo "\t\t\t-P\tPatch Management (pkginfo -l, showrev -p,..)\n"
#		echo "\t\t\t-R\tRoot User pwd prompt\n"
		echo "\t\t\t-s\tSecurIty configuration\n"
#		echo "\t\t\t-S\tSMS-SVC pwd prompt\n"
		echo "\t\t\t-T secs   Perf Gathering Total Duration as -g -I 1 -T 300 -l\n"
		echo "\t\t\t-t\tTrack configuration changes (Reports config changes..)\n"
		echo "\t\t\t-u\tUnTar ed: do NOT create a tar file)\n"
		echo "\t\t\t-V\tVerbose Mode (adds path_to_inst, network dev's, snoop..)\n"
		echo "\n\t\tNOTE: NO args equates to a brief rpt (No -A,-g/I,-l,-t,-D,-V,..)\n"
        	exit
		;;
	    A )
		echo "$log_stamp  ALL"
		ALL=1
		APPS=1
		CONFIG=1
		HA=1
		IO=1
		LONG=1
		N1=1
		NETWORK=1
		ORACLE=1
		PATCHMGT=1
		PERF=1
		POST=1
		TRACK=1
		VERBOSE=1
		;;

	esac

   	i=$(($i-1))

    done

fi

#########  PARSE and/or INPUT $SYSDIAG_HOME value ###########


while ( [ -z $home_dir ] || ( ! [ -w `echo $home_dir` ] ))
do
	echo "\n\tNOTE: SYSDIAG_HOME (or -d path) is not set (or is not writable)."
	echo "\tEnter a valid directory for storing datafiles [./] >\c"
	read home_dir

	if [ -z $home_dir ]
	then
		home_dir='.'
	fi
done

#############  INITIALIZE and/or Assign datafile values  ##############

#echo "\n*** fn=$filename,\n if=$infile, \n of=$outfile  ***\n"


filename='sysd_'`uname -n`'_'`date '+%y%m%d_%H%M'`

sysd_dir=`echo $home_dir/$filename`


if [ -z $outfile ]
then
	outfile=`echo $sysd_dir/$filename.out`
else
	outfile=`echo $sysd_dir/$outfile`
fi


mkdir $sysd_dir
ret=$?

if [ $ret -ne 0 ]
then
	echo "ERROR: on  >> # mkdir $sysd_dir << , EXITING..\n" >> $outfile
	echo "$log_stamp ERROR on >> #mkdir $sysd_dir << , EXITING...."
	exit
fi

cp ./sys_diag $sysd_dir

dash_file="$outfile.dash.html"


if ( [ -f `echo $outfile` ] && ( ! [ -w `echo $outfile` ] ))
then
	echo "$log_stamp  ERROR: $outfile NOT Writeable as : `id`."
	exit
fi

#TJ  script $sysd_dir/sys_diag.out


system_file=$sysd_dir'/sysd_sys_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
pkginfo_file=$sysd_dir'/sysd_pkg_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
ps_cpu_file=$sysd_dir'/sysd_cpu_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
ps_mem_file=$sysd_dir'/sysd_mem_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'

vmstat_file=$sysd_dir'/sysd_vm_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
mpstat_file=$sysd_dir'/sysd_mp_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
iostat_file=$sysd_dir'/sysd_io_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'

analysis_efile=$sysd_dir'/sysd_error_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
analysis_wfile=$sysd_dir'/sysd_warn_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'

vmstat_graph_file=$sysd_dir'/sysd_vm_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.gr.txt'

#
####################### FUNCTION DEFINITIONS #########################
#
 
####################  gen_html_rpt  ###########################
#
# Description: 'gen_html_rpt' generates an HTML version of the
#		main sys_diag output file (outfile).
#
# Parameters:
#       $1      $outfile
#       $2      $html_file
#       $3      $dash_file
#       $4      $PERF
#
function gen_html_rpt {

        typeset -r ofile=$1
        typeset -r hfile=$2
        typeset -r dfile=$3
        typeset -r perf=$4

	### Print the HEADER INFO ###

	echo "<html><head><title>"`hostname`" (sys_diag v$SYS_DIAG_VER) : System Profile Report</title></head>\n" >> $hfile

	echo "<body BGCOLOR="#FFFFFF"><hr><hr><h2 align="center">(sys_diag) : System Configuration/ Performance Profile Report</h2><hr><hr>" >> $hfile

	echo "<p><b><pre> hostname        \t:  "`hostname`"\c" >> $hfile

	if [ -x /usr/bin/zonename ]
	then
		echo "\t\t   zonename :  "`/usr/bin/zonename` >> $hfile
	else
		echo "\n" >> $hfile
	fi

	echo " uname -a        \t:  "`/usr/bin/uname -a`"\n" >> $hfile

	echo " hostid          \t:  "`/usr/bin/hostid` >> $hfile

	echo " domainname (DNS)\t:  "`/usr/bin/domainname` >> $hfile
	echo " system uptime   \t:  $Up_Time\n" >> $hfile
	echo " sys_diag uid    \t:  sys_diag (v$SYS_DIAG_VER) : "`id` >> $hfile
	echo " sys_diag args   \t:  sys_diag $CMD_LINE\n" >> $hfile

	if [ -f /etc/ssphostname ]
	then
		echo " ssphostname\t:  "`cat /etc/ssphostname`"\n" >> $hfile
	fi

	echo "<i>Report Label : "`date`" : $label </i>" >> $hfile
	echo "</pre><i>Output File  : $outfile </b></i><hr><hr>\n" >> $hfile

####### DASHBOARD Inserted ######

	if [ $perf -ne 0 ]
	then
		cat $dfile >> $hfile
		echo "<hr><hr>\n\n<h3>TABLE OF CONTENTS :</h3>\n<ul>" >> $hfile
	else
		echo "\n\n<h3>TABLE OF CONTENTS :</h3>\n<ul>" >> $hfile
	fi
	echo "\n<li><a href=\"#1\" class=\"named\"><b>Section 01>   System / Device Information</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#2\" class=\"named\"><b>Section 02>   E10K / F25K / SunFire System Information</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#3\" class=\"named\"><b>Section 03>   Processor / Performance Information</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#4\" class=\"named\"><b>Section 04>   Kernel Zones / Tunables / SRM</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#5\" class=\"named\"><b>Section 05>   Storage Device / Array Enclosure Information</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#6\" class=\"named\"><b>Section 06>   Volume Manager Information</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#7\" class=\"named\"><b>Section 07>   Filesystem / Swap Information</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#8\" class=\"named\"><b>Section 08>   I/O Statistics</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#9\" class=\"named\"><b>Section 09>   NFS Information</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#10\" class=\"named\"><b>Section 10>   Networking Information</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#11\" class=\"named\"><b>Section 11>   Tty / Modem Configurations</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#12\" class=\"named\"><b>Section 12>   User / Account / Group Info</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#13\" class=\"named\"><b>Section 13>   Services/ Naming Resolution (NIS/NIS+..)</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#14\" class=\"named\"><b>Section 14>   Security / System Configuration Files</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#15\" class=\"named\"><b>Section 15>   Clustering / HA Information</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#16\" class=\"named\"><b>Section 16>   Sun N1 SP Configuration</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#17\" class=\"named\"><b>Section 17>   Application / Oracle Config Files</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#18\" class=\"named\"><b>Section 18>   Packages Installed</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#19\" class=\"named\"><b>Section 19>   Patch Information</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#20\" class=\"named\"><b>Section 20>   Crontab File Listings</b></a></li>\n" >> $hfile
	echo "<li><a href=\"#21\" class=\"named\"><b>Section 21>   FMD / System Messages / Log Files</b></a></li>\n" >> $hfile

	if [ $TRACK -ne 0 ]
	then
		echo "<li><a href=\"#22\" class=\"named\"><b>Section 22>   Asset / Configuration Management -CHANGES-</b></a></li>\n" >> $hfile
	fi

	if [ $PERF -ne 0 ]
	then
		echo "<li><a href=\"#23\" class=\"named\"><b>Section 23>   System Analysis : Initial Findings / Errors/Warnings</b></a></li>\n" >> $hfile
		echo "<li><a href=\"#24\" class=\"named\"><b>Section 24>   Performance Analysis : Potential Issues</b></a></li></ul><h2> </h2>\n" >> $hfile
	else
		echo "</ul><h2> </h2>\n" >> $hfile
	fi

tail +69 $ofile | cut -c1-253 | /usr/bin/awk '{ if (( substr($0,1,3) == "## " ) && ( int(substr($0,4,2)) > 0 ))  { num=int(substr($0,4,2)) ; print "</pre></b><br><hr><br> <br></p>\n<a name=\""num"\" ><font size=+2 color=blue>( ",num," )<u>",substr($0,15,52),"</u></font></a><p><b><pre>" } else { if ( substr($0,1,4) == "*** " ) { namestr=substr($0,5,9) ; print "</pre></b></p><a name=\""namestr"\" ><font size=+1 color=blue> ",$0,"</font></a><p><b<pre>"  } else { print $0 } } } END { print "</pre></p>\n</body>\n</html>\n" }' >> $hfile

#tail +69 $ofile | cut -c1-253 | /usr/bin/awk '{ if (( substr($0,1,3)=="## " ) && ( int(substr($0,4,2)) > 0 ))  { num=int(substr($0,4,2)) ; print "</pre></b><br><hr><br> <br></p>\n<a name=\""num"\" ><font size=+2 color=blue>( ",num," )<u>",substr($0,15,52),"</u></font></a><p><b><pre>" } else { if ( substr($0,1,4)=="*** " ) { namestr=substr($0,5,9) ; print "</pre></b></p><a name=\""namestr"\" ><font size=+1 color=blue> ",$0,"</font></a><p><b<pre>"  } else { if ( substr($0,1,4)=="##**" ) { print "\t",$2,"  </pre></b></p><a href=\"file:///"$3"\" name=\""$3"\"></a><p><b><pre>" } else { print $0 } } } } END { print "</pre></p>\n</body>\n</html>\n" }' >> $hfile

}


####################  check_config  ###########################
#
# Description: 'check_config' compares new system configuration
#		details (command output and files) with previous
#		snapshots.  Discrepancies are flagged and logged.
#
# Parameters:
#       $1      last_file
#       $2      new_file
#       $3      log_file
#       $4      out_file
#       $5      first_page
#       $6      DEBUG
#
function check_config {

        typeset -r last_file=$1
        typeset -r new_file=$2
        typeset -r log_file=$3
        typeset -r out_file=$4
        typeset -r first_page=$5
        typeset -r DEBUG=$6

	if [ $DEBUG -eq 1 ]
	then
		echo "\t$1,$2,$3,$4,$5\n"
	fi

	if [ -f `echo $last_file` ] && [ -f `echo $new_file` ]
	then
		tmp_fname=${new_file##*_}

		echo "$log_stamp ASSET CHK: COMPARING  ${tmp_fname%%.cfg} \c"

		sum1=`sum $last_file | cut -d" " -f1`
		sum2=`sum $new_file | cut -d" " -f1`

		if [ $sum1 -ne $sum2 ]
		then
			if [ $first_page -eq 0 ]
			then
				echo "" >> $out_file
				echo "\n"
				first_page=0
			fi

			echo "\n\n\t************ ${tmp_fname%%.cfg} DIFFERENCES FOUND *************\n" >> $out_file
			echo " : ** DIFFERENCES FOUND **"
			echo "\n# diff -c $last_file $new_file\n" | tee -a $log_file $out_file 1>/dev/null
			diff -c $last_file $new_file | tee -a $log_file $out_file 1>/dev/null
			echo "-------------------------------------------------------\n" >> $out_file

		fi
	fi
}

#
################## End Function Declarations #######################

############## Start BACKGROUND Processing #################

if [ $PERF -ne 0 ]
then

	if [ $interval_secs -ne 0 ]
	then
		PERF_INTERVAL=$interval_secs
	fi

	if [ $duration_secs -ne 0 ]
	then
		PERF_SECS=$duration_secs
	fi

	duration_count=$(( ($PERF_SECS/$PERF_INTERVAL)-($PERF_SECS%$PERF_INTERVAL) ))

	echo "sys_diag: ------- (Background) DATA COLLECTION FOR $PERF_SECS secs Started -------\n"

	echo "$log_stamp # /usr/bin/vmstat $PERF_INTERVAL $duration_count > $vmstat_file 2>&1 &"
	/usr/bin/vmstat $PERF_INTERVAL $duration_count > $vmstat_file 2>&1 &
	vmpid=$!


	echo "$log_stamp # /usr/bin/iostat -xn $PERF_INTERVAL $duration_count > $iostat_file 2>&1 &"
	/usr/bin/iostat -xn $PERF_INTERVAL $duration_count > $iostat_file 2>&1 &
	iopid=$!

	echo "$log_stamp # /usr/bin/mpstat $PERF_INTERVAL $duration_count > $mpstat_file 2>&1 &"
	/usr/bin/mpstat $PERF_INTERVAL $duration_count > $mpstat_file 2>&1 &
	mppid=$!

	num_nets=0

	for i in `/usr/sbin/ifconfig -a |  grep ": " | cut -d":" -f1`
	do
   		num_nets=$(($num_nets+1))
		netstat_file=$sysd_dir'/sysd_net'$num_nets'_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
		echo "$log_stamp # /usr/bin/netstat -i -I $i $PERF_INTERVAL $duration_count > $netstat_file 2>&1 &"
		/usr/bin/netstat -i -I $i $PERF_INTERVAL $duration_count > $netstat_file 2>&1 &
		netpid[$num_nets]=$!
	done

	if [ $VERBOSE -ne 0 ] || [ $NETWORK -ne 0 ]
	then
		snoop_file=$sysd_dir'/sysd_snoop_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
		/usr/sbin/snoop -c 300 > $snoop_file 2>&1 &
		snooppid=$!

#		/usr/sbin/snoop -d nf0 -c 100 >> $outfile
#TJ
#		for i in `/usr/sbin/ifconfig -a |  grep : | cut -d: -f1`
#		do
#			/usr/sbin/snoop -V -d $i -c 300 >> $outfile
#		done
	fi

	num_llts=0

	if [ -x /sbin/lltstat ]		# VCS LLT interconnect stats,..if there
	then
	    /sbin/lltstat -z	# RESET lltstat packet Counters to Zero

	    for i in `/sbin/lltstat -P | cut -d ":" -f1 | grep -v LLT` # lists LLT if's..
	    do
   		num_llts=$(($num_llts+1))

 		j=${i%[0-9]}    #### device name (ce, ge, hme, qfe..)
		k=${i#$j}	#### device instance (#)

		if [ $DEBUG -eq 1 ]
		then
			echo "\n\t$j:$k : num_llts=$num_llts\n"
		fi

		kstat_net_file=$sysd_dir'/sysd_llt'$num_llts'_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
		echo "$log_stamp # /usr/bin/kstat -p -c net $j:$k:*:*packets $PERF_INTERVAL $duration_count > $kstat_net_file 2>&1 &" 
		/usr/bin/kstat -p -c net $j:$k:*:*packets $PERF_INTERVAL $duration_count > $kstat_net_file 2>&1 &

		kstatpid[$num_llts]=$!
	    done
	else
		echo "\n\n\tlltstat not in /sbin/lltstat\n\n" > $outfile
	fi

	if [ -x /usr/sbin/vxstat ]		# Reset the Veritas Stats
	then
		/usr/sbin/vxstat -r
	fi

#TJ Add :  trapstat $PERF_INTERVAL $duration_count
#TJ Add :  intrstat $PERF_INTERVAL $duration_count

fi

############ START FOREGROUND PROCESSING ##################

echo "\nsys_diag: ------- (Foreground) Gathering System Configuration Details -------"

echo "***************************************************************************" > $outfile
echo "* SYS_DIAG v$SYS_DIAG_VER\t\t"`date`" " >> $outfile
echo "*" >> $outfile

echo "* hostname        \t:  "`hostname`"\c" >> $outfile

if [ -x /usr/bin/zonename ]
then
	echo "\t\t   zonename :  "`/usr/bin/zonename` >> $outfile
else
	echo "\n" >> $outfile
fi

echo "$log_stamp # uname -a ..."
echo "* uname -a  :\n*\t"`/usr/bin/uname -a`" ">> $outfile

echo "$log_stamp # hostid ..."
echo "*\n* hostid            :  "`/usr/bin/hostid`" " >> $outfile

echo "$log_stamp # domainname (DNS) ..."
echo "* domainname (DNS)  :  "`/usr/bin/domainname`" " >> $outfile

if [ -f /etc/ssphostname ]
then
	echo "$log_stamp # cat /etc/ssphostname ..."
	echo "*\n* ssphostname\t:  "`cat /etc/ssphostname`"*\n" >> $outfile
fi

echo "* uptime          :  $Up_Time" >> $outfile
echo "*\n* UID             :  "`id` >> $outfile
echo "* sys_diag args   :  $CMD_LINE" >> $outfile

echo "*\n* Report Label : $label"  >> $outfile
echo "* Output File  : $outfile" >> $outfile
echo "***************************************************************************" >> $outfile

echo "\n\n\tTABLE OF CONTENTS :\n" >> $outfile
echo "\t\tSection 01> *	System / Device Information\n" >> $outfile
echo "\t\tSection 02> *	E10K / F25K / SunFire System Information\n" >> $outfile
echo "\t\tSection 03> *	Processor / Performance Information\n" >> $outfile
echo "\t\tSection 04> *	Kernel Zones / Tunables/ SRM\n" >> $outfile
echo "\t\tSection 05> *	Storage Device / Array Enclosure Information\n" >> $outfile
echo "\t\tSection 06> *	Volume Manager Information\n" >> $outfile
echo "\t\tSection 07> *	Filesystem / Swap Information\n" >> $outfile
echo "\t\tSection 08> *	I/O Statistics\n" >> $outfile
echo "\t\tSection 09> *	NFS Information\n" >> $outfile
echo "\t\tSection 10> *	Networking Information\n" >> $outfile
echo "\t\tSection 11> *	Tty / Modem Configurations\n" >> $outfile
echo "\t\tSection 12> *	User / Account / Group Info\n" >> $outfile
echo "\t\tSection 13> *	Naming Services (NIS/NIS+/...)\n" >> $outfile
echo "\t\tSection 14> *	Security / System Configuration Files\n" >> $outfile
echo "\t\tSection 15> *	Clustering / HA Information\n" >> $outfile
echo "\t\tSection 16> *	Sun N1 SP Configuration\n" >> $outfile
echo "\t\tSection 17> *	Application / Oracle Config Files\n" >> $outfile
echo "\t\tSection 18> *	Packages Installed\n" >> $outfile
echo "\t\tSection 19> *	Patch Information\n" >> $outfile
echo "\t\tSection 20> *	Crontab File Listings\n" >> $outfile
echo "\t\tSection 21> *	FMD / System Messages / Log Files\n" >> $outfile

if [ $TRACK -ne 0 ]
then
	echo "\t\tSection 22> *	Asset / Configuration Management -CHANGES-\n" >> $outfile
else
	echo "\t\tSection 22>   Asset / Configuration Management -CHANGES-\n" >> $outfile
fi

if [ $PERF -ne 0 ]
then
	echo "\t\tSection 23> *	System Analysis : Initial Findings / Errors/Warnings\n" >> $outfile
	echo "\t\tSection 24> *	Performance Analysis : Potential Issues" >> $outfile
else
	echo "\t\tSection 23>   System Analysis : Initial Findings\n" >> $outfile
	echo "\t\tSection 24>   Performance Analysis : Potential Issues" >> $outfile
fi

#######################  SYSTEM / DEVICE INFO   #####################

echo "\n$log_stamp ######  SYSTEM / DEVICE INFO  ######"
echo "" >> $outfile
echo "## 01 #################  SYSTEM / DEVICE INFO   #####################\n" >> $outfile

if [ $ALL -ne 0 ] || [ $LONG -ne 0 ] || [ $CONFIG -ne 0 ] || [ $TRACK -ne 0 ]
then
	if [ -x /usr/platform/`uname -m`/sbin/prtdiag ]
	then
		echo "# prtdiag\n" >> $outfile
		echo "$log_stamp # prtdiag ..."
		/usr/platform/`uname -m`/sbin/prtdiag -v >> $outfile
	else
		if [ -x /usr/platform/sun4u/sbin/prtdiag ]
		then
			echo "# prtdiag\n" >> $outfile
			echo "$log_stamp # prtdiag ..."
			/usr/platform/sun4u/sbin/prtdiag -v >> $outfile
		else

			if [ -x /usr/platform/sun4u1/sbin/prtdiag ]
			then
				echo "# prtdiag\n" >> $outfile
				echo "$log_stamp # prtdiag ..."
				/usr/platform/sun4u/sbin/prtdiag -v >> $outfile
			else
				echo "$log_stamp  prtdiag NOT found, skipping\n"
			fi

		fi
	fi
fi


	echo "\n\n" >> $outfile
	echo "# prtconf | grep Memory\n" >> $outfile
	echo "$log_stamp # prtconf | grep Memory ..."
	/usr/sbin/prtconf | grep Memory >> $outfile


	if [ -x /usr/sbin/sysdef ]
	then
        	echo "\n" >> $outfile
		echo "_____________________________________________________\n" >> $outfile
        	echo "# sysdef | tail -75\n" >> $outfile
        	echo "$log_stamp # sysdef  | tail -75 ..."
        	/usr/sbin/sysdef | tail -75 >> $outfile
		echo "_____________________________________________________\n" >> $outfile
	fi

	
#TJ	kcage=`grep kernel_cage_enable /etc/system | wc -l`

#TJ	if [ $kcage -gt 1 ]
#TJ	then
#TJ		kernel_cage_enabled=`grep kernel_cage_enable /etc/system | cut -d"=" -f2`

        	echo "$log_stamp # Checking Kernel Cage settings ..."
        	echo "\n\n# grep kernel_cage_enable /etc/system\n" >> $outfile
		grep kernel_cage_enable /etc/system >> $outfile
        	echo "\n# grep kcage_split /etc/system\n" >> $outfile
		grep kcage_split /etc/system >> $outfile
#TJ	else
#TJ    		echo "  ** Kernel Cage is Disabled ** : DR is not possible **\n\n" >> $outfile
#TJ    		echo "$log_stamp # ** Kernel Cage is Disabled ** : DR is not possible **"
#TJ	fi

	
	if [ -x /usr/bin/busstat ]
	then
		/usr/bin/busstat -l | grep -i axq

		if [ $? -eq 0 ]
		then
        		echo "\n" >> $outfile
        		echo "# busstat -w axq,pic0=cdc_hits,pic1=total_cdc_read 1 1\n" >> $outfile
        		echo "$log_stamp # busstat -w axq,pic0=cdc_hits,pic1=total_cdc_read 1 1 ..."
        		/usr/bin/busstat -w axq,pic0=cdc_hits,pic1=total_cdc_read 1 1 >> $outfile
		fi
	fi

        echo "\n" >> $outfile
        echo "# modinfo\n" >> $outfile
        echo "$log_stamp # modinfo ..."
        /usr/sbin/modinfo >> $outfile

	echo "\n" >> $outfile
	echo "# eeprom\n" >> $outfile
	echo "$log_stamp # eeprom ..."
	/usr/sbin/eeprom >> $outfile

	if [ -x /usr/bin/coreadm ]		# core config..
	then
		echo "\n" >> $outfile
		echo "# /usr/bin/coreadm\n" >> $outfile
		echo "$log_stamp # /usr/bin/coreadm ..."
		/usr/bin/coreadm >> $outfile
	fi

	if [ -f /usr/sbin/dumpadm ]		# core config..
	then
		echo "\n\n" >> $outfile
		echo "# /usr/sbin/dumpadm\n" >> $outfile
		echo "$log_stamp # /usr/sbin/dumpadm ..."
		/usr/sbin/dumpadm >> $outfile
	fi


if [ $LONG -ne 0 ] || [ $VERBOSE -ne 0 ]
then
    
	if [ -f /etc/bootparams ]	# diskless client bootparams..
	then
	    	echo "\n" >> $outfile
		echo "_____________________________________________________\n" >> $outfile
	    	echo "# cat /etc/bootparams\n" >> $outfile
	    	echo "$log_stamp # cat /etc/bootparams ..."
	    	cat /etc/bootparams >> $outfile
		echo "_____________________________________________________\n" >> $outfile
	fi

	if [ -d /export*/install ]	  #### Local Jumpstart images..
	then
		echo "\n$log_stamp ### Probing Local Install / Jumpstart Images..."
		echo "" >> $outfile
		echo "\n\n#############  Local Jumpstart.. Install Images  ###########\n\n" >> $outfile
		echo "# ls -l /export*/install/*/*\n" >> $outfile
		echo "$log_stamp # ls -l /export*/install/*/* ..."
		ls -l /export*/install/*/* >> $outfile

		if [ -f /export/*/*/sysidcfg ]
		then
			echo "^L" >> $outfile
			echo "\n\n\t######  /export/*/*/sysidcfg   #####\n\n" >> $outfile
			echo "# cat /export/*/*/sysidcfg\n" >> $outfile
			echo "$log_stamp # cat /export/*/*/sysidcfg ..."
			cat /export/*/*/sysidcfg >> $outfile
			echo "_____________________________________________________\n" >> $outfile
		fi

		if [ -f /export/install/profile/sysidcfg ]
		then
			echo "^L" >> $outfile
			echo "\n\n\t######  /export/install/profile/sysidcfg   #####\n\n" >> $outfile
			echo "# cat /export/install/profile/sysidcfg\n" >> $outfile
			echo "$log_stamp # cat /export/install/profile/sysidcfg ..."
			cat /export/install/profile/sysidcfg >> $outfile
			echo "_____________________________________________________\n" >> $outfile
		fi

		if [ -f /export/install/profile/rules ]
                then
                        echo "^L" >> $outfile
                        echo "\n\n\t######  /export/install/profile/rules   #####\n\n" >> $outfile
                        echo "# cat /export/install/profile/rules\n" >> $outfile
                        echo "$log_stamp # cat /export/install/profile/rules ..."
                        cat /export/install/profile/rules >> $outfile
			echo "_____________________________________________________\n" >> $outfile
                fi
	fi

	if [ $VERBOSE -ne 0 ]
	then

	    echo "\n" >> $outfile
	    echo "_____________________________________________________\n" >> $outfile
	    echo "# cat /etc/path_to_inst\n" >> $outfile
	    echo "$log_stamp # cat /etc/path_to_inst ..."
	    cat /etc/path_to_inst >> $outfile
	    echo "_____________________________________________________\n" >> $outfile

	fi

fi

################  E10K / SunFire / F25K Device/ SC Info #################

echo "\n$log_stamp ######  E10K / F25K / SunFire System INFO  ######"
echo "" >> $outfile
echo "## 02 #############  E10K / F25K / SunFire System Information  ##############\n\n" >> $outfile

if [ $LONG -ne 0 ] 	# Extended Configuration listing : kernel cage /DR /SAN device listings..
then
    if [ -x /usr/sbin/cfgadm ]
    then
	echo "# /usr/sbin/cfgadm -l\n" >> $outfile
	echo "$log_stamp # cfgadm  -l ..."
	/usr/sbin/cfgadm -l >> $outfile

	if [ $? -eq 2 ]
	then
		echo "\t/usr/sbin/cfgadm NOT supported on this platform.\n" >> $outfile
		echo "$log_stamp WARNING: /usr/sbin/cfgadm NOT supported on this platform."
	else
	    if (( $Solaris_Rev > 8 ))
	    then
		echo "\n# /usr/sbin/cfgadm -al\n" >> $outfile
		echo "$log_stamp # cfgadm  -al ..."
		/usr/sbin/cfgadm -al >> $outfile

		echo "\n# /usr/sbin/cfgadm -v\n" >> $outfile
		echo "$log_stamp # cfgadm  -v ..."
		/usr/sbin/cfgadm -v >> $outfile

		echo "\n# /usr/sbin/cfgadm -av | grep memory | grep perm \t(Caged Kernel boards) :\n" >> $outfile
		echo "$log_stamp # cfgadm  -av | grep memory | grep perm ..."
		/usr/sbin/cfgadm -av | grep memory | grep perm >> $outfile
	    fi
	fi

    else
	echo "\n/usr/sbin/cfgadm NOT found, skipping.\n" >> $outfile
	echo "$log_stamp  /usr/sbin/cfgadm NOT found, skipping.\n"
    fi
fi

if [ -d /opt/SUNWssp ]			# E10K / SSP domain info
then
	echo "\n" >> $outfile
	echo "# domain_status\n" >> $outfile
	echo "$log_stamp # domain_status ..."
	domain_status >> $outfile

	echo "\n" >> $outfile
	echo "# domain_history\n" >> $outfile
	echo "$log_stamp # domain_history..."
	domain_history >> $outfile
else
	echo "\n\n/opt/SUNWssp NOT found, skipping.\n" >> $outfile
	echo "$log_stamp  /opt/SUNWssp NOT found, skipping.\n"
fi

# test to see if on an F25K SC .... or could look for /opt/SUNWSMS
#	interface=`/usr/sbin/ifconfig -a | grep scman`
#	if [ $? -eq 0 ]

if [ -d /opt/SUNWSMS/bin ] 	# E25K / SC domain info
then

#	if [ $PROMPT -ne 0 ] && [ $User_Name != "sms-svc" ] 
#	then
#		echo "Please enter sms-svc password :"
#		su - sms-svc
#
#		if [ $? -eq 0 ]
#		then
#			sud=1	# su was successfull..
#		fi
#	fi


	echo "\n" >> $outfile
	echo "# /opt/SUNWSMS/bin/showplatform\n" >> $outfile
	echo "$log_stamp # /opt/SUNWSMS/bin/showplatform ..."
	/opt/SUNWSMS/bin/showplatform >> $outfile

	echo "\n" >> $outfile
	echo "# /opt/SUNWSMS/bin/showplatform -v\n" >> $outfile
	echo "$log_stamp # /opt/SUNWSMS/bin/showplatform  -v..."
	/opt/SUNWSMS/bin/showplatform -v >> $outfile

	echo "\n" >> $outfile
	echo "# /opt/SUNWSMS/bin/showboards\n" >> $outfile
	echo "$log_stamp # /opt/SUNWSMS/bin/showboards ..."
	/opt/SUNWSMS/bin/showboards >> $outfile

	echo "" >> $outfile

	for i in `/opt/SUNWSMS/bin/showplatform | grep -i Running | /usr/bin/awk '{ print $1 }' `
	do
		echo "\n# /opt/SUNWSMS/bin/showobpparams -d $i\n" >> $outfile
		echo "$log_stamp # /opt/SUNWSMS/bin/showobpparams -d $i ..."
		/opt/SUNWSMS/bin/showobpparams -d $i >> $outfile
	done

	for i in `/opt/SUNWSMS/bin/showplatform | grep -i "Powered On" | /usr/bin/awk '{ print $1 }' `
	do
		echo "\n# /opt/SUNWSMS/bin/showobpparams -d $i\n" >> $outfile
		echo "$log_stamp # /opt/SUNWSMS/bin/showobpparams -d $i ..."
		/opt/SUNWSMS/bin/showobpparams -d $i >> $outfile
	done

	echo "\n" >> $outfile
	echo "# /opt/SUNWSMS/bin/showfailover -v\n" >> $outfile
	echo "$log_stamp # /opt/SUNWSMS/bin/showfailover -v ..."
	/opt/SUNWSMS/bin/showfailover -v >> $outfile


	if [ -d /etc/opt/SUNWSMS/config ]   # E25K / SC IP configs
	then
       	 echo "^L\n" >> $outfile
	 echo "_____________________________________________________\n" >> $outfile
       	 echo "# cat /etc/opt/SUNWSMS/config/MAN.cf\n" >> $outfile
       	 echo "$log_stamp # cat /etc/opt/SUNWSMS/config/MAN.cf ..."
       	 cat /etc/opt/SUNWSMS/config/MAN.cf >> $outfile
	 echo "_____________________________________________________\n" >> $outfile
	fi

#	if [ $PROMPT -ne 0 ] && [ $sud -eq 1 ]	# exit back from 'sms-svc'
#	then
#		sud=0
#		exit
#	fi


else
	NOT_SF_SC=1
fi



########################  PROCESSOR / PERFORMANCE INFO ###################

if [ $ALL -ne 0 ] || [ $PERF -ne 0 ]
then
	echo "\n" >> $outfile
	echo "\n$log_stamp ######  PROCESSOR / PERFORMANCE INFO ######"
	echo "## 03 ##################  PROCESSOR / PERFORMANCE INFO ###################\n\n" >> $outfile

	echo "# /usr/sbin/psrinfo -v\n" >> $outfile
	echo "$log_stamp # /usr/sbin/psrinfo -v ..."
	/usr/sbin/psrinfo -v >> $outfile

	if (( $Solaris_Rev > 8 ))
	then
		echo "\n" >> $outfile
		echo "# /usr/sbin/psrinfo -pv\n" >> $outfile
		echo "$log_stamp # /usr/sbin/psrinfo -pv ..."
		/usr/sbin/psrinfo -pv >> $outfile
	fi

	echo "\n\n# /usr/sbin/psrset -q\n" >> $outfile
	echo "$log_stamp # /usr/sbin/psrset -q ..."
	/usr/sbin/psrset -q >> $outfile

	echo "\n\n# /usr/bin/mpstat 1 5\n" >> $outfile
	echo "$log_stamp # /usr/bin/mpstat 1 5 ..."
	/usr/bin/mpstat 1 5 >> $outfile

	echo "\n" >> $outfile
	echo "# vmstat 1 10 \n" >> $outfile
	echo "$log_stamp # vmstat 1 10 ..."
	vmstat 1 10 >> $outfile

	log_stamp='sys_diag:'`date '+%m%d_%H%M'`':'

#	echo "\n" >> $outfile
#	echo "# mem -p \n" >> $outfile
#	echo "$log_stamp # mem -p ..."
#	mem -p >> $outfile

	echo "\n\n# /usr/bin/vmstat -s\n" >> $outfile
	echo "$log_stamp # /usr/bin/vmstat -s ..."
	/usr/bin/vmstat -s >> $outfile

	echo "\n\n# /usr/bin/vmstat -i\n" >> $outfile
	echo "$log_stamp # /usr/bin/vmstat -i ..."
	/usr/bin/vmstat -i >> $outfile

        echo "\n\n# /usr/bin/pagesize\n" >> $outfile
        echo "$log_stamp # /usr/bin/pagesize ..."
        /usr/bin/pagesize >> $outfile


	if (( $Solaris_Rev < 10 ))
	then
        	echo "\n\n# /usr/bin/netstat -k | grep pp_kernel\n" >> $outfile
        	echo "$log_stamp # /usr/bin/netstat -k | grep pp_kernel ..."
        	/usr/bin/netstat -k | grep pp_kernel >> $outfile
	fi

	echo "" >> $outfile
	echo "\n# /usr/bin/ipcs -a\n" >> $outfile
	echo "$log_stamp # /usr/bin/ipcs -a ..."
	/usr/bin/ipcs -a >> $outfile

	if [ -x /opt/RMCmem/bin/prtmem ]
	then
		echo "" >> $outfile
		echo "# prtmem\n" >> $outfile
		echo "$log_stamp # prtmem ..."
		/opt/RMCmem/bin/prtmem >> $outfile
	fi

	if [ -x /opt/RMCmem/bin/memps ]		# FS Cache
	then
		echo "" >> $outfile
		echo "# memps -m\n" >> $outfile
		echo "$log_stamp # memps -m ..."
		/opt/RMCmem/bin/memps -m >> $outfile
	fi

#TJ Only do this section if LONG rpt or PERF Details needed..

    if [ $LONG -ne 0 ] || [ $PERF -ne 0 ]
    then

#	if [[ -x /usr/bin/prstat  &&  ($Solaris_Rev -ge 10) ]]
	if [ -x /usr/bin/prstat ]
	then
		echo "" >> $outfile

		echo "\n# prstat -c -a 1 1 \n" >> $outfile
		echo "$log_stamp # prstat -c -a 1 1 ..."
		/usr/bin/prstat -c -a 1 1 >> $outfile

		echo "\n# prstat -c -J 1 1 \n" >> $outfile
		echo "$log_stamp # prstat -c -J 1 1 ..."
		/usr/bin/prstat -c -J 1 1 >> $outfile


		if (( $Solaris_Rev >= 10 ))
		then
			echo "\n# prstat -c -Z 1 1 \n" >> $outfile
			echo "$log_stamp # prstat -c -Z 1 1 ..."
			/usr/bin/prstat -c -Z 1 1 >> $outfile
		fi

		echo "\n# prstat -c 1 2 \n" >> $outfile
		echo "$log_stamp # prstat -c 1 2 ..."
		/usr/bin/prstat -c 1 2 >> $outfile

		echo "\n# prstat -c -v 1 3\n" >> $outfile
		echo "$log_stamp # prstat -c -v 1 3 ..."
		/usr/bin/prstat -c -v 1 3 >> $outfile
	fi

	if [ -x /usr/local/bin/top ]
	then
		echo "" >> $outfile
		echo "# top -S -d1 300 \n" >> $outfile
		echo "$log_stamp # top -S -d1 300 ..."
		/usr/local/bin/top -S -d1 300 >> $outfile

		echo "" >> $outfile
		echo "# top -S -d1 -ores 100 \n" >> $outfile
		echo "$log_stamp # top -S -d1 -ores 100 ..."
		/usr/local/bin/top -S -d1 -ores 100 >> $outfile
	else
                echo "\n\n# ps -e -opid,ppid,user,nlwp,pmem,vsz,rss,s,time,stime,pri,nice,pcpu,args (by %CPU) :\n\n" >> $outfile
                echo "\n\n# ps -e -opid,ppid,user,nlwp,pmem,vsz,rss,s,time,stime,pri,nice,pcpu,args (by %CPU) :\n\n" >> $ps_cpu_file
                echo "$log_stamp # ps -e -o ...(by %CPU) ..."
                ps -e -opid,ppid,user,nlwp,pmem,vsz,rss,s,time,stime,pri,nice,pcpu,args | head -1 >> $outfile
                ps -e -opid,ppid,user,nlwp,pmem,vsz,rss,s,time,stime,pri,nice,pcpu,args | sort -r -k 13,13 | tail -60 >> $outfile
                ps -e -opid,ppid,user,nlwp,pmem,vsz,rss,s,time,stime,pri,nice,pcpu,args | sort -r -k 13,13 | tail -600 >> $ps_cpu_file

                echo "\n\n# ps -e -opid,ppid,user,nlwp,pmem,vsz,rss,s,time,stime,pri,nice,pcpu,args (by %MEM) :\n\n" >> $outfile
                echo "\n\n# ps -e -opid,ppid,user,nlwp,pmem,vsz,rss,s,time,stime,pri,nice,pcpu,args (by %MEM) :\n\n" >> $ps_mem_file
                echo "$log_stamp # ps -e -o ...(by %MEM) ..."
                ps -e -opid,ppid,user,nlwp,pmem,vsz,rss,s,time,stime,pri,nice,pcpu,args | head -1 >> $outfile
                ps -e -opid,ppid,user,nlwp,pmem,vsz,rss,s,time,stime,pri,nice,pcpu,args | sort -r -k 5,5 | tail -60 >> $outfile
                ps -e -opid,ppid,user,nlwp,pmem,vsz,rss,s,time,stime,pri,nice,pcpu,args | sort -r -k 5,5 | tail -600 >> $ps_mem_file
	fi

    fi


# TJ : p/lockstat -V -p x | dtrace ??
# TJ : pwdx -p x (shows workg dir of proc)


    if [ $VERBOSE -ne 0 ] || [ $PERF -ne 0 ]	## Added Additional buffers for S10, some for S9, none for S8
    then
	if [[ -x /usr/sbin/lockstat  &&  ($Solaris_Rev -ge 10) ]]
	then
		echo "" >> $outfile
		echo "# /usr/sbin/lockstat -AkW -n 75000 -D 20 sleep 5 \n" >> $outfile
		echo "$log_stamp # /usr/sbin/lockstat -AkW -n 75000 -D 20 sleep 5 ..."
		/usr/sbin/lockstat -AkW -n 75000 -D 20 sleep 5 >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile

		echo "" >> $outfile
		echo "# /usr/sbin/lockstat -AkP -n 75000 -D 20 sleep 5\n" >> $outfile
		echo "$log_stamp # /usr/sbin/lockstat -AkP -n 75000 -D 20 sleep 5 ..."
		/usr/sbin/lockstat -AkP -n 75000 -D 20 sleep 5 >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile

		echo "" >> $outfile
		echo "# /usr/sbin/lockstat -AkIW -n 75000 -D 20 sleep 5\n" >> $outfile
		echo "$log_stamp # /usr/sbin/lockstat -AkIW -n 75000 -D 20 sleep 5 ..."
		/usr/sbin/lockstat -AkIW -n 75000 -D 20 sleep 5 >> $outfile
	elif [[ -x /usr/sbin/lockstat  &&  ($Solaris_Rev -eq 9) ]] 
	then
		echo "" >> $outfile
		echo "# /usr/sbin/lockstat -AkW -n 50000 -D 20 sleep 5\n" >> $outfile
		echo "$log_stamp # /usr/sbin/lockstat -AkW -n 50000 -D 20 sleep 10 ..."
		/usr/sbin/lockstat -AkW -n 50000 -D 20 sleep 10 >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile

		echo "" >> $outfile
		echo "# /usr/sbin/lockstat -AkP -n 50000 -D 20 sleep 10 \n" >> $outfile
		echo "$log_stamp # /usr/sbin/lockstat -AkP -n 50000 -D 20 sleep 5 ..."
		/usr/sbin/lockstat -AkP -n 50000 -D 20 sleep 5 >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile

		echo "" >> $outfile
		echo "# /usr/sbin/lockstat -AkIW -n 50000 -D 20 sleep 5 \n" >> $outfile
		echo "$log_stamp # /usr/sbin/lockstat -AkIW -n 50000 -D 20 sleep 5 ..."
		/usr/sbin/lockstat -AkIW -n 50000 -D 20 sleep 5 >> $outfile
	elif [[ -x /usr/sbin/lockstat  &&  ($Solaris_Rev -eq 8) ]] 
	then				
		echo "" >> $outfile
		echo "# /usr/sbin/lockstat -AkW -D 20 sleep 5\n" >> $outfile
		echo "$log_stamp # /usr/sbin/lockstat -AkW -D 20 sleep 5 ..."
		/usr/sbin/lockstat -AkW -D 20 sleep 5 >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile

		echo "" >> $outfile
		echo "# /usr/sbin/lockstat -AkP -D 20 sleep 5\n" >> $outfile
		echo "$log_stamp # /usr/sbin/lockstat -AkP -D 20 sleep 5 ..."
		/usr/sbin/lockstat -AkP -D 20 sleep 5 >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile

		echo "" >> $outfile
		echo "# /usr/sbin/lockstat -AkIW -D 20 sleep 5\n" >> $outfile
		echo "$log_stamp # /usr/sbin/lockstat -AkIW -D 20 sleep 5 ..."
		/usr/sbin/lockstat -AkIW -D 20 sleep 5 >> $outfile

	fi

	if [ -x /usr/sbin/lockstat ]
	then
		echo "\tNOTE: Refer to the detailed lockstat report files listed in Sec.24/MPSTAT Analysis" >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	fi

	if [ $LONG -ne 0 ] && [ -x /usr/proc/bin/pmap ]	# investigate the 4 or 5 top processes
	log_stamp='sys_diag:'`date '+%m%d_%H%M'`':'

	then
		for i in `ps -e -opid,pcpu | sort -r -k 2,2 | /usr/bin/awk '{ print $1 }' | tail +2 | head -10`

		do		
			if [ $i -eq $$ ] 	## If sys_diag, skip
			then
				continue
			fi

			if ( [ $PERF -ne 0 ] && ( [ $i -eq $vmpid ] || [ $i -eq $iopid ] || [ $i -eq $mppid ] || [ $i -eq netpid[1] ] ))
			then
				continue
			fi

			if ( [ $PERF -ne 0 ] && [ $num_llts -gt 0 ] )
			then
				if [ $i -eq kstatpid[1] ]
				then
					continue
				fi
			fi

			echo "" >> $outfile
			echo "# pmap -x $i\n" >> $outfile
			echo "$log_stamp # pmap -x $i ..."
			/usr/proc/bin/pmap -xs $i >> $outfile 2>/dev/null
			
			echo "" >> $outfile
			echo "# ptree -a $i\n" >> $outfile
			echo "$log_stamp # ptree -a $i ..."
			/usr/proc/bin/ptree -a $i >> $outfile 2>/dev/null

			if [[ -x /usr/proc/bin/pfiles  &&  ($Solaris_Rev -gt 8) ]]
			then
				echo "" >> $outfile
				echo "# pfiles $i\n" >> $outfile
				echo "$log_stamp # pfiles $i ..."
				/usr/proc/bin/pfiles $i >> $outfile 2>/dev/null
			fi
		done
	fi

	if [ -x /usr/sbin/trapstat ]
	then
		echo "" >> $outfile
		echo "# /usr/sbin/trapstat\n" >> $outfile
		echo "$log_stamp # /usr/sbin/trapstat 1 3 ..."
		/usr/sbin/trapstat 1 3 >> $outfile

		echo "\n\n\n" >> $outfile
		echo "# /usr/sbin/trapstat -l\n" >> $outfile
		echo "$log_stamp # /usr/sbin/trapstat -l ..."
		/usr/sbin/trapstat -l >> $outfile

		echo "\n\n\n" >> $outfile
		echo "# /usr/sbin/trapstat -t 1 3\n" >> $outfile
		echo "$log_stamp # /usr/sbin/trapstat -t 1 3 ..."
		/usr/sbin/trapstat -t 1 3 >> $outfile

		echo "\n\n\n" >> $outfile
		echo "# /usr/sbin/trapstat -T 1 3\n" >> $outfile
		echo "$log_stamp # /usr/sbin/trapstat -T 1 3 ..."
		/usr/sbin/trapstat -T 1 3 >> $outfile
	fi

	if [ -x /usr/sbin/intrstat ]
	then
		echo "" >> $outfile
		echo "# /usr/sbin/intrstat\n" >> $outfile
		echo "$log_stamp # /usr/sbin/intrstat 1 3 ..."
		/usr/sbin/intrstat 1 3 >> $outfile
	fi
    fi

fi


###################  KERNEL ZONES(S10)/ SRM/ TUNABLES  ####################

if [ $ALL -ne 0 ] || [ $CONFIG -ne 0 ]
then
	echo "" >> $outfile
	echo "\n$log_stamp ######  KERNEL ZONES(s10)/ SRM / TUNABLES  ######"
	echo "## 04 ##############  KERNEL ZONES(s10)/ SRM/ TUNABLES  #################\n\n" >> $outfile

	if [ -x /usr/sbin/zoneadm ]	# S10 Zones / Containers ..
	then
		echo "# /usr/sbin/zoneadm list -v\n" >> $outfile
		echo "$log_stamp # /usr/sbin/zoneadm list -v ..."
		/usr/sbin/zoneadm list -v >> $outfile
	fi

		# SRM Projects ..
	if [[ -x /usr/bin/projects  &&  ($Solaris_Rev -ge 10) ]]
	then
		echo "\n# /usr/bin/projects -l \n" >> $outfile
		echo "$log_stamp # /usr/bin/projects -l ..."
		/usr/bin/projects -l >> $outfile
	elif [[ -x /usr/bin/projects  &&  ($Solaris_Rev -ge 8) ]]
	then
		echo "\n# /usr/bin/projects -v \n" >> $outfile
		echo "$log_stamp # /usr/bin/projects -v ..."
		/usr/bin/projects -v >> $outfile
	fi


        if [ -x /usr/bin/svcs ]	&& [ -x /usr/bin/rcapstat ]	# S10 SSM : Resource cap stats
        then
		rcap_online=`/usr/bin/svcs -av | grep -n rcap | /usr/bin/awk '{ print $1 }'`

		if [ $rcap_online = "online" ]
		then
			echo "\n" >> $outfile
			echo "# /usr/bin/rcapstat -g 1 5 \n" >> $outfile
			echo "$log_stamp # /usr/bin/rcapstat -g 1 5 ..."
			/usr/bin/rcapstat -g 1 5 >> $outfile

			echo "# /usr/bin/rcapstat 1 5 \n" >> $outfile
			echo "$log_stamp # /usr/bin/rcapstat 1 5 ..."
			/usr/bin/rcapstat 1 5 >> $outfile
		fi
        fi


	if [ -x /usr/sbin/rctladm ]	# SRM/OS resource controls ..
	then
		echo "\n\n# /usr/sbin/rctladm -l \n" >> $outfile
		echo "$log_stamp # /usr/sbin/rctladm -l ..."
		/usr/sbin/rctladm -l >> $outfile
	fi

	if [ -x /usr/bin/priocntl ]	# SRM/OS Class Priorities ..
	then
		echo "\n\n# /usr/bin/priocntl -l \n" >> $outfile
		echo "$log_stamp # /usr/bin/priocntl -l ..."
		/usr/bin/priocntl -l >> $outfile
	fi

	if [ -x /usr/sbin/acctadm ]	# Accounting ..
	then
		echo "\n\n# /usr/sbin/acctadm \n" >> $outfile
		echo "$log_stamp # /usr/sbin/acctadm ..."
		/usr/sbin/acctadm >> $outfile
	fi

	if [ -x /usr/sbin/acctadm ]	# Accounting ..
	then
		echo "\n\n# /usr/sbin/acctadm -r\n" >> $outfile
		echo "$log_stamp # /usr/sbin/acctadm -r..."
		/usr/sbin/acctadm -r >> $outfile
	fi

	echo "" >> $outfile
	echo "_____________________________________________________\n" >> $outfile
	echo "# tail -75 /etc/system \n" >> $outfile
	echo "$log_stamp # tail -75 /etc/system ..."
	tail -75 /etc/system >> $outfile
	cat /etc/system >> $system_file
	echo "_____________________________________________________\n" >> $outfile

	echo "" >> $outfile
	echo "# tail -40 /etc/init.d/sysetup \n\n" >> $outfile
	echo "$log_stamp # tail -40 /etc/init.d/sysetup ..."
	tail -40 /etc/init.d/sysetup >> $outfile
	echo "_____________________________________________________\n" >> $outfile

 	if [ -f /etc/power.conf ]	# Solaris Power Management
 	then
		echo "" >> $outfile
		echo "# cat /etc/power.conf\n" >> $outfile
		echo "$log_stamp # cat /etc/power.conf ..."
		cat /etc/power.conf >> $outfile
		echo "_____________________________________________________\n" >> $outfile
 	fi

fi

#################   STORAGE / VOLUME MANAGER INFO    ##################


if [ $ALL -ne 0 ] || [ $CONFIG -ne 0 ] || [ $IO -ne 0 ]
then

#	if [ $PROMPT -ne 0 ] && [ $User_Name != "root" ]  # su to 'root'
#	then
#		echo "Please enter Root Password :"
#		su - root
#
#		if [ $? -eq 0 ]
#		then
#			sud=1	# su was successfull..
#		fi
#	fi

	echo "" >> $outfile
	echo "\n$log_stamp ######  STORAGE / ARRAY INFO  ######"
	echo "## 05 ###############  STORAGE / ARRAY ENCLOSURE INFO  ###############\n\n" >> $outfile

	echo "# /usr/sbin/format\n" >> $outfile
	/usr/sbin/format -m << @EOI >> $outfile 2>&1
0
verify
disk 1
verify
disk 2
verify
disk 3
verify
disk 4
verify
disk 5
verify
quit
@EOI
	echo "\n" >> $outfile

	echo "\n" >> $outfile


#	if [ $PROMPT -ne 0 ] && [ $sud -eq 1 ]  # exit back from 'root'
#	then
#		sud=0
#		exit
#	fi

	echo "# prtconf -pv     {root/boot/disk DEVICES}\n" >> $outfile
	echo "$log_stamp # prtconf -pv ..."
	/usr/sbin/prtconf -pv | grep -i root >> $outfile
	/usr/sbin/prtconf -pv | grep -i boot >> $outfile
	/usr/sbin/prtconf -pv | grep -i disk >> $outfile


	if [ -f /usr/sbin/luxadm ]
	then
		echo "\n# luxadm probe\n" >> $outfile
		echo "$log_stamp # luxadm probe ..."
		/usr/sbin/luxadm probe >> $outfile

		for i in `/usr/sbin/luxadm probe | grep "Name:" | /usr/bin/awk '{ print $2 }' | cut -d":" -f2`
		do
			echo "\n\t>>>>>>>  $i  <<<<<<<<\n" >> $outfile

			echo "# luxadm display $i\n" >> $outfile
			echo "$log_stamp # luxadm display $i ..."
			/usr/sbin/luxadm display $i >> $outfile
		done
	else
		echo "\n\nNOTE:  /usr/sbin/luxadm NOT found, skipping.\n" >> $outfile
		echo "$log_stamp  /usr/sbin/luxadm NOT found, skipping.\n"
	fi

	if [ -f /usr/sbin/osa/lad ]
	then
		echo "\n# /usr/sbin/osa/lad\n" >> $outfile
		echo "$log_stamp # /usr/sbin/osa/lad  ..."
		/usr/sbin/osa/lad >> $outfile

		for i in `/usr/sbin/osa/lad | cut -d" " -f1`
		do
			echo "\n\t>>>>>>>  $i  <<<<<<<<\n" >> $outfile

			echo "# raidutil -c $i -i\n" >> $outfile
			echo "$log_stamp # raidutil -c $i -i ..."
			/usr/sbin/osa/raidutil -c $i -i >> $outfile

			echo "\n\n# rdacutil -i $i\n" >> $outfile
			echo "$log_stamp # rdacutil -i $i ..."
			/usr/sbin/osa/rdacutil -i $i >> $outfile

			echo "\n\n# drivutil -d $i\n" >> $outfile
			echo "$log_stamp # drivutil -d $i ..."
			/usr/sbin/osa/drivutil -d $i >> $outfile

			echo "\n\n# drivutil -i $i\n" >> $outfile
			echo "$log_stamp # drivutil -i $i ..."
			/usr/sbin/osa/drivutil -i $i >> $outfile

			echo "\n\n# drivutil -I $i\n" >> $outfile
			echo "$log_stamp # drivutil -I $i ..."
			/usr/sbin/osa/drivutil -I $i >> $outfile

			echo "\n\n# drivutil -l $i\n" >> $outfile
			echo "$log_stamp # drivutil -l $i ..."
			/usr/sbin/osa/drivutil -l $i >> $outfile
		done

	else
		echo "$log_stamp  /usr/sbin/osa/lad  NOT found, skipping.\n"
	fi

	log_stamp='sys_diag:'`date '+%m%d_%H%M'`':'

	echo "" >> $outfile
	echo "\n$log_stamp ######  STORAGE VOLUME MANAGEMENT INFO  ######"
	echo "## 06 ################  STORAGE VOLUME MANAGEMENT INFO  ################\n\n" >> $outfile


	if [ -d /usr/opt/SUNWmd ]		## Check for SDS 4.x Config
	then

		echo "\n$log_stamp ######  SOLARIS Disk Suite (SDS 4.x) Info  ######"
		echo "\t##  Solaris Disk Suite (SDS 4.x) Info  ##\n\n" >> $outfile

		echo "# /usr/opt/SUNWmd/metadb\n" >> $outfile
		echo "$log_stamp # /usr/opt/SUNWmd/metadb ..."
		/usr/opt/SUNWmd/metadb >> $outfile

		echo "\n# /usr/opt/SUNWmd/metastat\n" >> $outfile
		echo "$log_stamp # /usr/opt/SUNWmd/metastat ..."
		/usr/opt/SUNWmd/metastat >> $outfile
	else
		echo "\n\nNOTE:  /usr/opt/SUNWmd  (SDS 4.x) NOT found, skipping.\n\n" >> $outfile
#		echo "$log_stamp  /usr/opt/SUNWmd  (SDS 4.x) NOT found, skipping.\n"
	fi

	if [ -f /etc/lvm/md.tab ]		## Check for SDS/SVM Config
	then
		echo "\n$log_stamp ######  SOLARIS (SDS/SVM) VOLUME MANAGER Info  ######"
		echo "\t##  SOLARIS (SDS/SVM) VOLUME MANAGER Info  ##\n\n" >> $outfile

	    if [ -x /sbin/metadb ]
	    then
		echo "# /sbin/metadb\n" >> $outfile
		echo "$log_stamp # /sbin/metadb ..."
		/sbin/metadb >> $outfile

		echo "\n# /sbin/metastat\n" >> $outfile
		echo "$log_stamp # /sbin/metastat ..."
		/sbin/metastat >> $outfile
	    else
		echo "# /usr/sbin/metadb\n" >> $outfile
		echo "$log_stamp # /usr/sbin/metadb ..."
		/usr/sbin/metadb >> $outfile

		echo "\n# /usr/sbin/metastat\n" >> $outfile
		echo "$log_stamp # /usr/sbin/metastat ..."
		/usr/sbin/metastat >> $outfile
	    fi

	else
		echo "\n\nNOTE:  /etc/lvm/md.tab  (S9 LVM) NOT found, skipping.\n\n" >> $outfile
#		echo "$log_stamp  /etc/lvm/md.tab  (S9 LVM) NOT found, skipping.\n"
	fi


	if [ -x /usr/sbin/vxdisk ]
	then
		echo "\t_____________________________________________________\n" >> $outfile
		echo "\n$log_stamp ######  Veritas VOLUME MANAGER Info  ######"
		echo "\n\t##  Veritas VOLUME MANAGER Info  ##\n\n" >> $outfile

		echo "# /usr/sbin/vxlicense -p\n" >> $outfile
		echo "$log_stamp # /usr/sbin/vxlicense -p ..."
		/usr/sbin/vxlicense -p >> $outfile
	
		echo "\n\n# /usr/sbin/vxdisk list\n" >> $outfile
		echo "$log_stamp # /usr/sbin/vxdisk list ..."
		/usr/sbin/vxdisk list >> $outfile
	
		echo "\n" >> $outfile
		echo "# /usr/sbin/vxprint -S\n" >> $outfile
		echo "$log_stamp # /usr/sbin/vxprint -S ..."
		/usr/sbin/vxprint -S >> $outfile

		echo "\n" >> $outfile
		echo "# /usr/sbin/vxprint -Ath\n" >> $outfile
		echo "$log_stamp # /usr/sbin/vxprint -Ath ..."
		/usr/sbin/vxprint -Ath >> $outfile
		
		for i in `/usr/sbin/vxprint -S | grep Disk | cut -c13-`
		do
			echo "\n" >> $outfile
#			echo "# /usr/sbin/vxstat -g "$i"\n" >> $outfile
#			echo "$log_stamp # /usr/sbin/vxstat -g "$i" ..."
#			/usr/sbin/vxstat -g $i >> $outfile

			echo "# /usr/sbin/vxstat -g "$i" -i 1 -c 5\n" >> $outfile
			echo "$log_stamp # /usr/sbin/vxstat -g "$i" -i 1 -c 5 ..."
			/usr/sbin/vxstat -g $i -i 1 -c 5 >> $outfile
		done
		
		if [ -x /opt/VRTSvxfs/sbin/vxtunefs ]
		then
			for i in `df | grep -i "dev/vx/dsk" | cut -d" " -f1`
			do
				echo "\n" >> $outfile
				echo "# /opt/VRTSvxfs/sbin/vxtunefs "$i"\n" >> $outfile
				echo "$log_stamp # /opt/VRTSvxfs/sbin/vxtunefs "$i" ..."
				/opt/VRTSvxfs/sbin/vxtunefs $i >> $outfile
			done
		elif [ -x /usr/sbin/vxtunefs ]
		then
			for i in `df | grep -i "dev/vx/dsk" | cut -d" " -f1`
			do
				echo "\n" >> $outfile
				echo "# /usr/sbin/vxtunefs "$i"\n" >> $outfile
				echo "$log_stamp # /usr/sbin/vxtunefs "$i" ..."
				/usr/sbin/vxtunefs $i >> $outfile
			done

		fi

		echo "\n" >> $outfile
		echo "# /usr/sbin/vxdmpadm listctlr all\n" >> $outfile
		echo "$log_stamp # /usr/sbin/vxdmpadm listctlr all ..."
		/usr/sbin/vxdmpadm listctlr all >> $outfile

	else
		echo "\n\nNOTE:  /usr/sbin/vxdisk NOT found, skipping VX.\n\n" >> $outfile
#		echo "$log_stamp  /usr/sbin/vxdisk NOT found, skipping VX.\n"
	fi


	if [ -x /usr/sbin/zpool ]			## Solaris 10 ZFS 
	then
		echo "# /usr/sbin/zpool status -v\n" >> $outfile
		echo "$log_stamp # /usr/sbin/zpool status -v ..."
		/usr/sbin/zpool status -v >> $outfile

		echo "\n\n# /usr/sbin/zpool list\n" >> $outfile
		echo "$log_stamp # /usr/sbin/zpool list ..."
		/usr/sbin/zpool list >> $outfile

		echo "\n\n# /usr/sbin/zfs list\n" >> $outfile
		echo "$log_stamp # /usr/sbin/zfs list ..."
		/usr/sbin/zfs list >> $outfile
	fi

	#
	# NOTE: these commands run in the TS dispatcher class
	#
	#do ODM and QIO and vxfsstat
	#
#	if [ -x /opt/VRTS/bin/odmstat ]
#	then
#		priocntl -e -c TS /opt/VRTS/bin/odmstat -i 1 -c 5 -o local >> $outfile
#	fi

#	if [ -x /opt/VRTS/bin/qiostat ]
#	then
#      		priocntl -e -c TS /opt/VRTS/bin/qiostat -i 1 -c 5 -l -o local >> $outfile
#	fi

				## Check for Sun SAN FndaSuite/STMS/MPxIO
	if [ $LONG -ne 0 ] && [ -f /kernel/drv/fp.conf ]
	then
		echo "_____________________________________________________\n" >> $outfile
		echo "\n$log_stamp ######  Sun STMS / MPxIO Info  ######"
		echo "\t##  Sun STMS / MPxIO Info  ##\n\n" >> $outfile

		echo "# cat /kernel/drv/fp.conf\n" >> $outfile
		echo "$log_stamp # cat /kernel/drv/fp.conf ..."
		cat /kernel/drv/fp.conf >> $outfile
		echo "_____________________________________________________\n" >> $outfile

		if [ -f /kernel/drv/fcp.conf ]	## 
		then
			echo "# cat /kernel/drv/fcp.conf\n" >> $outfile
			echo "$log_stamp # cat /kernel/drv/fcp.conf ..."
			cat /kernel/drv/fcp.conf >> $outfile
		echo "_____________________________________________________\n" >> $outfile
		fi

		if [ -f /kernel/drv/scsi*vhci.conf ]	## 
		then
			echo "# cat /kernel/drv/scsi*vhci.conf\n" >> $outfile
			echo "$log_stamp # cat /kernel/drv/scsi*vhci.conf ..."
			cat /kernel/drv/scsi*vhci.conf >> $outfile
		fi
#	else
#		echo "\n\nNOTE:  /kernel/drv/fp.conf (MPxIO) NOT found, skipping.\n\n" >> $outfile
#		echo "$log_stamp  /kernel/drv/fp.conf (MPxIO) NOT found, skipping.\n"
	fi

fi


#######################  FILESYSTEM / SWAP INFO ##########################

if [ $ALL -ne 0 ] || [ $CONFIG -ne 0 ] || [ $IO -ne 0 ]
then
	echo "" >> $outfile
	echo "\n$log_stamp ######  FILESYSTEM / SWAP INFO  ######"
	echo "## 07 #################  FILESYSTEM / SWAP INFO ##########################\n\n" >> $outfile

	echo "# df\n" >> $outfile
	echo "$log_stamp # df ..."
	df >> $outfile

	echo "\n\n# df -k\n" >> $outfile
	echo "$log_stamp # df -k ..."
	df -k >> $outfile

	echo "\n" >> $outfile
	echo "# /usr/sbin/mount -v\n" >> $outfile
	echo "$log_stamp # mount -v ..."
	/usr/sbin/mount -v >> $outfile

	echo "\n" >> $outfile
	echo "# /usr/sbin/showmount -a\n" >> $outfile
	echo "$log_stamp # /usr/sbin/showmount -a ..."
	/usr/sbin/showmount -a >> $outfile

	echo "" >> $outfile
	echo "_____________________________________________________\n" >> $outfile
	echo "# cat /etc/vfstab\n" >> $outfile
	echo "$log_stamp # cat /etc/vfstab ..."
	cat /etc/vfstab >> $outfile
	echo "_____________________________________________________\n" >> $outfile

	# Clusr logical /..../vfstab.logical_host files ..

	if [ -d /etc/opt/SUNWcluster/conf/hanfs ]
	then
	   	echo "\n" >> $outfile
	   	echo "# cat /etc/opt/SUNWcluster/conf/hanfs/vfstab...\n" >> $outfile
	   	echo "$log_stamp # cat /etc/opt/SUNWcluster/conf/hanfs/vfstab ..."
		for i in /etc/opt/SUNWcluster/conf/hanfs/vfstab.*
		do
			echo "\n\t>>>>>>>  $i  <<<<<<<<\n" >> $outfile
			cat $i >> $outfile
			echo "_____________________________________________________\n" >> $outfile
			echo "\n" >> $outfile
		done
	fi

	echo "\n" >> $outfile
	echo "# /usr/sbin/swap -l\n" >> $outfile
	echo "$log_stamp # swap -l ..."
	/usr/sbin/swap -l >> $outfile

        echo "\n\n\n" >> $outfile
        echo "# swap -s\n" >> $outfile
        echo "$log_stamp # swap -s ..."
        /usr/sbin/swap -s >> $outfile

	if [ -f /opt/RMCmem/bin/prtswap ]
	then
		echo "\n" >> $outfile
		echo "#  /opt/RMCmem/bin/prtswap -l\n" >> $outfile
		echo "$log_stamp # prtswap -l ..."
		/opt/RMCmem/bin/prtswap -l >> $outfile
	fi	

	if [ -f /usr/bin/cachefsstat ]
	then
		echo "\n" >> $outfile
		echo "#  /usr/bin/cachefsstat\n" >> $outfile
		echo "$log_stamp # /usr/bin/cachefsstat ..."
		/usr/bin/cachefsstat >> $outfile
	fi	

fi


############################    I/O STATS    #############################

if [ $ALL -ne 0 ] || [ $PERF -ne 0 ] || [ $IO -ne 0 ]
then
	echo "" >> $outfile
	echo "\n$log_stamp ######  IO STATS  ######"
	echo "## 08 ######################    I/O STATS    #############################\n\n" >> $outfile

## !! TJ
	echo "# /usr/bin/iostat -nxe 3 2\n" >> $outfile
	echo "$log_stamp # /usr/bin/iostat -nxe 3 2 ..."
	/usr/bin/iostat -nxe 3 2 >> $outfile

	if [ $? -ne 0 ]
	then
		echo "\n\tERROR: You need to install an iostat patch..\n"
		echo "\t\tiostat is being re-run using only -x option\n"
		echo "\n\tERROR: You need to install an iostat patch\n" >> $outfile
		/usr/bin/iostat -x 3 2 >> $outfile
		echo "\n\n" >> $outfile
	else

		echo "\n\n\n# /usr/bin/iostat -xcC 3 2\n" >> $outfile
		echo "$log_stamp # /usr/bin/iostat -xcC 3 2 ..."
		/usr/bin/iostat -xcC 3 2 >> $outfile

		echo "\n\n\n# /usr/bin/iostat -xnE \n" >> $outfile
		echo "$log_stamp # /usr/bin/iostat -xnE ..."
		/usr/bin/iostat -xnE >> $outfile

	fi
fi


############################   NFS INFO   ################################

if [ $ALL -ne 0 ] || [ $PERF -ne 0 ] || [ $IO -ne 0 ]
then
	echo "" >> $outfile
	echo "\n$log_stamp ######  NFS INFO  ######"
	echo "## 09 ######################   NFS INFO   ################################\n\n" >> $outfile
	echo "# /usr/bin/nfsstat\n" >> $outfile
	echo "$log_stamp # /usr/bin/nfsstat ..."
	/usr/bin/nfsstat >> $outfile

	echo "\n" >> $outfile
	echo "# /usr/bin/nfsstat -m\n" >> $outfile
	echo "$log_stamp # /usr/bin/nfsstat -m ..."
	/usr/bin/nfsstat -m >> $outfile
fi


#########################   NETWORKING INFO   ############################


if [ $ALL -ne 0 ] || [ $PERF -ne 0 ] || [ $NETWORK -ne 0 ]
then
	echo "" >> $outfile
	echo "\n$log_stamp ######  NETWORKING INFO  ######"
	echo "## 10 ###################   NETWORKING INFO   ############################\n\n" >> $outfile

   	if [ -f /etc/hosts ]
   	then
		echo "# cat /etc/hosts\n" >> $outfile
		echo "$log_stamp # cat /etc/hosts ..."
		cat /etc/hosts >> $outfile
		echo "_____________________________________________________\n" >> $outfile
	fi

	echo "\n\n# /usr/sbin/ifconfig -a\n" >> $outfile
	echo "$log_stamp # /usr/sbin/ifconfig -a ..."
	/usr/sbin/ifconfig -a >> $outfile

	echo "\n\n# /usr/bin/netstat -r\n" >> $outfile
	echo "$log_stamp # /usr/bin/netstat -r ..."
	/usr/bin/netstat -r >> $outfile

	echo "\n\n\n# /usr/bin/netstat -s" >> $outfile
	echo "$log_stamp # /usr/bin/netstat -s ..."
	/usr/bin/netstat -s >> $outfile
   
	if [ -x /sbin/lltstat ]	# 	VCS LLT transport (private links)
   	then
		lltstat_file=$sysd_dir'/sysd_llt_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
		echo "\n*** VCS LLTSTAT Interconnect Packets after $SECONDS seconds **" >> $lltstat_file
		/sbin/lltstat -l >> $lltstat_file
		echo "\n*** VCS LLTSTAT Interconnect Packets after $SECONDS seconds **" >> $outfile
		/sbin/lltstat -l >> $outfile
	fi

	echo "\n\n# /usr/sbin/arp -a\n" >> $outfile
	echo "$log_stamp # /usr/sbin/arp -a ..."
	/usr/sbin/arp -a >> $outfile

#
   	if [ -f /etc/inet/ntp.server ]
   	then
		echo "\n" >> $outfile
		echo "_____________________________________________________\n" >> $outfile
		echo "# tail -30 /etc/inet/ntp.server\n" >> $outfile
		echo "$log_stamp # tail -30 /etc/inet/ntp.server ..."
		tail -30 /etc/inet/ntp.server >> $outfile
		echo "_____________________________________________________\n" >> $outfile
	fi

	if [ $LONG -ne 0 ] || [ $VERBOSE -ne 0 ]
	then
		echo "\n\n" >> $outfile
		echo "# /usr/bin/netstat -a\n" >> $outfile
		echo "$log_stamp # /usr/bin/netstat -a ..."
		/usr/bin/netstat -a >> $outfile
	fi

	echo "\n\n" >> $outfile
	echo "# /usr/bin/netstat -i\n" >> $outfile
	echo "$log_stamp # /usr/bin/netstat -i ..."
	/usr/bin/netstat -i >> $outfile


	echo "\n\n########## /etc/hostname.___ (Network Interface) files ##########\n" >> $outfile

	for i in /etc/hostname.*
	do
		echo "$log_stamp # cat $i ..."
		
		echo "\n\n\t>>>>>>>  $i  <<<<<<<<\n" >> $outfile
		cat $i >> $outfile
		echo "_____________________________________________________\n" >> $outfile
	done

   	if [ -f /etc/inet/networks ]
   	then
		echo "\n\n" >> $outfile
		echo "# cat /etc/inet/networks\n" >> $outfile
		echo "$log_stamp # cat /etc/inet/networks ..."
		cat /etc/inet/networks >> $outfile
		echo "_____________________________________________________\n" >> $outfile
	fi

	name_svc=`grep "^networks:" /etc/nsswitch.conf | /usr/bin/awk '{ print $2 }'`
	if [ $name_svc = "nis" ]
	then
		echo "" >> $outfile
		echo "# /usr/bin/ypcat networks\n" >> $outfile
		echo "$log_stamp # /usr/bin/ypcat networks ..."
		/usr/bin/ypcat networks >> $outfile

		echo "" >> $outfile
		echo "# /usr/bin/ypcat ethers\n" >> $outfile
		echo "$log_stamp # /usr/bin/ypcat ethers ..."
		/usr/bin/ypcat ethers >> $outfile
		
	elif [ $name_svc = "nisplus" ]
	then
		echo "" >> $outfile
		echo "# /usr/bin/niscat networks.org_dir\n" >> $outfile
		echo "$log_stamp # /usr/bin/niscat networks.org_dir ..."
		/usr/bin/niscat networks.org_dir >> $outfile
	fi

   	if [ -f /etc/ethers ]
   	then
		echo "" >> $outfile
		echo "# cat /etc/ethers\n" >> $outfile
		echo "$log_stamp # cat /etc/ethers ..."
		cat /etc/ethers >> $outfile
		echo "_____________________________________________________\n" >> $outfile
	fi

   	if [ -f /etc/defaultrouter ]
   	then
		echo "\n\n# cat /etc/defaultrouter\n" >> $outfile
		echo "$log_stamp # cat /etc/defaultrouter ..."
		cat /etc/defaultrouter >> $outfile
		echo "_____________________________________________________\n" >> $outfile
	else
		echo "$log_stamp  /etc/defaultrouter  NOT found, skipping.\n"
	fi

   	if [ -f /etc/notrouter ]
   	then
		echo "\n\n\n\n**** /etc/notrouter exists. ** Note: This system is NOT a router.\n" >> $outfile
		echo "$log_stamp #  NOT a router ..."
	fi

   	if [ -f /etc/netmasks ]
   	then
		echo "\n\n\n# cat /etc/netmasks\n" >> $outfile
		echo "$log_stamp # cat /etc/netmasks ..."
		cat /etc/netmasks >> $outfile
		echo "_____________________________________________________\n" >> $outfile
	else
		echo "$log_stamp  /etc/netmasks  NOT found, skipping.\n"
	fi

   	if [ -f /etc/gateways ]
   	then
		echo "\n\n\n# cat /etc/gateways\n" >> $outfile
		echo "$log_stamp # cat /etc/gateways ..."
		cat /etc/gateways >> $outfile
		echo "_____________________________________________________\n" >> $outfile
	else
		echo "$log_stamp  /etc/gateways  NOT found, skipping.\n"
	fi


   	if [ -d /etc/opt/SUNWqfetr/bin ]	## Sun Trunking 1.0.1
   	then
		echo "\n\n\n# /etc/opt/SUNWqfetr/bin/qfetr -conf\n" >> $outfile
		echo "$log_stamp # /etc/opt/SUNWqfetr/bin/qfetr -conf ..."
		/etc/opt/SUNWqfetr/bin/qfetr -conf >> $outfile

		echo "\n\n\n# /etc/opt/SUNWqfetr/bin/qfetr -debug\n" >> $outfile
		echo "$log_stamp # /etc/opt/SUNWqfetr/bin/qfetr -debug ..."
		/etc/opt/SUNWqfetr/bin/qfetr -debug >> $outfile

		echo "\n\n\n# cat /etc/opt/SUNWqfetr/bin/qfetr.sh \n" >> $outfile
		echo "$log_stamp # cat /etc/opt/SUNWqfetr/bin/qfetr.sh ..."
		cat /etc/opt/SUNWqfetr/bin/qfetr.sh >> $outfile
	fi

   	if [ -d /etc/opt/SUNWconn/bin ]		## Sun Trunking 1.2.x
   	then
		echo "\n\n\n# /etc/opt/SUNWconn/bin/nettr -conf\n" >> $outfile
		echo "$log_stamp # /etc/opt/SUNWconn/bin/nettr -conf ..."
		/etc/opt/SUNWconn/bin/nettr -conf >> $outfile

		echo "\n\n\n# /etc/opt/SUNWconn/bin/nettr -debug\n" >> $outfile
		echo "$log_stamp # /etc/opt/SUNWconn/bin/nettr -debug ..."
		/etc/opt/SUNWconn/bin/nettr -debug >> $outfile

		echo "\n\n\n# cat /etc/opt/SUNWconn/bin/nettr.sh \n" >> $outfile
		echo "$log_stamp # cat /etc/opt/SUNWconn/bin/nettr.sh ..."
		cat /etc/opt/SUNWconn/bin/nettr.sh >> $outfile
	fi
#
 	if [ -x /usr/sbin/laadm ]		## Sun S10/ Nemo Link Aggr
   	then
		echo "\n\n\n# /usr/sbin/dladm show-dev\n" >> $outfile
		echo "$log_stamp # /usr/sbin/dladm show-dev ..."
		/usr/sbin/dladm show-dev >> $outfile

		echo "\n\n# /usr/sbin/dladm show-link\n" >> $outfile
		echo "$log_stamp # /usr/sbin/dladm show-link ..."
		/usr/sbin/dladm show-link >> $outfile

		echo "\n\n# /usr/sbin/dladm show-aggr\n" >> $outfile
		echo "$log_stamp # /usr/sbin/dladm show-aggr ..."
		/usr/sbin/dladm show-aggr >> $outfile
	fi

   	if [ -x /usr/sbin/pntadm ]		## DHCP config
   	then
		echo "\n\n\n# /usr/sbin/pntadm -L\n" >> $outfile
		echo "$log_stamp # /usr/sbin/pntadm -L ..."
		/usr/sbin/pntadm -L >> $outfile
	fi

#### X.25 config capture 

   	if [ -x /opt/SUNWconn/bin/X25info ]		## X25 Links
   	then
		echo "\n\n\n# /opt/SUNWconn/bin/X25info\n" >> $outfile
		echo "$log_stamp # /opt/SUNWconn/bin/X25info ..."
		/opt/SUNWconn/bin/X25info >> $outfile
	fi


   	if [ -x /opt/SUNWconn/bin/X25stat ]		## X25 status
   	then
		echo "\n\n\n# /opt/SUNWconn/bin/X25stat\n" >> $outfile
		echo "$log_stamp # /opt/SUNWconn/bin/X25stat ..."
		/opt/SUNWconn/bin/X25stat >> $outfile
	fi

   	if [ -x /opt/SUNWconn/bin/X25file ]	## X25 link config files
   	then

		for i in `/opt/SUNWconn/bin/X25info | /usr/bin/awk '{ print $2 }'`
		do
			echo "\n# /opt/SUNWconn/bin/X25file -l $i\n" >> $outfile
			echo "$log_stamp # /opt/SUNWconn/bin/X25file -l $i ..."
			/opt/SUNWconn/bin/X25file -l $i >> $outfile

		done

	fi

	log_stamp='sys_diag:'`date '+%m%d_%H%M'`':'

	if [ $VERBOSE -ne 0 ] || [ $NETWORK -ne 0 ]
	then
		echo "\n" >> $outfile		# Kernel network driver params/stats
		echo "$log_stamp # /usr/bin/kstat -c net ..."
		echo "# /usr/bin/kstat -c net \n" >> $outfile
		/usr/bin/kstat -c net >> $outfile

		echo "\n" >> $outfile			# SNOOP on next 300 packets..
		echo "# /usr/sbin/snoop\n" >> $outfile
		echo "$log_stamp # /usr/sbin/snoop ..."

	################ Get the Network DRIVER SETTINGS ###############


		echo "\n\n# ndd -get /dev/tcp ..." >> $outfile
		echo "$log_stamp # ndd -get /dev/tcp ..."

		for i in `ndd /dev/tcp \? | grep read | grep -v \? | cut -d' ' -f1`
		do
			echo "/dev/tcp:  $i\t`/usr/sbin/ndd -get /dev/tcp $i`" >> $outfile 2>/dev/null
		done


		echo "\n\n# ndd -get /dev/udp ..." >> $outfile
		echo "$log_stamp # ndd -get /dev/udp ..."

		for i in `ndd /dev/udp \? | grep read | grep -v \? | cut -d' ' -f1`
		do
			echo "/dev/udp:  $i\t`/usr/sbin/ndd -get /dev/udp $i`" >> $outfile 2>/dev/null
		done


		echo "\n\n# ndd -get /dev/ip ..." >> $outfile
		echo "$log_stamp # ndd -get /dev/ip ..."

		for i in `ndd /dev/ip \? | grep read | grep -v \? | cut -d' ' -f1`
		do
			echo "/dev/ip:  $i\t`/usr/sbin/ndd -get /dev/ip $i`" >> $outfile 2>/dev/null
		done

# .....	Loop through all devices ........................................
#
		for i in `/usr/sbin/ifconfig -a |  grep ": " | grep "IPv4" | cut -d":" -f1`
		do
			j=${i%[0-9]}	#### device name 

			if [ $j = "lo" ]
			then
				continue
			fi

			echo "$log_stamp # ndd -set /dev/$j instance ${i#$j} ..."
			/usr/sbin/ndd -set /dev/$j instance ${i#$j} 2>/dev/null

			echo "\n\n# ndd -get /dev/$j ... instance ${i#$j}\n" >> $outfile
			echo "$log_stamp # ndd -get /dev/$j ..."

			for k in `ndd /dev/$j \? |grep read |grep -v \? |cut -d' ' -f1`
			do
				echo "/dev/$j:  $k\t`/usr/sbin/ndd -get /dev/$j $k`" >> $outfile
			done
		done
	fi
fi


############################ TTY / Modem Configs ##############################

if [ $ALL -ne 0 ] || [ $NETWORK -ne 0 ]
then
	echo "" >> $outfile
	echo "\n$log_stamp ######  TTY / MODEM INFO  ######"
	echo "## 11 ###################### TTY / MODEM INFO ################################\n\n" >> $outfile

	if [ -x /usr/sbin/pmadm ]
	then
		echo "# /usr/sbin/pmadm -l\n" >> $outfile
		echo "$log_stamp # /usr/sbin/pmadm -l ..."
		/usr/sbin/pmadm -l >> $outfile
	fi

	if [ -f /etc/remote ]
	then
		echo "\n_____________________________________________________\n" >> $outfile
		echo "# cat /etc/remote\n" >> $outfile
		echo "$log_stamp # cat /etc/remote ..."
		cat /etc/remote >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	fi

	if [ -f /etc/phones ]
	then
		echo "\n" >> $outfile
		echo "# cat /etc/phones\n" >> $outfile
		echo "$log_stamp # cat /etc/phones ..."
		cat /etc/phones >> $outfile
	fi

	if [ -f /var/adm/aculog ]
	then
		echo "\n" >> $outfile
		echo "# cat /var/adm/aculog\n" >> $outfile
		echo "$log_stamp # cat /var/adm/aculog ..."
		tail -120 /var/adm/aculog >> $outfile 2>&1
	fi
fi


#######################  USER / ACCOUNT / GROUP Info  #####################

if [ $ALL -ne 0 ]
then
	echo "\n$log_stamp ######  USER / ACCOUNT / GROUP Info  ######"
	echo "" >> $outfile
	echo "## 12 #################  USERs/ ACCOUNTs/ GROUPs  ###################\n" >> $outfile
	echo "# /usr/bin/w\n" >> $outfile
	echo "$log_stamp # w ..."
	/usr/bin/w >> $outfile

	echo "\n" >> $outfile
	echo "# /usr/bin/who -a\n" >> $outfile
	echo "$log_stamp # who -a ..."
	/usr/bin/who -a >> $outfile

   	if [ -f /etc/passwd ]
   	then
		echo "" >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
		echo "# cat /etc/passwd\n" >> $outfile
		echo "$log_stamp # cat /etc/passwd ..."
		cat /etc/passwd >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	fi
	name_svc=`grep "^passwd:" /etc/nsswitch.conf | /usr/bin/awk '{ print $2 }'`

	if [ $name_svc = "nis" ]
	then
		echo "" >> $outfile
		echo "# /usr/bin/ypcat passwd\n" >> $outfile
		echo "$log_stamp # /usr/bin/ypcat passwd ..."
		/usr/bin/ypcat passwd >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	elif [ $name_svc = "nisplus" ]
	then
		echo "" >> $outfile
		echo "# /usr/bin/niscat passwd.org_dir\n" >> $outfile
		echo "$log_stamp # /usr/bin/niscat passwd.org_dir ..."
		/usr/bin/niscat passwd.org_dir >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	fi


   	if [ -f /etc/group ]
   	then
		echo "" >> $outfile
		echo "# cat /etc/group\n" >> $outfile
		echo "$log_stamp # cat /etc/group ..."
		cat /etc/group >> $outfile
	fi
	name_svc=`grep "^group:" /etc/nsswitch.conf | /usr/bin/awk '{ print $2 }'`

	if [ $name_svc = "nis" ]
	then
		echo "" >> $outfile
		echo "# /usr/bin/ypcat group\n" >> $outfile
		echo "$log_stamp # /usr/bin/ypcat group ..."
		/usr/bin/ypcat group >> $outfile
	elif [ $name_svc = "nisplus" ]
	then
		echo "" >> $outfile
		echo "# /usr/bin/niscat groups.org_dir\n" >> $outfile
		echo "$log_stamp # /usr/bin/niscat groups.org_dir ..."
		/usr/bin/niscat groups.org_dir >> $outfile
	fi

fi


##################### SERVICES / NAMING RESOLUTION ######################


if [ $ALL -ne 0 ] || [ $CONFIG -ne 0 ] || [ $NETWORK -ne 0 ]
then
	echo "" >> $outfile
	echo "\n$log_stamp ######  SERVICES / NAMING RESOLUTION  ######"
	echo "## 13 ###################### SERVICES / NAMING RESOLUTION ##############\n\n" >> $outfile


        if [ -x /usr/bin/svcs ]		# S10 SSM : Service Management
        then
                echo "\n" >> $outfile
                echo "# /usr/bin/svcs -v\n" >> $outfile
                echo "$log_stamp # /usr/bin/svcs -v ..."
                /usr/bin/svcs -v >> $outfile
        fi


        if [ -f /etc/services ]
        then
                echo "" >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
                echo "# cat /etc/services\n" >> $outfile
                echo "$log_stamp # cat /etc/services ..."
                cat /etc/services >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
        else
                echo "$log_stamp  /etc/services NOT found, skipping.\n"
        fi

        if [ -f /etc/inetd.conf ]
        then
                echo "\n" >> $outfile
                echo "# cat /etc/inetd.conf\n" >> $outfile
                echo "$log_stamp # cat /etc/inetd.conf ..."
                cat /etc/inetd.conf >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
        else
                echo "$log_stamp  /etc/inetd.conf NOT found, skipping.\n"
        fi

        if [ -f /etc/inittab ]
        then
                echo "\n\n" >> $outfile
                echo "# cat /etc/inittab\n" >> $outfile
                echo "$log_stamp # cat /etc/inittab ..."
                cat /etc/inittab >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
        else
                echo "$log_stamp  /etc/inittab NOT found, skipping.\n"
        fi

	if [ -f /etc/nsswitch.conf ]
	then
		echo "\n\n# cat /etc/nsswitch.conf\n" >> $outfile
		echo "$log_stamp # cat /etc/nsswitch.conf ..."
		cat /etc/nsswitch.conf >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	else
		echo "$log_stamp  /etc/nsswitch.conf NOT found, skipping.\n"
	fi

	if [ -f /etc/resolv.conf ]
	then
		echo "\n" >> $outfile
		echo "# cat /etc/resolv.conf\n" >> $outfile
		echo "$log_stamp # cat /etc/resolv.conf ..."
		cat /etc/resolv.conf >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	else
		echo "$log_stamp  /etc/resolv.conf NOT found, skipping.\n"
	fi
#TJ-
	if [ -f /etc/auto_master ]
	then
		echo "\n" >> $outfile
		echo "# cat /etc/auto_master\n" >> $outfile
		echo "$log_stamp # cat /etc/auto_master ..."
		cat /etc/auto_master >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	else
		echo "\n" >> $outfile
		echo "# ypcat auto.master\n" >> $outfile
		echo "$log_stamp # ypcat auto.master ..."
		ypcat auto.master >> $outfile
		
		echo "$log_stamp  /etc/auto_master NOT found locally.\n"
	fi

	if [ -f /etc/auto_home ]
	then
		echo "\n" >> $outfile
		echo "# cat /etc/auto_home\n" >> $outfile
		echo "$log_stamp # cat /etc/auto_home ..."
		cat /etc/auto_home >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	else
		echo "$log_stamp  /etc/auto_home NOT found locally, skipping.\n"
	fi

	if [ -f /etc/named.conf ]
	then
		echo "\n" >> $outfile
		echo "# cat /etc/named.conf\n" >> $outfile
		echo "$log_stamp # cat /etc/named.conf ..."
		cat /etc/named.conf >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	else
		echo "$log_stamp  /etc/named.conf NOT found, skipping.\n"
	fi

	if [ -f /etc/named.boot ]
	then
		echo "\n" >> $outfile
		echo "# cat /etc/named.boot\n" >> $outfile
		echo "$log_stamp # cat /etc/named.boot ..."
		cat /etc/named.boot >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	else
		echo "$log_stamp  /etc/named.boot NOT found, skipping.\n"
	fi

	echo "\n" >> $outfile
	echo "# /usr/bin/ypwhich\n" >> $outfile
	echo "$log_stamp # /usr/bin/ypwhich ..."
	/usr/bin/ypwhich >> $outfile

	if [ $? -eq 0 ]
	then
		echo "\n\n\n" >> $outfile
		echo "# /usr/bin/ypwhich -m\n" >> $outfile
		echo "$log_stamp # /usr/bin/ypwhich -m ..."
		/usr/bin/ypwhich -m >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	else
		no_nis=1
	fi

	echo "" >> $outfile
	echo "# /usr/bin/nisdefaults\n" >> $outfile
	echo "$log_stamp # /usr/bin/nisdefaults ..."
	/usr/bin/nisdefaults >> $outfile

	nisd=`ps -ef | grep nisd | wc -l`

	if [ $nisd -gt 1 ]
	then
		echo "" >> $outfile
		echo "# /usr/bin/nisls -l\n" >> $outfile
		echo "$log_stamp # /usr/bin/nisls -l ..."
		/usr/bin/nisls -l >> $outfile

		echo "" >> $outfile
		echo "# /usr/bin/niscat -o org_dir\n" >> $outfile
		echo "$log_stamp # /usr/bin/niscat -o org_dir..."
		/usr/bin/niscat -o org_dir >> $outfile

		echo "" >> $outfile
		echo "# /usr/bin/nislog\n" >> $outfile
		echo "$log_stamp # /usr/bin/nislog ..."
		/usr/bin/nislog >> $outfile

		echo "" >> $outfile
		echo "# /usr/lib/nis/nisstat\n" >> $outfile
		echo "$log_stamp # /usr/lib/nis/nisstat ..."
		/usr/lib/nis/nisstat >> $outfile
	fi

	name_svc1=`grep "^hosts:" /etc/nsswitch.conf | /usr/bin/awk '{ print $2 }'`
	name_svc2=`grep "^hosts:" /etc/nsswitch.conf | /usr/bin/awk '{ print $3 }'`

#	if [ $name_svc1 = "nis" ] || ( [ $name_svc1 = "xfn" ] && [ $name_svc2 = "nis" ] )
#	if [ $name_svc1 = "nis" ] || [ $name_svc2 = "nis" ]

	if [ $no_nis -eq 0 ]
	then
		echo "" >> $outfile
		echo "# /usr/bin/ypcat hosts\n" >> $outfile
		echo "$log_stamp # /usr/bin/ypcat hosts ..."
		/usr/bin/ypcat hosts >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	fi

#	elif [ $name_svc1 = "nisplus" ] || ( [ $name_svc1 = "xfn" ] && [ $name_svc2 = "nisplus" ] )
#	if [ $name_svc1 = "nisplus" ] || [ $name_svc2 = "nisplus" ]

	if [ $nisd -gt 1 ]
	then
		echo "" >> $outfile
		echo "# /usr/bin/niscat hosts.org_dir\n" >> $outfile
		echo "$log_stamp # /usr/bin/niscat hosts.org_dir ..."
		/usr/bin/niscat hosts.org_dir >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	fi

#	if [ $name_svc1 = "dns" ] || [ $name_svc2 = "dns" ]
#	then
#!!TJ ??	
#		echo "" >> $outfile
#		echo "# cat ??db.cache\n" >> $outfile
#		echo "$log_stamp # cat ??db.cache ..."
#		cat ??db.cache >> $outfile
#	
#		echo "" >> $outfile
#		echo "# cat ?? \n" >> $outfile
#		echo "$log_stamp # cat ?? ..."
#		cat ?? >> $outfile
#
#
#		nslookup -all ???????????????
#	fi

fi


##################### SECURITY+ CONFIG FILES  ######################


if [ $ALL -ne 0 ] || [ $CONFIG -ne 0 ] || [ $NETWORK -ne 0 ]
then
        echo "" >> $outfile
	echo "\n$log_stamp ######  SECURITY / CONFIG FILES  ######"
        echo "## 14 ################  SECURITY+ / SYSTEM CONFIG FILES  ###############\n\n" >> $outfile

        if [ -f /etc/hosts.equiv ]
        then
                echo "\nAn /etc/hosts.equiv file DOES exist.\n" >> $outfile
                echo "# cat /etc/hosts.equiv\n" >> $outfile
                echo "$log_stamp # cat /etc/hosts.equiv ..."
                cat /etc/hosts.equiv >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
        else
                echo "\nNo /etc/hosts.equiv file exists.\n" >> $outfile
                echo "$log_stamp  /etc/hosts.equiv NOT found, skipping.\n"
        fi

        if [ -f /.rhosts ]
        then
                echo "\n\nAn /.rhosts file DOES exist.\n" >> $outfile
                echo "# cat /.rhosts\n" >> $outfile
                echo "$log_stamp # cat /.rhosts ..."
                cat /.rhosts >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
        else
                echo "\n\nNo /.rhosts file exists.\n" >> $outfile
                echo "$log_stamp  /.rhosts NOT found, skipping.\n"
        fi

        if [ -f /etc/shadow ]
        then
                echo "\n\n-------------------\n\n" >> $outfile
                echo "An /etc/shadow file DOES exist." >> $outfile
        else
                echo "$log_stamp  /etc/shadow NOT found !!\n"
                echo "\n\n\n" >> $outfile
                echo "!! NO /etc/shadow file exists !!" >> $outfile
        fi

        if [ -f /etc/syslog.conf ]
        then
                echo "\n" >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
                echo "# cat /etc/syslog.conf\n" >> $outfile
                echo "$log_stamp # cat /etc/syslog.conf ..."
                cat /etc/syslog.conf >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
#        else
#                echo "$log_stamp  /etc/syslog.conf NOT found, skipping.\n"
        fi

        if [ -f /etc/default/login ]
        then
                echo "\n" >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
                echo "# cat /etc/default/login\n" >> $outfile
                echo "$log_stamp # cat /etc/default/login ..."
                cat /etc/default/login >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
#        else
#                echo "$log_stamp  /etc/default/login NOT found, skipping.\n"
        fi

	if [ -f /var/adm/sulog ]
        then
                echo "\n" >> $outfile
                echo "# tail -250 /var/adm/sulog\n" >> $outfile
                echo "$log_stamp # tail -250 /var/adm/sulog ..."
                tail -250 /var/adm/sulog >> $outfile 2>&1
#        else
#                echo "$log_stamp  /var/adm/sulog NOT found, skipping.\n"
        fi

	if [ -f /usr/bin/last ]
        then
                echo "\n" >> $outfile
                echo "# /usr/bin/last reboot\n" >> $outfile
                echo "$log_stamp # /usr/bin/last reboot ..."
                /usr/bin/last reboot >> $outfile
        
                echo "\n" >> $outfile
                echo "# /usr/bin/last -200\n" >> $outfile
                echo "$log_stamp # /usr/bin/last -200  ..."
                /usr/bin/last -200 >> $outfile
#       else
#                echo "$log_stamp  /usr/bin/last  NOT found, skipping.\n"
        fi

	if [ -x /usr/sbin/ipf ]		## Solaris 10 IP Filtering
        then
                echo "\n" >> $outfile
                echo "# /usr/sbin/ipf -T list\n" >> $outfile
                echo "$log_stamp # /usr/sbin/ipf -T list ..."
                /usr/sbin/ipf -T list >> $outfile
        fi
	
	if [ -f /etc/ipf/ipf.conf ]
	then
                echo "\n" >> $outfile
                echo "# cat /etc/ipf/ipf.conf\n" >> $outfile
                echo "$log_stamp # cat /etc/ipf/ipf.conf  ..."
                cat /etc/ipf/ipf.conf >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile

                echo "\n\n# cat /etc/ipf/pfil.ap\n" >> $outfile
                echo "$log_stamp # cat /etc/ipf/pfil.ap ..."
		echo "\n_____________________________________________________\n" >> $outfile
                cat /etc/ipf/pfil.ap >> $outfile
	fi

	if [ -x /usr/sbin/ipnat ]		## Solaris 10 IP NAT
        then
                echo "\n" >> $outfile
                echo "# /usr/sbin/ipnat -vls\n" >> $outfile
                echo "$log_stamp # /usr/sbin/ipnat -vls ..."
                /usr/sbin/ipnat -vls >> $outfile
        fi
	
fi

########################  CLUSTERING INFO  ################################


if [ $ALL -ne 0 ] || [ $HA -ne 0 ] || [ $CONFIG -ne 0 ]
then

   echo "\n$log_stamp ######  HA/ CLUSTERING INFO  ######"
   echo "" >> $outfile
   echo "## 15 ##################  HA / CLUSTERING INFO  ##########################\n" >> $outfile

   if [ -f /opt/SUNWcluster/bin/hastat ]	# SC2.2
   then
	echo "# /opt/SUNWcluster/bin/hastat\n" >> $outfile
	echo "$log_stamp # /opt/SUNWcluster/bin/hastat ..."
	/opt/SUNWcluster/bin/hastat >> $outfile
   fi

   if [ -f /opt/SUNWcluster/bin/scconf ]	# SC2.2
   then
	echo "\n" >> $outfile
	echo "# /opt/SUNWcluster/bin/scconf `cat /etc/opt/SUNWcluster/conf/default_clustername` -p\n" >> $outfile
	echo "$log_stamp # /opt/SUNWcluster/bin/scconf `cat /etc/opt/SUNWcluster/conf/default_clustername` -p ..."
	/opt/SUNWcluster/bin/scconf `cat /etc/opt/SUNWcluster/conf/default_clustername` -p >> $outfile
   fi

   if [ -x /opt/SUNWcluster/bin/pnmstat ]	# SC2.2
   then
	echo "\n# /opt/SUNWcluster/bin/pnmstat\n" >> $outfile
	echo "$log_stamp # /opt/SUNWcluster/bin/pnmstat -l ..."
	/opt/SUNWcluster/bin/pnmstat -l >> $outfile
   fi

   if [ -x /usr/cluster/bin/scconf ]	# SC3.x
   then
	echo "\n" >> $outfile
	echo "# /usr/cluster/bin/scconf -p -v\n" >> $outfile
	echo "$log_stamp # /usr/cluster/bin/scconf -p -v ..."
	/usr/cluster/bin/scconf -p -v >> $outfile
   fi

   if [ -x /usr/cluster/bin/scstat ]	# SC3.x
   then
	echo "\n" >> $outfile
	echo "# /usr/cluster/bin/scstat\n" >> $outfile
	echo "$log_stamp # /usr/cluster/bin/scstat ..."
	/usr/cluster/bin/scstat >> $outfile
   fi

   if [ -x /usr/cluster/bin/pnmstat ]	# SC3.x
   then
	echo "\n" >> $outfile
	echo "# /usr/cluster/bin/pnmstat -l\n" >> $outfile
	echo "$log_stamp # /usr/cluster/bin/pnmstat -l ..."
	/usr/cluster/bin/pnmstat -l >> $outfile
   fi

   if [ -x /usr/cluster/bin/scrgadm ]	# SC3.x
   then
	echo "\n" >> $outfile
	echo "# /usr/cluster/bin/scrgadm -p\n" >> $outfile
	echo "$log_stamp # /usr/cluster/bin/scrgadm -p ..."
	/usr/cluster/bin/scrgadm -p >> $outfile
   fi

   if [ -x /usr/cluster/bin/scrgadm ]	# SC3.x
   then
	echo "\n" >> $outfile
	echo "# /usr/cluster/bin/scrgadm -p -v\n" >> $outfile
	echo "$log_stamp # /usr/cluster/bin/scrgadm -p -v ..."
	/usr/cluster/bin/scrgadm -p -v >> $outfile
   fi

#   if[ $HA -ne 0 ] || [ [ $VERBOSE -ne 0 ] && [ -f /usr/cluster/bin/scrgadm ] ]
   if [ -f /usr/cluster/bin/scrgadm ]
   then
	echo "\n" >> $outfile
	echo "# /usr/cluster/bin/scrgadm -p -vv\n" >> $outfile
	echo "$log_stamp # /usr/cluster/bin/scrgadm -p -vv ..."
	/usr/cluster/bin/scrgadm -p -vv >> $outfile

	#######  SC3 Data Svc Agent listings  ########

     print_hdr=1

     for i in `scrgadm -p -vv | grep "base directory:" | /usr/bin/awk '{ print $6 }'`
     do

	if [ $print_hdr -eq 1 ]
	then
		echo "\n$log_stamp ## Probing SC3 DATA SVC Agent FILES ..."
		echo "##############  Sun Cluster 3 DataSvc Agent Files ###########\n\n" >> $outfile
		print_hdr=0
	fi

	for j in $i/*	##### Go through the agent files per dir
	do
		file $j | grep -i "script"
		ret=$?

		if [ $ret -ne 0 ]	## not a shell script, skip
		then
			continue
		fi

		echo "" >> $outfile

		echo "\n\t>>>>>>>  $j  <<<<<<<<\n" >> $outfile
		cat $j >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	done

     done

   fi

# 	Veritas VCS CONFIG DATA ............

   if [ -x /opt/VRTSvcs/bin/hastatus ]	# VCS hastatus cluster summary
   then
	echo "\n" >> $outfile
   	echo "\n$log_stamp ######  Veritas VCS Clustering INFO  ######"
	echo "# /opt/VRTSvcs/bin/hastatus -sum\n" >> $outfile
	echo "$log_stamp # /opt/VRTSvcs/bin/hastatus -sum ..."
	/opt/VRTSvcs/bin/hastatus -sum >> $outfile
   fi

   if [ -x /opt/VRTS/bin/hares ]	# VCS hares cluster status
   then
	echo "\n" >> $outfile
   	echo "\n$log_stamp ######  Veritas VCS Clustering INFO  ######"
	echo "# /opt/VRTS/bin/hares -state\n" >> $outfile
	echo "$log_stamp # /opt/VRTS/bin/hares -state ..."
	/opt/VRTS/bin/hares -state >> $outfile
   fi


   if [ -x /sbin/gabconfig ]	# VCS/CRS Global membership Atomic Broadcast: GAB
   then
	echo "\n" >> $outfile
	echo "# /sbin/gabconfig -a\n" >> $outfile
	echo "$log_stamp # /sbin/gabconfig -a ..."
	/sbin/gabconfig -a >> $outfile
   fi

   if [ -f /etc/llttab ]	# VCS node/host entry table
   then
	echo "\n" >> $outfile
	echo "# cat /etc/llttab\n" >> $outfile
	echo "$log_stamp # cat /etc/llttab ..."
	cat /etc/llttab >> $outfile
   fi

   if [ -f /etc/llhosts ]	# VCS LLT host interconnects 
   then
	echo "\n" >> $outfile
	echo "# cat /etc/llhosts\n" >> $outfile
	echo "$log_stamp # cat /etc/llhosts ..."
	cat /etc/llhosts >> $outfile
   fi

   if [ -x /sbin/lltstat ]	# 	VCS LLT transport (private links)
   then
	echo "# /sbin/lltstat -n\n" >> $outfile
	echo "$log_stamp # /sbin/lltstat -n ..."
	/sbin/lltstat -n >> $outfile

	echo "# /sbin/lltstat -c\n" >> $outfile
	echo "$log_stamp # /sbin/lltstat -c ..."
	/sbin/lltstat -c >> $outfile

	echo "# /sbin/lltstat -l\n" >> $outfile
	echo "$log_stamp # /sbin/lltstat -l ..."
	/sbin/lltstat -l >> $outfile
   fi

   if [ -f /etc/VRTSvcs/conf/config/main.cf ]	# VCS main config file
   then
	echo "" >> $outfile
	echo "\n_____________________________________________________\n" >> $outfile
	echo "# cat /etc/VRTSvcs/conf/config/main.cf\n" >> $outfile
	echo "$log_stamp # cat /etc/VRTSvcs/conf/config/main.cf ..."
	cat /etc/VRTSvcs/conf/config/main.cf >> $outfile
	echo "\n_____________________________________________________\n" >> $outfile
   fi

fi


########################  N1 CONFIGURATION INFO  ###############################

if [ $ALL -ne 0 ] || [ $N1 -ne 0 ] || [ $CONFIG -ne 0 ]
then

   echo "\n$log_stamp ######  SUN N1 Configuration INFO  ######"
   echo "" >> $outfile
   echo "## 16 ##################  Sun N1 Config INFO  ################################\n" >> $outfile


   if [ -f /opt/terraspring/sbin/farm ]		# N1 - list farms
   then

      echo "" >> $outfile
      echo "# /opt/terraspring/sbin/farm -l\n" >> $outfile
      echo "$log_stamp # /opt/terraspring/sbin/farm -l ..."
      /opt/terraspring/sbin/farm -l >> $outfile


      for i in `/opt/terraspring/sbin/farm -l | grep -v "FARM_ID" | /usr/bin/awk '{ print $1 }'`
      do

   	if [ -f /opt/terraspring/sbin/lr ]	# N1 - list farm resources
   	then
		echo "" >> $outfile

		echo "\n\t>>>>>>>  FARM_ID=$i  <<<<<<<<\n" >> $outfile
		echo "# /opt/terraspring/sbin/lr -l $i\n" >> $outfile
		echo "$log_stamp # /opt/terraspring/sbin/lr -l $i..."
		/opt/terraspring/sbin/lr -l $i >> $outfile
   	fi

      done

   fi


   if [ -f /opt/terraspring/sbin/device ] && [ $VERBOSE -ne 1 ]
   then
	echo "" >> $outfile
	echo "# /opt/terraspring/sbin/device -l\n" >> $outfile
	echo "$log_stamp # /opt/terraspring/sbin/device -l ..."
	/opt/terraspring/sbin/device -l >> $outfile

   elif [ -f /opt/terraspring/sbin/device ] && [ $VERBOSE -eq 1 ]
   then
	echo "" >> $outfile
	echo "# /opt/terraspring/sbin/device -lv\n" >> $outfile
	echo "$log_stamp # /opt/terraspring/sbin/device -lv ..."
	/opt/terraspring/sbin/device -lv >> $outfile

#   else
#	echo "\n/opt/terraspring/sbin/device NOT found, skipping.\n" >> $outfile
#	echo "$log_stamp  /opt/terraspring/sbin/device NOT found, skipping.\n"
   fi


   if [ -f /opt/terraspring/sbin/image ] && [ $VERBOSE -ne 1 ]
   then
	echo "" >> $outfile
	echo "# /opt/terraspring/sbin/image -lv\n" >> $outfile
	echo "$log_stamp # /opt/terraspring/sbin/image -lv ..."
	/opt/terraspring/sbin/image -lv >> $outfile

   elif [ -f /opt/terraspring/sbin/image ] && [ $VERBOSE -eq 1 ]
   then
	echo "" >> $outfile
	echo "# /opt/terraspring/sbin/image -lV\n" >> $outfile
	echo "$log_stamp # /opt/terraspring/sbin/image -lV ..."
	/opt/terraspring/sbin/image -lV >> $outfile

#  else
#	echo "\n/opt/terraspring/sbin/image NOT found, skipping.\n" >> $outfile
#	echo "$log_stamp  /opt/terraspring/sbin/image NOT found, skipping.\n"
   fi


   if [ -f /opt/terraspring/sbin/subnet ]	# N1 - list subnets
   then
	echo "" >> $outfile
	echo "# /opt/terraspring/sbin/subnet -l\n" >> $outfile
	echo "$log_stamp # /opt/terraspring/sbin/subnet -l ..."
	/opt/terraspring/sbin/subnet -l >> $outfile
   fi


   if [ -f /opt/terraspring/sbin/vlan ]		# N1 - list vlans
   then
	echo "" >> $outfile
	echo "# /opt/terraspring/sbin/vlan -l\n" >> $outfile
	echo "$log_stamp # /opt/terraspring/sbin/vlan -l ..."
	/opt/terraspring/sbin/vlan -l >> $outfile
   fi


   if [ -f /opt/terraspring/sbin/vlanconfig ]	# N1
   then

	for i in `/opt/terraspring/sbin/device -l | grep -v "DEVICE_ID" | /usr/bin/awk '{ print $1 }'`
   	do
		echo "" >> $outfile
		echo "# /opt/terraspring/sbin/vlanconfig -lV $i\n" >> $outfile
		echo "$log_stamp # /opt/terraspring/sbin/vlanconfig -lV $i..."
		/opt/terraspring/sbin/vlanconfig -lV $i >> $outfile
	done
   fi

   if [ -f /opt/terraspring/sbin/image ] && [ $VERBOSE -eq 1 ]
   then

	for i in `/opt/terraspring/sbin/device -l | grep -v "DEVICE_ID" | /usr/bin/awk '{ print $1 }'`
   	do
		echo "" >> $outfile
		echo "# /opt/terraspring/sbin/showconf $i\n" >> $outfile
		echo "$log_stamp # /opt/terraspring/sbin/showconf $i..."
		/opt/terraspring/sbin/showconf $i >> $outfile
	done
   fi


   if [ -f /opt/terraspring/sbin/request ]	# N1
   then
	echo "" >> $outfile
	echo "# /opt/terraspring/sbin/request -l\n" >> $outfile
	echo "$log_stamp # /opt/terraspring/sbin/request -l ..."
	/opt/terraspring/sbin/request -l >> $outfile
   fi


   if [ -f /opt/terraspring/sbin/aps ]	# N1
   then
	echo "" >> $outfile
	echo "# /opt/terraspring/sbin/aps\n" >> $outfile
	echo "$log_stamp # /opt/terraspring/sbin/aps ..."
	/opt/terraspring/sbin/aps >> $outfile
   fi


   if [ -f /opt/terraspring/sbin/wmld ] && [ $VERBOSE -eq 1 ]
   then
	echo "" >> $outfile
	echo "# /opt/terraspring/sbin/wmld -c\n" >> $outfile
	echo "$log_stamp # /opt/terraspring/sbin/wmld -c ..."
	/opt/terraspring/sbin/wmld -c >> $outfile
   fi


   if [ -f /var/adm/tspr.debug ] && [ $VERBOSE -ne 1 ]
   then
	echo "\n" >> $outfile
	echo "\n_____________________________________________________\n" >> $outfile
	echo "# tail -120 /var/adm/tspr.debug\n" >> $outfile
	echo "$log_stamp # tail -120 /var/adm/tspr.debug ..."
	tail -120 /var/adm/tspr.debug >> $outfile 2>&1

   elif [ -f /var/adm/tspr.debug ] && [ $VERBOSE -eq 1 ]
   then
	echo "\n" >> $outfile
	echo "\n_____________________________________________________\n" >> $outfile
	echo "# tail -400 /var/adm/tspr.debug\n" >> $outfile
	echo "$log_stamp # tail -400 /var/adm/tspr.debug ..."
	tail -400 /var/adm/tspr.debug >> $outfile 2>&1
	echo "\n_____________________________________________________\n" >> $outfile
   fi


   if [ -f /etc/opt/terraspring/tspr.properties ] && [ $VERBOSE -eq 1 ]
   then
	echo "\n" >> $outfile
	echo "# cat /etc/etc/opt/terraspring/tspr.properties\n" >> $outfile
	echo "$log_stamp # cat /etc/opt/terraspring/tspr.properties ..."
	cat /etc/opt/terraspring/tspr.properties >> $outfile
   fi

fi


###################  APPLICATION / ORACLE CONFIG FILES  ######################



if [ $ALL -ne 0 ] || [ $ORACLE -ne 0 ] || [ $APPS -ne 0 ]
then

   echo "" >> $outfile
   echo "\n$log_stamp ######  APPLICATION / ORACLE CONFIG FILES  ######"
   echo "## 17 #############  APPLICATION / ORACLE Config Files  ##############\n\n" >> $outfile

if [ ${ORACLE_BASE:-UNSET} = "UNSET" ]	## if not set, then set to default
then
	if [ -d /opt/oracle ]	## if not set, then set to default
	then
		ORACLE_BASE="/opt/oracle/"
	fi
fi

if [ ${ORACLE_HOME:-UNSET} = "UNSET" ]	
then
	if [ -d /opt/oracle/product/10g_dbs ]	## if not set, then set to default
	then
		ORACLE_HOME="/opt/oracle/product/10g_dbs"
	fi
fi

if [ ${ORA_CRS_HOME:-UNSET} = "UNSET" ]
then
	if [ -d /opt/oracle/product/10g_crs ]	## if not set, then set to default
	then
		ORA_CRS_HOME="/opt/oracle/product/10g_crs"
	fi
fi


   if [ -f /var/opt/oracle/oratab ]
   then
	echo "# cat /var/opt/oracle/oratab\n" >> $outfile
	cat /var/opt/oracle/oratab >> $outfile

	ora_dir=`grep "^*:*" /var/opt/oracle/oratab | cut -d":" -f2`

	if [ -d $ora_dir ]
	then
		for i in $ora_dir/*/*/*.ora
		do
			echo "\n\t>>>>>>>  $i  <<<<<<<<\n" >> $outfile
			cat $i >> $outfile
			echo "\n_____________________________________________________\n" >> $outfile
			echo "\n" >> $outfile
		done

		for i in $ora_dir/*/*.ora
		do
			echo "\n\t>>>>>>>  $i  <<<<<<<<\n" >> $outfile
			cat $i >> $outfile
			echo "\n_____________________________________________________\n" >> $outfile
			echo "\n" >> $outfile
		done
	fi

   fi

   if [ -f /var/opt/oracle/tnsnames.ora ]
   then
	echo "\n" >> $outfile
	echo "# cat /var/opt/oracle/tnsnames.ora\n" >> $outfile
	cat /var/opt/oracle/tnsnames.ora >> $outfile
	echo "\n_____________________________________________________\n" >> $outfile
   fi


   if [ -f /var/opt/oracle/listener.ora ]
   then
	echo "\n" >> $outfile
	echo "# cat /var/opt/oracle/listener.ora\n" >> $outfile
	cat /var/opt/oracle/listener.ora >> $outfile
	echo "\n_____________________________________________________\n" >> $outfile
   fi


   if [ -f /var/opt/oracle/sqlnet.ora ]
   then
	echo "\n" >> $outfile
	echo "# cat /var/opt/oracle/sqlnet.ora\n" >> $outfile
	cat /var/opt/oracle/sqlnet.ora >> $outfile
	echo "\n_____________________________________________________\n" >> $outfile
   fi


   if [ -f /oracle/product/*/dbs/init.ora ]
   then
	echo "\n" >> $outfile
	echo "# cat /oracle/product/*/dbs/init.ora\n" >> $outfile
	cat /oracle/product/*/dbs/init.ora >> $outfile
	echo "\n_____________________________________________________\n" >> $outfile
   fi


   if [ -f /oracle/product/*/dbs/init?*.ora ]
   then
	echo "\n" >> $outfile
	echo "# cat /oracle/product/*/dbs/init?*.ora\n" >> $outfile
#	cat /oracle/product/*/dbs/init?*.ora >> $outfile

	for i in /oracle/product/*/dbs/init?*.ora
	do
		echo "\n\t>>>>>>>  $i  <<<<<<<<\n" >> $outfile
		cat $i >> $outfile
		echo "\n" >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
	done

   else
   	if [ -f /*/app/oracle/product/*/dbs/init?*.ora ]
   	then
		echo "\n" >> $outfile
		echo "# cat /*/app/oracle/product/*/dbs/init?*.ora\n" >> $outfile
	
		for i in /*/app/oracle/product/*/dbs/init?*.ora
		do
			echo "\n\t>>>>>>>  $i  <<<<<<<<\n" >> $outfile
			cat $i >> $outfile
			echo "\n_____________________________________________________\n" >> $outfile
			echo "\n" >> $outfile
		done
	fi
   fi

   if [ -x $ORA_CRS_HOME/bin/crs_stat ]
   then
	echo "\n" >> $outfile
	echo "# $ORA_CRS_HOME/bin/crs_stat ...\n"
	echo "# $ORA_CRS_HOME/bin/crs_stat\n" >> $outfile
	$ORA_CRS_HOME/bin/crs_stat >> $outfile
   fi
	

######## SYMON / SUNMC (Sun Mgmt Center) .cfg files #########

   if [ $VERBOSE ] && [ -d /var/opt/SUNWsymon/cfg/ ]	
   then
	for i in /var/opt/SUNWsymon/cfg/*.cfg
	do
   		echo "" >> $outfile
   		echo "\n$log_stamp ##  SunMC Config Files ..."
   		echo "############  SUN Management Center Config Files  ###########\n\n" >> $outfile
		echo "\n\t>>>>>>>  $i  <<<<<<<<\n" >> $outfile
		cat $i >> $outfile
		echo "\n_____________________________________________________\n" >> $outfile
		echo "\n" >> $outfile
	done
   fi

fi


##########################  PACKAGE / PATCH INFO  #########################

if [ $ALL -ne 0 ] || [ $CONFIG -ne 0 ] || [ $PATCHMGT -ne 0 ]
then
	echo "" >> $outfile
	echo "\n$log_stamp ######  PACKAGE INFO / SOLARIS REGISTRY  ######"
	echo "## 18 ################  INSTALLED PACKAGES / SOLARIS REGISTRY ################\n\n" >> $outfile

	if (( $Solaris_Rev > 8 )) && [ -x /usr/bin/prodreg ]	# Solaris Product Registry
	then
		echo "# /usr/bin/prodreg browse\n" >> $outfile
		echo "$log_stamp # /usr/bin/prodreg browse ..."
		/usr/bin/prodreg browse >> $outfile
	fi

	echo "\n\n# /usr/bin/pkginfo\n" >> $outfile
	echo "$log_stamp # /usr/bin/pkginfo ..."
	/usr/bin/pkginfo >> $outfile

	if [ $LONG -ne 0 ]
	then
		echo "\n\n\n\n" >> $outfile
		echo "# /usr/bin/pkginfo -l  ***** STORED in : $pkginfo_file\n" >> $outfile
		echo "$log_stamp # /usr/bin/pkginfo -l ..."
		/usr/bin/pkginfo  -l >> $pkginfo_file
	fi

	echo "" >> $outfile
	echo "\n$log_stamp ######  PATCH INFO  ######"
	echo "## 19 ####################  INSTALLED PATCHES / INFO #####################\n\n" >> $outfile

	echo "# /usr/bin/showrev -p\n" >> $outfile
	echo "$log_stamp # /usr/bin/showrev -p ..."
	/usr/bin/showrev -p >> $outfile


	if [ -d $PATCH_UTILITY_DIR ]
	then
		echo "\n# $PATCH_UTILITY_CMD\n" >> $outfile
		echo "$log_stamp # $PATCH_UTILITY_CMD ..."
		$PATCH_UTILITY_DIR/$PATCH_UTILITY_CMD >> $outfile

	elif [ -x /opt/patchdiag*/patchdiag ]
	then
		echo "\n" >> $outfile
		echo "# patchdiag -l\n" >> $outfile
		echo "$log_stamp # patchdiag -l ..."
		/opt/patchdiag*/patchdiag -l >> $outfile

	elif [ -x /usr/sadm/bin/smpatch ]
	then
		echo "\n" >> $outfile
		echo "$log_stamp # /usr/sadm/bin/smpatch analyze  NOT RUN, passwd required...."
#		echo "# /usr/sadm/bin/smpatch analyze\n" >> $outfile
#		echo "$log_stamp # /usr/sadm/bin/smpatch analyze ..."
#		/usr/sadm/bin/smpatch analyze >> $outfile
	else
		echo "\n\n### NOTE: NO PATCH DIAGNOSTIC UTILITY found, skipping... ###\n\n" >> $outfile
		echo "$log_stamp  * NO Patch Diagnostic Utility found, skipping.\n"
	fi

fi



#######################  CRONTAB FILE LISTINGS  ######################


if [ $ALL -ne 0 ] || [ $CONFIG -ne 0 ]
then

	print_hdr=1

	for i in /var/spool/cron/crontabs/*
	do
		echo "" >> $outfile

		if [ $print_hdr -eq 1 ]
		then
			echo "\n$log_stamp ######  CRONTAB FILE LISTINGS  ######"
			echo "## 20 #################  CRONTAB FILE LISTINGS  ######################\n\n" >> $outfile
			print_hdr=0
		fi

		echo "\n\t>>>>>>>  $i  <<<<<<<<\n" >> $outfile
		cat $i >> $outfile
	done


fi


########################  FMD / SYSTEM MESSAGES ...  #########################


if [ $ALL -ne 0 ] || [ $LONG -ne 0 ] || [ $PERF -ne 0 ]
then
	echo "" >> $outfile
	echo "\n$log_stamp ######  FMD / SYSTEM MESSAGE/LOG FILES  ######"
	echo "## 21 #################  FMD / SYSTEM MESSAGE / LOG FILES  ######################\n\n" >> $outfile



	if [ -x /usr/sbin/fmadm ]	# S10 FMD...
	then
		echo "\n\n# /usr/sbin/fmadm config\n" >> $outfile
		echo "$log_stamp # /usr/sbin/fmadm config ..."
		/usr/sbin/fmadm config >> $outfile
	fi

	if [ -x /usr/sbin/fmdump ]	# S10 FMD...
	then
		echo "# /usr/sbin/fmdump\n" >> $outfile
		echo "$log_stamp # /usr/sbin/fmdump ..."
		/usr/sbin/fmdump >> $outfile
	fi

	if [ -x /usr/sbin/fmstat ]	# S10 FMD...
	then
		echo "\n\n# /usr/sbin/fmstat\n" >> $outfile
		echo "$log_stamp # /usr/sbin/fmstat ..."
		/usr/sbin/fmstat >> $outfile
	fi


	if [ $LONG -ne 0 ] || [ $PERF -ne 0 ]
	then
		echo "\n\n# tail -250 /var/adm/messages\n" >> $outfile
		echo "$log_stamp # tail -250 /var/adm/messages ..."
		tail -250 /var/adm/messages >> $outfile

		echo "\n\n######## [/var/adm/messages] *ERRORS* #########:\n" >> $analysis_efile
		grep -i -n error /var/adm/messages >> $analysis_efile
		grep -i -n failure /var/adm/messages >> $analysis_wfile
		
		echo "\n\n######## [/var/adm/messages] *WARNINGS* #######:\n" >> $analysis_wfile
		grep -i -n warning /var/adm/messages >> $analysis_wfile
		grep -i -n not /var/adm/messages >> $analysis_wfile


		echo "\n" >> $outfile
		echo "# /usr/bin/dmesg | tail -250\n" >> $outfile
		echo "$log_stamp # /usr/bin/dmesg ..."
		/usr/bin/dmesg | tail -250 >> $outfile

		echo "\n\n######## [/usr/bin/dmesg] *ERRORS* #########:\n" >> $analysis_efile
		/usr/bin/dmesg | grep -i -n error >> $analysis_efile
		/usr/bin/dmesg | grep -i -n failure >> $analysis_efile
		
		echo "\n\n######## [/usr/bin/dmesg] *WARNINGS* #######:\n" >> $analysis_wfile
		/usr/bin/dmesg | grep -i -n warning >> $analysis_wfile
		/usr/bin/dmesg | grep -i -n not >> $analysis_wfile


        	if [ -d /opt/SUNWssp ]
		then
			echo "\n" >> $outfile
			echo "# tail -250 $SSPOPT/adm/messages\n" >> $outfile
			echo "$log_stamp # tail -250 $SSPOPT/adm/messages ..."
			tail -250 $SSPOPT/adm/messages >> $outfile

			for i in /var/opt/SUNWssp/adm/*/messages
			do
				echo "\n\t>>>> tail -250 $i <<<<\n" >> $outfile
				tail -250 $i >> $outfile
				echo "\n" >> $outfile
			done
		fi

        	if [ -d /opt/SUNWSMS ]
		then
			echo "\n" >> $outfile
			echo "# /opt/SUNWSMS/bin/showlogs | tail -500\n" >> $outfile
			echo "$log_stamp # /opt/SUNWSMS/bin/showlogs | tail -500 ..."
			/opt/SUNWSMS/bin/showlogs | tail -500 >> $outfile

			echo "\n\n######## [/opt/SUNWSMS/bin/showlogs] *ERRORS* #########:\n" >> $analysis_efile
			/opt/SUNWSMS/bin/showlogs | grep -i -n error >> $analysis_efile
			
			echo "\n\n######## [/opt/SUNWSMS/bin/showlogs] *WARNINGS* #######:\n" >> $analysis_wfile
			/opt/SUNWSMS/bin/showlogs | grep -i -n warning >> $analysis_wfile
			/opt/SUNWSMS/bin/showlogs | grep -i -n not >> $analysis_wfile

		fi


        	if [ -f /var/log/syslog ]
        	then
                	echo "\n" >> $outfile
                	echo "# tail -500 /var/log/syslog\n" >> $outfile
                	echo "$log_stamp # tail -500 /var/log/syslog ..."
               		tail -500 /var/log/syslog >> $outfile

			echo "\n\n######## [/var/log/syslog] *ERRORS* #########:\n" >> $analysis_efile
			grep -i -n error /var/log/syslog >> $analysis_efile
			
			echo "\n\n######## [/var/log/syslog] *WARNINGS* #######:\n" >> $analysis_wfile
			grep -i -n warning /var/log/syslog >> $analysis_wfile
			grep -i -n not /var/log/syslog >> $analysis_wfile

        	else
               		echo "$log_stamp  /var/log/syslog NOT found, skipping.\n"
        	fi
	else
		echo "\n\n# tail -120 /var/adm/messages\n" >> $outfile
		echo "$log_stamp # tail -120 /var/adm/messages ..."
		tail -120 /var/adm/messages >> $outfile

		echo "\n" >> $outfile
		echo "# /usr/bin/dmesg | tail -120\n" >> $outfile
		echo "$log_stamp # /usr/bin/dmesg ..."
		/usr/bin/dmesg | tail -120 >> $outfile

        	if [ -d /opt/SUNWssp ]
		then
			echo "\n" >> $outfile
			echo "# tail -120 $SSPOPT/adm/messages\n" >> $outfile
			echo "$log_stamp # tail -120 $SSPOPT/adm/messages ..."
			tail -120 $SSPOPT/adm/messages >> $outfile

			for i in /var/opt/SUNWssp/adm/*/messages
			do
				echo "\n\t>>>> tail -120 $i <<<<\n" >> $outfile
				tail -120 $i >> $outfile
				echo "\n" >> $outfile
			done
		fi

        	if [ -d /opt/SUNWSMS ]		## SunFire 25K showlog info..
		then
			echo "\n" >> $outfile
			echo "# /opt/SUNWSMS/bin/showlogs | tail -120\n" >> $outfile
			echo "$log_stamp # /opt/SUNWSMS/bin/showlogs  | tail -120 ..."
			/opt/SUNWSMS/bin/showlogs | tail -120 >> $outfile
		fi

	fi

fi


#################  ASSET / CONFIGURATION MGMT - TRACKING ################

if [ $TRACK -ne 0 ]
then

	if ( ! [ -w `echo $home_dir/sysd_cfg_mgt` ] )
	then
		mkdir $home_dir/sysd_cfg_mgt
		ret=$?

		if [ $ret -ne 0 ]
		then
			echo "ERROR: on  >> # mkdir $home_dir/sysd_cfg_mgt << , EXITING..\n" >> $outfile
			echo "$log_stamp ERROR on >> #mkdir $home_dir/sysd_cfg_mgt << , EXITING...."
			exit
		fi
	fi

	afile_prtdiag=$home_dir'/sysd_cfg_mgt/'`date '+%y%m%d_%H%M'`'_prtdiag.cfg'
	afile_prtconf=$home_dir'/sysd_cfg_mgt/'`date '+%y%m%d_%H%M'`'_prtconf.cfg'
	afile_psrinfo=$home_dir'/sysd_cfg_mgt/'`date '+%y%m%d_%H%M'`'_psrinfo.cfg'
	afile_sysdef=$home_dir'/sysd_cfg_mgt/'`date '+%y%m%d_%H%M'`'_sysdef.cfg'
	afile_eeprom=$home_dir'/sysd_cfg_mgt/'`date '+%y%m%d_%H%M'`'_eeprom.cfg'
	afile_df=$home_dir'/sysd_cfg_mgt/'`date '+%y%m%d_%H%M'`'_df.cfg'
	afile_hosts=$home_dir'/sysd_cfg_mgt/'`date '+%y%m%d_%H%M'`'_hosts.cfg'
	afile_MANcf=$home_dir'/sysd_cfg_mgt/'`date '+%y%m%d_%H%M'`'_MANcf.cfg'
	afile_showplat=$home_dir'/sysd_cfg_mgt/'`date '+%y%m%d_%H%M'`'_showplat.cfg'
	afile_domainstatus=$home_dir'/sysd_cfg_mgt/'`date '+%y%m%d_%H%M'`'_domainstatus.cfg'
	afile_cfgadm=$home_dir'/sysd_cfg_mgt/'`date '+%y%m%d_%H%M'`'_cfgadm.cfg'
	afile_metadb=$home_dir'/sysd_cfg_mgt/'`date '+%y%m%d_%H%M'`'_metadb.cfg'
	afile_metastat=$home_dir'/sysd_cfg_mgt/'`date '+%y%m%d_%H%M'`'_metastat.cfg'
	afile_vxdisk=$home_dir'/sysd_cfg_mgt/'`date '+%y%m%d_%H%M'`'_vxdisk.cfg'
	afile_vxprint=$home_dir'/sysd_cfg_mgt/'`date '+%y%m%d_%H%M'`'_vxprint.cfg'

	afile_prtdiag_last=$home_dir'/sysd_cfg_mgt/prtdiag_last.cfg'
	afile_prtconf_last=$home_dir'/sysd_cfg_mgt/prtconf_last.cfg'
	afile_psrinfo_last=$home_dir'/sysd_cfg_mgt/psrinfo_last.cfg'
	afile_sysdef_last=$home_dir'/sysd_cfg_mgt/sysdef_last.cfg'
	afile_eeprom_last=$home_dir'/sysd_cfg_mgt/eeprom_last.cfg'
	afile_df_last=$home_dir'/sysd_cfg_mgt/df_last.cfg'
	afile_hosts_last=$home_dir'/sysd_cfg_mgt/hosts_last.cfg'
	afile_MANcf_last=$home_dir'/sysd_cfg_mgt/MANcf_last.cfg'
	afile_showplat_last=$home_dir'/sysd_cfg_mgt/showplat_last.cfg'
	afile_domainstatus_last=$home_dir'/sysd_cfg_mgt/domainstatus_last.cfg'
	afile_cfgadm_last=$home_dir'/sysd_cfg_mgt/cfgadm_last.cfg'
	afile_metadb_last=$home_dir'/sysd_cfg_mgt/metadb_last.cfg'
	afile_metastat_last=$home_dir'/sysd_cfg_mgt/metastat_last.cfg'
	afile_vxdisk_last=$home_dir'/sysd_cfg_mgt/vxdisk_last.cfg'
	afile_vxprint_last=$home_dir'/sysd_cfg_mgt/vxprint_last.cfg'

	afile_log=$home_dir'/sysd_cfg_mgt/'`uname -n`'_change_log.out'


	echo "" >> $outfile
	echo "\n$log_stamp ######  ASSET / CONFIG MGMT - TRACK'G ######"
	echo "## 22 #################  ASSET / CONFIG MGMT - TRACKING  ################\n\n" >> $outfile

	if [ -f /usr/platform/`uname -m`/sbin/prtdiag ]
	then
		echo "$log_stamp ASSET CHK: STORING # /usr/platform/`uname -m`/sbin/prtdiag ..."
		/usr/platform/`uname -m`/sbin/prtdiag -v | tee $afile_prtdiag 1>/dev/null

		if [ $? -ne 0 ]
		then
			rm $afile_prtdiag
		fi

	elif [ -x /usr/platform/sun4u*/sbin/prtdiag ]
	then
		echo "$log_stamp ASSET CHK: STORING # /usr/platform/sun4u*/sbin/prtdiag ..."
		/usr/platform/sun4u*/sbin/prtdiag -v | tee $afile_prtdiag 1>/dev/null
#FIX!
		if [ $? -ne 0 ]
		then
			rm $afile_prtdiag
		fi

	else
		echo "/usr/platform/sun4u*/sbin/prtdiag NOT found, skipping.\n" >> $outfile
		echo "$log_stamp  /usr/platform/sun4u*/sbin/prtdiag NOT found, skipping.\n"
	fi

	if [ -x /usr/sbin/prtconf ]
	then
		echo "$log_stamp ASSET CHK: STORING # /usr/sbin/prtconf | grep Memory ..."
		/usr/sbin/prtconf | grep Memory | tee $afile_prtconf 1>/dev/null
	fi

#	echo "\n" >> $outfile
#	echo "# vxprint -?\n" >> $outfile
#	echo "$log_stamp ASSET CHK: # vxprint -? ..."
#	vxprint -? >> $outfile

	if [ -x /usr/sbin/psrinfo ]
	then
		echo "$log_stamp ASSET CHK: STORING # /usr/sbin/psrinfo -v ..."
		/usr/sbin/psrinfo | tee $afile_psrinfo 1>/dev/null
	fi

	if [ -x /usr/sbin/sysdef ]
	then
		echo "$log_stamp ASSET CHK: STORING # /usr/sbin/sysdef -D..."
		/usr/sbin/sysdef -D | tee $afile_sysdef 1>/dev/null
	fi

	if [ -x /usr/sbin/eeprom ]
	then
		echo "$log_stamp ASSET CHK: STORING # /usr/sbin/eeprom ..."
		/usr/sbin/eeprom | tee $afile_eeprom 1>/dev/null
	fi

	if [ -x /usr/sbin/df ]
	then
		echo "$log_stamp ASSET CHK: STORING # /usr/sbin/df -k..."
		/usr/sbin/df -k | tee $afile_df 1>/dev/null
	fi

	echo "$log_stamp ASSET CHK: STORING # /etc/hosts ..."
	cat /etc/hosts | tee $afile_hosts 1>/dev/null

	if [ -d /etc/opt/SUNWSMS/config ]   # E25K / SC IP configs
	then
		echo "$log_stamp ASSET CHK: STORING # MAN.cf ..."
		cat /etc/opt/SUNWSMS/config/MAN.cf | tee $afile_MANcf 1>/dev/null
	fi

	if [ -d /opt/SUNWSMS/bin ]
	then
		echo "$log_stamp ASSET CHK: STORING # showplatform -v ..."
		/opt/SUNWSMS/bin/showplatform -v | tee $afile_showplat 1>/dev/null
	fi

       	if [ -d /opt/SUNWssp ]			# E10K / SSP domain info
	then
		echo "$log_stamp ASSET CHK: STORING # domain_status ..."
		domain_status | tee $afile_domainstatus 1>/dev/null
#FIX!
		if [ $? -ne 0 ]
		then
			rm $afile_domainstatus
		fi
	fi

	if [ -f /usr/sbin/cfgadm ]
	then
		echo "$log_stamp ASSET CHK: STORING # /usr/sbin/cfgadm ..."
		/usr/sbin/cfgadm | tee $afile_cfgadm 1>/dev/null
#FIX!

		if [ $? -ne 0 ]
		then
			rm $afile_cfgadm
		
			if [ $ret -eq 2 ]
			then
				echo "\t/usr/sbin/cfgadm NOT supported on this platform.\n" >> $outfile
				echo "$log_stamp WARNING: /usr/sbin/cfgadm NOT supported on this platform."
			fi
		fi
	fi

	if [ -f /usr/sbin/metadb ]		## Check for SDS/SLVM Config
	then
		echo "$log_stamp ASSET CHK: STORING # metadb ..."
                /usr/sbin/metadb | tee $afile_metadb 1>/dev/null

		if [ $? -ne 0 ]
		then
			rm $afile_metadb
		fi

		echo "$log_stamp ASSET CHK: STORING # metastat ..."
                /usr/sbin/metastat | tee $afile_metastat 1>/dev/null

		if [ $? -ne 0 ]
		then
			rm $afile_metastat
		fi
	fi

	if [ -f /usr/sbin/vxdisk ]
	then
		echo "$log_stamp ASSET CHK: STORING # vxdisk list ..."
		/usr/sbin/vxdisk list | tee $afile_vxdisk 1>/dev/null
#FIX!
		if [ $? -ne 0 ]
		then
			rm $afile_vxdisk
		fi
	fi

	if [ -f /usr/sbin/vxprint ]
	then
		echo "$log_stamp ASSET CHK: STORING # vxprint -Ath ..."
		/usr/sbin/vxprint -Ath | tee $afile_vxprint 1>/dev/null
#FIX!
		if [ $? -ne 0 ]
		then
			rm $afile_vxprint
		fi
	fi

#
########## Compare latest to last Asset/Config files #############
#
	echo "_____________________________________________________\n" >> $afile_log
	echo `date` >> $afile_log

	first_page=1

	check_config $afile_prtdiag_last $afile_prtdiag $afile_log $outfile $first_page $DEBUG
	check_config $afile_prtconf_last $afile_prtconf $afile_log $outfile $first_page $DEBUG
	check_config $afile_psrinfo_last $afile_psrinfo $afile_log $outfile $first_page $DEBUG
	check_config $afile_sysdef_last $afile_sysdef $afile_log $outfile $first_page $DEBUG
	check_config $afile_eeprom_last $afile_eeprom $afile_log $outfile $first_page $DEBUG
	check_config $afile_df_last $afile_df $afile_log $outfile $first_page $DEBUG
	check_config $afile_hosts_last $afile_hosts $afile_log $outfile $first_page $DEBUG
	check_config $afile_MANcf_last $afile_MANcf $afile_log $outfile $first_page $DEBUG
	check_config $afile_showplat_last $afile_showplat $afile_log $outfile $first_page $DEBUG
	check_config $afile_domainstatus_last $afile_domainstatus $afile_log $outfile $first_page $DEBUG
	check_config $afile_cfgadm_last $afile_cfgadm $afile_log $outfile $first_page $DEBUG

	if [ -f /usr/sbin/metadb ]
	then
		check_config $afile_metadb_last $afile_metadb $afile_log $outfile $first_page $DEBUG
		check_config $afile_metastat_last $afile_metastat $afile_log $outfile $first_page $DEBUG
	fi

	if [ -f /usr/sbin/vxprint ]
	then
		check_config $afile_vxdisk_last $afile_vxdisk $afile_log $outfile $first_page $DEBUG
		check_config $afile_vxprint_last $afile_vxprint $afile_log $outfile $first_page $DEBUG
	fi

	cp $afile_log $sysd_dir


##!?TJ ADD LOGIC TO ONLY SAVE DATA/CONFIG FILES if they have changed
#
	########### save latest datafiles as the _last config files

	if [ -f `echo $afile_prtdiag` ]
	then
		cp $afile_prtdiag $afile_prtdiag_last
	fi

	cp $afile_prtconf $afile_prtconf_last
	cp $afile_psrinfo $afile_psrinfo_last
	cp $afile_sysdef $afile_sysdef_last
	cp $afile_eeprom $afile_eeprom_last
	cp $afile_df $afile_df_last

	cp $afile_hosts $afile_hosts_last

	if [ -f `echo $afile_MANcf` ]
	then
		cp $afile_MANcf $afile_MANcf_last
	fi

	if [ -f `echo $afile_showplat` ]
	then
		cp $afile_showplat $afile_showplat_last
	fi

	if [ -f `echo $afile_domainstatus` ]
	then
		cp $afile_domainstatus $afile_domainstatus_last
	fi

	if [ -f `echo $afile_cfgadm` ]
	then
		cp $afile_cfgadm $afile_cfgadm_last
	fi

	if [ -f `echo $afile_metadb` ]
	then
		cp $afile_metadb $afile_metadb_last
	fi

	if [ -f `echo $afile_metastat` ]
	then
		cp $afile_metastat $afile_metastat_last
	fi

	if [ -f `echo $afile_vxdisk` ]
	then
		cp $afile_vxdisk $afile_vxdisk_last
	fi

fi	#### END of ASSET/CONFIG MANAGEMENT SECTION ###


############################################################################
##########  wait and then KILL performance data collection  ##########

if [ $PERF -ne 0 ]
then
	log_stamp='sys_diag:'`date '+%m%d_%H%M'`':'

	wait_secs=$(($PERF_SECS-$SECONDS))

	if [ $wait_secs -gt 0 ]
	then
		echo "$log_stamp  ... WAITING $wait_secs seconds to complete data collection..."
		sleep $wait_secs
	fi

	if [ $snooppid -gt 0 ]
	then
		kill $snooppid 2>/dev/null
	fi
	
	kill $mppid $vmpid $iopid 2>/dev/null

	i=1
   	while [ $i -le $num_nets ]
   	do
		kill $((netpid[$i])) 2>/dev/null
		i=$(($i+1))
	done

	i=1
   	while [ $i -le $num_llts ]
   	do
		kill $((kstatpid[$i])) 2>/dev/null
		i=$(($i+1))
	done

	sleep 1

	lkstat_Afile=$sysd_dir'/sysd_lA_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
	lkstat_sfile=$sysd_dir'/sysd_ls_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
	lkstat_Pfile=$sysd_dir'/sysd_lP_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
    	lkstat_Ifile=$sysd_dir'/sysd_lI_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
#	dtrace_file=$sysd_dir'/sysd_dt_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'

	loutfile="./lockstat_tmp.out"

	if [[ -x /usr/sbin/lockstat  &&  ($Solaris_Rev -ge 10) ]]
	then
		echo "" >> $outfile
#		echo "# /usr/sbin/lockstat -IW -n 100000 -s 30 -o $lkstat_Ifile sleep 3 \n" >> $loutfile
		echo "##** (/usr/sbin/lockstat_-IW_-n_100000_-s_30)  $lkstat_Ifile\n" >> $loutfile
		echo "$log_stamp # /usr/sbin/lockstat -IW -n 100000 -s 30 -o $lkstat_Ifile sleep 3 ..."
		/usr/sbin/lockstat -IW -n 100000 -s 30 -o $lkstat_Ifile sleep 3

#		echo "# /usr/sbin/lockstat -A -n 100000 -D30 -o $lkstat_Afile sleep 10 \n" > $loutfile
		echo "##** (/usr/sbin/lockstat_-A_-n_100000_-D30)  $lkstat_Afile\n" > $loutfile
		echo "$log_stamp # /usr/sbin/lockstat -A -n 100000 -D30 -o $lkstat_Afile sleep 10 ..."
		/usr/sbin/lockstat -A -n 100000 -D30 -o $lkstat_Afile sleep 10

#		echo "# /usr/sbin/lockstat -A -s10 -n 100000 -D10 -o $lkstat_sfile sleep 10 \n" >> $loutfile
		echo "##** (/usr/sbin/lockstat_-A_-s10_-n_100000_-D10)  $lkstat_sfile\n" >> $loutfile
		echo "$log_stamp # /usr/sbin/lockstat -A -s10 -n 100000 -D10 -o $lkstat_sfile sleep 10 ..."
		/usr/sbin/lockstat -A -s10 -n 100000 -D10 -o $lkstat_sfile sleep 10

#		echo "# /usr/sbin/lockstat -AP -s10 -n 100000 -D10 -o $lkstat_Pfile sleep 10 \n" >> $loutfile
		echo "##** (/usr/sbin/lockstat_-AP_-s10_-n_100000_-D10)  $lkstat_Pfile\n" >> $loutfile
		echo "$log_stamp # /usr/sbin/lockstat -AP -s10 -n 100000 -D10 -o $lkstat_Pfile sleep 10 ..."
		/usr/sbin/lockstat -AP -s10 -n 100000 -D10 -o $lkstat_Pfile sleep 10
	elif [[ -x /usr/sbin/lockstat  &&  ($Solaris_Rev -eq 9) ]]
	then
#		echo "# /usr/sbin/lockstat -IW -n 75000 -s30 -o $lkstat_Ifile sleep 3 \n" >> $loutfile
		echo "##** (/usr/sbin/lockstat_-IW_-n_75000_-s30)  $lkstat_Ifile\n" >> $loutfile
		echo "$log_stamp # /usr/sbin/lockstat -IW -n 75000 -s30 -o $lkstat_Ifile sleep 3 ..."
		/usr/sbin/lockstat -IW -n 75000 -s 30 -o $lkstat_Ifile sleep 3

#		echo "# /usr/sbin/lockstat -A -n 75000 -D30 -o $lkstat_Afile sleep 10 \n" > $loutfile
		echo "##** (/usr/sbin/lockstat_-A_-n_75000_-D30)  $lkstat_Afile\n" > $loutfile
		echo "$log_stamp # /usr/sbin/lockstat -A -n 75000 -D30 -o $lkstat_Afile sleep 10 ..."
		/usr/sbin/lockstat -A -n 75000 -D30 -o $lkstat_Afile sleep 10

#		echo "# /usr/sbin/lockstat -A -s10 -n 75000 -D10 -o $lkstat_sfile sleep 10 \n" >> $loutfile
		echo "##** (/usr/sbin/lockstat_-A_-s10_-n_75000_-D10)  $lkstat_sfile\n" >> $loutfile
		echo "$log_stamp # /usr/sbin/lockstat -A -s10 -n 75000 -D10 -o $lkstat_sfile sleep 10 ..."
		/usr/sbin/lockstat -A -s10 -n 75000 -D10 -o $lkstat_sfile sleep 10

#		echo "# /usr/sbin/lockstat -AP -s10 -n 50000 -D10 -o $lkstat_Pfile sleep 10 \n" >> $loutfile
		echo "##** (/usr/sbin/lockstat_-AP_-s10_-n_50000_-D10)  $lkstat_Pfile\n" >> $loutfile
		echo "$log_stamp # /usr/sbin/lockstat -AP -s10 -n 50000 -D10 -o $lkstat_Pfile sleep 10 ..."
		/usr/sbin/lockstat -AP -s10 -n 50000 -D10 -o $lkstat_Pfile sleep 10
	elif [[ -x /usr/sbin/lockstat  &&  ($Solaris_Rev -eq 8) ]]
	then
#		echo "# /usr/sbin/lockstat -IW -s 30 -o $lkstat_Ifile sleep 3 \n" >> $loutfile
		echo "##** (/usr/sbin/lockstat_-IW_-s_30)  $lkstat_Ifile\n" >> $loutfile
		echo "$log_stamp # /usr/sbin/lockstat -IW -s 30 -o $lkstat_Ifile sleep 3 ..."
		/usr/sbin/lockstat -IW -s 30 -o $lkstat_Ifile sleep 3

#		echo "# /usr/sbin/lockstat -A -D30 -o $lkstat_Afile sleep 10 \n" > $loutfile
		echo "##** (/usr/sbin/lockstat_-A_-D30)  $lkstat_Afile\n" > $loutfile
		echo "$log_stamp # /usr/sbin/lockstat -A -D30 -o $lkstat_Afile sleep 10 ..."
		/usr/sbin/lockstat -A -D30 -o $lkstat_Afile sleep 10

#		echo "# /usr/sbin/lockstat -A -s10 -D10 -o $lkstat_sfile sleep 10 \n" >> $loutfile
		echo "##** (/usr/sbin/lockstat_-A_-s10_-D10)  $lkstat_sfile\n" >> $loutfile
		echo "$log_stamp # /usr/sbin/lockstat -A -s10 -D10 -o $lkstat_sfile sleep 10 ..."
		/usr/sbin/lockstat -A -s10 -D10 -o $lkstat_sfile sleep 10

#		echo "# /usr/sbin/lockstat -AP -s10 -D10 -o $lkstat_Pfile sleep 10 \n" >> $loutfile
		echo "##** (/usr/sbin/lockstat_-AP_-s10_-D10)  $lkstat_Pfile\n" >> $loutfile
		echo "$log_stamp # /usr/sbin/lockstat -AP -s10 -D10 -o $lkstat_Pfile sleep 10 ..."
		/usr/sbin/lockstat -AP -s10 -D10 -o $lkstat_Pfile sleep 10
	fi

	echo "\n$log_stamp  ------- Data Collection COMPLETE -------\n"

	sleep 1
###

   echo "" >> $outfile
   echo "\n$log_stamp ######  SYSTEM ANALYSIS : INITIAL FINDINGS ... ######"
   echo "## 23 ##################  SYSTEM ANALYSIS : INITIAL FINDINGS #############\n\n" >> $outfile

	echo "\n\t****************** *! ERROR !* MESSAGES *******************:\n" >> $outfile
	cat $analysis_efile >> $outfile		## ERROR Message Listings

	echo "\n\t****************** *WARNING* MESSAGES *******************:\n" >> $outfile
	cat $analysis_wfile >> $outfile		## WARNING Message Listings


#
# SCAN the Performance data files gathered for any possible issues
#
	num=0

	echo "" >> $outfile
	echo "\n$log_stamp ######  PERFORMANCE DATA : POTENTIAL ISSUES  ######"
	echo "\n_____________________________________________________\n"
	echo "## 24 #############  PERFORMANCE DATA : POTENTIAL ISSUES  ################\n\n" >> $outfile

	vmex_file=$sysd_dir'/sysd_vmx_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
	vmavg_file=$sysd_dir'/sysd_vmavg_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'

	echo "\n$log_stamp ## Analyzing VMSTAT CPU Datafile :\n\t$vmstat_file ..."
	echo "*** VMSTAT CPU Exceptions for file: $vmstat_file **" >> $outfile
	echo "\n\t[entries where (RunQ > $VMSTAT_RUNQ_GT) or (RunQ_Blocked > $VMSTAT_RQBLKD_GT) \n\t\tor (cpu_idle < $VMSTAT_PCTIDLE_LT) or ((%Sys > %Usr) and (cpu_idle < 20))]\n" >> $outfile


##? state || procs || device (ignore state change msgs / headers..) 

	tail +4 $vmstat_file | grep -v "swap" | grep -v "kthr" | grep -v "State" | /usr/bin/awk '{ if (( $1 > int(w) ) || ( $2 > int(x) ) || (( $21 > $20 ) && ( $22 < int(20) )) || ( $22 < int(z) )) { print $0 ; num++ } { num_lines++ } } END { print "\tNOTE:", (num/num_lines)*100 , "%", ":", num, "of",NR }' num=0 w=$VMSTAT_RUNQ_GT x=$VMSTAT_RQBLKD_GT z=$VMSTAT_PCTIDLE_LT | sort -k 22,22 -k 20,20 > $vmex_file

	tail +4 $vmstat_file | /usr/bin/awk '{ if (( $1 != "procs" ) && ( $1 != "r" ) && ( $1 != "\<\<State" ) && ( $1 != "kthr" )) { rqueue+=$1 ; vmem+=$4 ; free+=$5 ; sr+=$12 ; user+=$20 ; sys+=$21 ; idle+=$22 ; num++ } { num_lines++ } } END { printf "TOTAL CPU AVGS :   RUNQ=%5.1f  :   USR=%5.1f :  SYS=%5.1f :  IDLE=%5.1f\n",(rqueue/num),(user/num),(sys/num),(idle/num); print "\n"; printf "TOTAL MEM AVGS :   SR=%5.1f  :   SWAP=%11.1f K  :  FREE=%11.1f K\n",(sr/num),(vmem/num),(free/num) }' num=0 >> $vmavg_file


	echo "\n  `head -1 $vmavg_file`" >> $outfile

	echo "\n   * `grep "NOTE" $vmex_file` VMSTAT CPU entries are WARNINGS!! *\n"
	echo "\n   * `grep "NOTE" $vmex_file` VMSTAT CPU entries are WARNINGS!! *\n" >> $outfile

	head -1 $vmavg_file

	vm_pct=`grep "NOTE" $vmex_file | cut -d" " -f2`

	if [ $vm_pct -gt 0 ]
	then
		echo "   VMSTAT (top 100) WARNINGs are sorted by least % Idle cpu.\n" >> $outfile
		echo "`/usr/bin/vmstat | head -2`" >> $outfile
		head -100 $vmex_file | grep -v "NOTE:" >> $outfile
	fi

	echo "Rq B Vmem Ram SR Usr Sys Idle" > $vmstat_graph_file

	tail +4 $vmstat_file | /usr/bin/awk '{ if (( $1 != "procs" ) && ( $1 != "r" ) && ( $1 != "\<\<State" ) && ( $1 != "kthr" )) { print $1,$2,$4,$5,$12,$20,$21,$22  } { num_lines++ } } END { num=0 } '  >> $vmstat_graph_file


####### (Check Free MEMORY and Available SWAP and Scan Rate Thresholds)

	echo "\n_____________________________________________________\n" >> $outfile
	echo "\n_____________________________________________________\n"

	memex_file=$sysd_dir'/sysd_memx_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'

	echo "\n$log_stamp ## Analyzing VMSTAT MEMORY from Datafile :\n\t$vmstat_file ..."
	echo "\n*** VMSTAT MEMORY Findings for file: $vmstat_file **" >> $outfile

	total_swap_k=0

	for s in `/usr/sbin/swap -l | grep -v "swapfile" | /usr/bin/awk '{ print $4 }'`
	do
		s=$(($s/2))
		total_swap_k=$(($total_swap_k+$s))
	done

	min_swap_k=`echo "$total_swap_k $SWAP_PCT_MIN" | /usr/bin/awk '{ swap_pct=int(s)/100; min_swap=int(t)*swap_pct; print min_swap }' s=$SWAP_PCT_MIN t=$total_swap_k`

	total_ram_k=0
	total_ram_k=$((`/usr/sbin/prtconf | grep Memory | cut -d" " -f3`*1000))

	min_ram_k=`echo "$total_ram_k $MEM_PCT_MIN" | /usr/bin/awk '{ mem_pct=int(m)/100; min_ram=int(t)*mem_pct; print min_ram }' m=$MEM_PCT_MIN t=$total_ram_k`
	tail +4 $vmstat_file | grep -v "swap" | grep -v "kthr" | grep -v "State" | /usr/bin/awk '{ free_swap=$4-$5; if (( $12 > int(s) ) || ( free_swap < int(v) ) || ( $5 < int(m) )) { print $0 ; num++ } { num_lines++ } } END { print "\tNOTE:", (num/num_lines)*100 , "%", ":", num, "of",NR }' num=0 v=$min_swap_k m=$min_ram_k s=$VMSTAT_SCANRT_GT | sort -k 5,5 > $memex_file

	mem_pct=`grep "NOTE" $memex_file | cut -d" " -f2`

	echo "\n  [entries where (scan_rate > $VMSTAT_SCANRT_GT) or ( free_swap [swap-free] < $min_swap_k K [ < $SWAP_PCT_MIN % total_swap ($total_swap_k K) ] )\n\t\tor (free_mem < $min_ram_k K) [ < $MEM_PCT_MIN % total_ram ($total_ram_k K) ]\n" >> $outfile

	echo "\n  `tail -1 $vmavg_file`" >> $outfile

	echo "\n   * `grep "NOTE" $memex_file` VMSTAT MEMORY entries are WARNINGS!! *\n" 
	echo "\n   * `grep "NOTE" $memex_file` VMSTAT MEMORY entries are WARNINGS!! *\n" >> $outfile

	tail -1 $vmavg_file

	if [ $mem_pct -gt 0 ]
	then
		echo "\n   VMSTAT (top 10) exceptions with least Memory Available\n" >> $outfile
		echo "`/usr/bin/vmstat | head -2`\n" >> $outfile
		head -10 $memex_file | grep -v "NOTE:" >> $outfile
	fi

	echo "\n_____________________________________________________\n" >> $outfile
	echo "\n_____________________________________________________\n"

	mpex_file=$sysd_dir'/sysd_mpx_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'

	echo "\n$log_stamp ## Analyzing MPSTAT Datafile :\n\t$mpstat_file ..."
	echo "\n\n*** MPSTAT Findings for file: $mpstat_file **" >> $outfile
	echo "\n\t[entries where Cpu ( ((icsw > $MPSTAT_ICSW_GT) || (smtx > $MPSTAT_SMTX_GT)) && (%Sys > $MPSTAT_SYS_GT)) or\n\t\t (%Wait > $MPSTAT_PCTWT_GT) or (%Idle < $MPSTAT_PCTIDLE_LT)]" >> $outfile

	grep -v "CPU" $mpstat_file | grep -v "State" | /usr/bin/awk '{ if (((( $8 > int(w) ) || ( $10 > int(x) )) && ( $14 > int(v) )) || ( $15 > int(y) ) || ( $16 < int(z) )) { print $0 ; num++ } { num_lines++ } } END { print "\tNOTE:", (num/NR)*100 , "%", ":", num, "of", NR }' num=0 v=$MPSTAT_SYS_GT w=$MPSTAT_ICSW_GT x=$MPSTAT_SMTX_GT y=$MPSTAT_PCTWT_GT z=$MPSTAT_PCTIDLE_LT | sort -r -k 14,14 -k 9,9 > $mpex_file

	mp_avgs=`grep -v "CPU" $mpstat_file | grep -v "State" | /usr/bin/awk '{ if ( $1 != "procs" ) { w+=$15 ; xcal+=$4 ; csw+=$7 ; icsw+=$8 ; migr+=$9 ; smtx+=$10 ; syscl+=$12 ; num++ } { num_lines++ } } END { printf "CPU AVGS :  Wt=%d : Xcal=%d : csw=%d : icsw=%d : migr=%d : smtx=%d : syscl=%d",(w/num),(xcal/num),(csw/num),(icsw/num),(migr/num),(smtx/num),(syscl/num) }' num=0`

	echo "\n  $mp_avgs" >> $outfile

	mp_pct=`grep "NOTE" $mpex_file | cut -d" " -f2`

	echo "\n   * `grep "NOTE" $mpex_file` MPSTAT CPU entries are WARNINGS!! *" 
	echo "\n   * `grep "NOTE" $mpex_file` MPSTAT CPU entries are WARNINGS!! *\n" >> $outfile
	echo "\n  $mp_avgs"

	if [ $mp_pct -gt 0 ]
	then
		echo "   MPSTAT (top 100) WARNINGs are sorted by highest %Sys\n" >> $outfile
		echo "`/usr/bin/mpstat | head -1`\n" >> $outfile
		head -100 $mpex_file | grep -v "NOTE:" >> $outfile
	fi

	echo "\n\n   NOTE: Review the following LOCKSTAT rpts for locking/mtx correlation.\n" >> $outfile
	cat $loutfile >> $outfile

	echo "\n_____________________________________________________\n" >> $outfile
	echo "\n_____________________________________________________\n"


	io_pct=0

	ioex_file=$sysd_dir'/sysd_iox_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
	ioavg_file=$sysd_dir'/sysd_ioavg_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'

	echo "\n$log_stamp ## Analyzing IOSTAT Datafile :\n\t$iostat_file ..."

	echo "\n\n*** IOSTAT Findings for file: $iostat_file **" >> $outfile
	echo "\n   [entries where device (transacts_Waiting > $IOSTAT_WAIT_GT) or (Svc_time_ms > $IOSTAT_SVCTM_GT) \n\t  or (%W > $IOSTAT_PCTWT_GT) or (%Busy > $IOSTAT_PCTBSY_GT)]" >> $outfile


## Print device samples that are beyond thresholds (sorted by highest a_svct)

	grep -v "^    0.0    0.0" $iostat_file | grep -v "extended" | grep -v "r/s" | /usr/bin/awk '{ if (( $5 > int(w) ) || ( $8 > int(x) ) || ( $9 > int(y) ) || ( $10 > int(z) )) { print $0 ; num++ } else { num_lines++ } } END { print "NOTE:", (num/NR)*100,"%",":",num,"of",NR }' w=$IOSTAT_WAIT_GT x=$IOSTAT_SVCTM_GT y=$IOSTAT_PCTWT_GT z=$IOSTAT_PCTBSY_GT | sort -r -k 8,8 > $ioex_file

	io_pct=`grep "NOTE" $ioex_file | cut -d" " -f2`

	echo "\n   * `grep "NOTE" $ioex_file` IOSTAT entries are WARNINGS!! *" 
	echo "\n   * `grep "NOTE" $ioex_file` IOSTAT entries are WARNINGS!! *\n" >> $outfile

	if [ $io_pct -gt 0 ]
	then
		echo "   IOSTAT (top 100) WARNINGs reflect the slowest device entries.\n" >> $outfile
		echo "`/usr/bin/iostat -xn | head -2`\n" >> $outfile
		head -100 $ioex_file | grep -v "NOTE:" >> $outfile
		echo "\n________________________\n" >> $outfile
	fi

# Print averages per device (only for non-zero entries .. device activity)

	grep -v "^    0.0    0.0" $iostat_file | grep -v "^     " | grep -v "extended" | grep -v "r/s" | sort -k 11,11 | /usr/bin/awk '{ if (( $11 == ldev ) || ( dnum < 1 )) { r+=$1; w+=$2; kr+=$3; kw+=$4; ac+=$6; ws+=$7; as+=$8; w+=$9; b+=$10; ldev=$11; dnum++ } else { printf "%7.1f%7.1f%7.1f%7.1f%5.1f     %7.1f%7.1f%4d%4d %-12s %d\n",(r/dnum),(w/dnum),(kr/dnum),(kw/dnum),(ac/dnum),(ws/dnum),(as/dnum),(w/dnum),(b/dnum),ldev,dnum; r=$1; w=$2; kr=$3; kw=$4; ac=$6; ws=$7; as=$8; w=$9; b=$10; ldev=$11; dnum=1 } } END { printf "%7.1f%7.1f%7.1f%7.1f%5.1f     %7.1f%7.1f%4d%4d %-13s %d\n",(r/dnum),(w/dnum),(kr/dnum),(kw/dnum),(ac/dnum),(ws/dnum),(as/dnum),(w/dnum),(b/dnum),ldev,dnum }' > $ioavg_file

	echo "\n\n   Device AVERAGES (for non-zero entries).\n"

	echo "`/usr/bin/iostat -xn | head -2 | tail -1`  # I/O Samples\n"
	cat $ioavg_file

	echo "\n   The following reflects DEVICE AVERAGES (for non-zero entries) :\n   ( # Samples = the # of non 0 iostat entries per device, used for the avg)\n" >> $outfile

	echo "`/usr/bin/iostat -xn | head -2`    # I/O Samples\n" >> $outfile
	cat $ioavg_file >> $outfile


	echo "\n_____________________________________________________\n" >> $outfile
	echo "\n_____________________________________________________\n"

#############
##	NOTE:  Network Performance analysis  :
##	(most systems dont see collisions, ..they cant exist with Full Duplex )
##
	netavg2_file=$sysd_dir'/sysd_netavg2_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'
	netavg1_file=$sysd_dir'/sysd_netavg1_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'

	echo "\n$log_stamp ## Analyzing NETSTAT Datafiles : ...\n"
	echo "\n\n*** NETSTAT Findings :\n" >> $outfile
	echo "\n\t[entries where interface (RX_Pkts > $NETSTAT_RX_GT) or (Rx_Pkt_Errs > $NETSTAT_RX_ERR_GT) \n\t\tor (Tx_Pkts > $NETSTAT_TX_GT) or (Tx_Pkt_Errs > $NETSTAT_TX_ERR_GT) or (Collisions > $NETSTAT_COLL_GT)]\n" >> $outfile

	num_nets=0
	net_pct=0
	net_pct_nic=0

	for i in `/usr/sbin/ifconfig -a |  grep ": " | cut -d":" -f1`
	do
   		num_nets=$(($num_nets+1))
		netex_file=$sysd_dir'/sysd_net'$num_nets'x_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.out'

		netstat_file=$sysd_dir'/sysd_net'$num_nets'_'`uname -n`'_'`date '+%y%m%d_'`'*.out'
		netstat_graph_file=$sysd_dir'/sysd_net'$num_nets'_'`uname -n`'_'`date '+%y%m%d_%H%M'`'.gr.txt'


		tail +4 $netstat_file | /usr/bin/awk '{ if ((( $1 != "input" ) && ( $1 != "packets" )) && (( $1 > int(v) ) || ( $2 > int(w) ) || ( $3 > int(x) ) || ( $4 > int(y) ) || ( $5 < int(z) ))) { print $0 ; num++ } { num_lines++ } } END { print "NOTE:", (num/num_lines)*100,"%",":", num, "of",num_lines }' num=0 v=$NETSTAT_RX_GT w=$NETSTAT_RX_ERR_GT x=$NETSTAT_TX_GT y=$NETSTAT_TX_ERR_GT z=$NETSTAT_COLL_GT > $netex_file

		net_pct_nic=`grep "NOTE" $netex_file | cut -d" " -f2`

		echo "   * $i : `grep "NOTE" $netex_file` NETSTAT entries are WARNINGS!! *\n" >> $netavg1_file
		echo "\n   * $i : `grep "NOTE" $netex_file` NETSTAT entries are WARNINGS!! *\n" >> $outfile

		if [ $net_pct_nic -gt 0 ]
		then
			echo "\n*** Top 20 samples for : $i from file: $netstat_file **" >> $outfile
			echo "\nRX_PKTS\t\tRX_ERRS\t\tTX_PKTS\t\tTX_ERRS\t\tCOLLISIONS" >> $outfile
			grep -v "NOTE" $netex_file | sort -r -k 1,1 | head -20 >> $outfile
		fi


		echo "\n\t      AVG_RX_PKTS  AVG_RX_ERRS  AVG_TX_PKTS  AVG_TX_ERRS  AVG_COLL" >> $outfile

		echo "NET$num_nets: $i : \c" >> $outfile
		echo "NET$num_nets: $i : \c" >> $netavg2_file

		net_avg=`tail +4 $netstat_file | /usr/bin/awk '{ if (( $1 != "input" ) && ( $1 != "packets" )) { rxpkts+=$1 ; rxerrs+=$2 ; txpkts+=$3 ; txerrs+=$4 ; collisions+=$5 ; num++ } { num_lines++ } } END { if ( num > 0 ) { print "\t", (rxpkts/num), "\t", (rxerrs/num), "\t", (txpkts/num), "\t", (txerrs/num), "\t", (collisions/num) } }' num=0 v=$NETSTAT_RX_GT w=$NETSTAT_RX_ERR_GT x=$NETSTAT_TX_GT y=$NETSTAT_TX_ERR_GT z=$NETSTAT_COLL_GT `

		echo "$net_avg" >> $outfile
		echo "$net_avg" >> $netavg2_file

		echo "RX_pkts TX_pkts Total_RX Total_TX" > $netstat_graph_file

		tail +4 $netstat_file | /usr/bin/awk '{ if (( $1 != "input" ) && ( $1 != "packets" )) { print $1,$3,$6,$8 } { num_lines++ } } END { num=0 }' >> $netstat_graph_file


		echo "\n\t_________________________________________\n" >> $outfile

		if [ $net_pct_nic -gt $net_pct ]
		then
			net_pct=$net_pct_nic
		fi

	done

	echo "\t     AVG_RX_PKTS  AVG_RX_ERRS  AVG_TX_PKTS  AVG_TX_ERRS  AVG_COLL" >> $netavg1_file
	cat $netavg1_file
	cat $netavg2_file

	echo "\n_____________________________________________________\n"

	if [ -x /sbin/lltstat ]		# VCS LLT interconnect stats,..if there
	then
		echo "\n*** VCS LLTSTAT Interconnect Packets after $SECONDS seconds **" >> $outfile
		/sbin/lltstat -l >> $outfile

		echo "_____________________________________________________\n" >> $outfile
	fi


##### Calculate the Dashboard States ##########################

if [ $vm_pct -gt $VMSTAT_PCT_RED ] || [ $mp_pct -gt $MPSTAT_PCT_RED ]
then
	cpu_color="RED"
	cpu_rgb="rgb(255, 0, 0)"
elif [ $vm_pct -gt $VMSTAT_PCT_YEL ] || [ $mp_pct -gt $MPSTAT_PCT_YEL ]
then
	cpu_color="YEL"
	cpu_rgb="rgb(255, 255, 0)"
else
	cpu_color="GRN"
	cpu_rgb="rgb(51, 204, 0)"
fi

if [ $mem_pct -gt $MEM_PCT_RED ]
then
	mem_color="RED"
	mem_rgb="rgb(255, 0, 0)"
elif [ $mem_pct -gt $MEM_PCT_YEL ]
then
	mem_color="YEL"
	mem_rgb="rgb(255, 255, 0)"
else
	mem_color="GRN"
	mem_rgb="rgb(51, 204, 0)"
fi

if [ $io_pct -gt $IOSTAT_PCT_RED ]
then
	io_color="RED"
	io_rgb="rgb(255, 0, 0)"
elif [ $io_pct -gt $IOSTAT_PCT_YEL ]
then
	io_color="YEL"
	io_rgb="rgb(255, 255, 0)"
else
	io_color="GRN"
	io_rgb="rgb(51, 204, 0)"
fi

if [ $net_pct -gt $NETSTAT_PCT_RED ]
then
	net_color="RED"
	net_rgb="rgb(255, 0, 0)"
elif [ $net_pct -gt $NETSTAT_PCT_YEL ]
then
	net_color="YEL"
	net_rgb="rgb(255, 255, 0)"
else
	net_color="GRN"
	net_rgb="rgb(51, 204, 0)"
fi

echo "* NOTE:\tCPU=$cpu_color  :  \c"
echo "MEM=$mem_color  :  \c"
echo "IO=$io_color  :  \c"
echo "NET=$net_color *\n"

echo "_____________________________________________________\n"
########### Generate the HTML Performance Dashboard #############

echo "<h3>System Performance Dashboard :</h3>" > $dash_file
echo "<table style=\"margin-left: auto; margin-right: auto; text-align: left; width: 677px;\" border=\"2\" cellpadding=\"2\" cellspacing=\"2\"> <tbody> <tr>" >> $dash_file

## to EMBED file lnk: echo "<a href=\"file:///$etc_system_file#etc_system\" class=\"named\"></a>" >> $hfile

echo "<td style=\"vertical-align: top; background-color: $cpu_rgb;\"><span style=\"font-weight: bold; text-decoration: underline;\">CPU:</span><br>" >> $dash_file

echo "<pre>   * `grep "NOTE" $vmex_file` VMSTAT CPU entries are WARNINGS!! *<br><b>" >> $dash_file
head -1 $vmavg_file >> $dash_file
echo "</b><br>`/usr/bin/prstat -c -t 1 1`<br>" >> $dash_file
echo "\t<a href=\"#3\" class=\"named\">CPU Config</a>\t<a href=\"#VMSTAT CP\" class=\"named\">*VMSTAT CPU Analysis*</a>\t<a href=\"#MPSTAT Fi\" class=\"named\">*MPSTAT Analysis*</a></ul>" >> $dash_file
echo "</pre> </td> </tr>" >> $dash_file

echo "<tr> <td style=\"vertical-align: top; background-color: $mem_rgb;\"><span style=\"font-weight: bold; text-decoration: underline;\">MEMORY:</span><br>" >> $dash_file
echo "<pre>   * `grep "NOTE" $memex_file` VMSTAT MEMORY entries are WARNINGS!! *<br><b>" >> $dash_file
tail -1 $vmavg_file >> $dash_file
echo "</b>\n\t<a href=\"#1\" class=\"named\">Memory Config</a>\t<a href=\"#VMSTAT ME\" class=\"named\">*VMSTAT MEM Analysis*</a></ul>" >> $dash_file
echo "</pre> </td> </tr>" >> $dash_file

echo "<tr> <td style=\"vertical-align: top; background-color: $io_rgb;\"><span style=\"text-decoration: underline; font-weight: bold;\">IO:</span><br>" >> $dash_file
echo "<pre>   * `grep "NOTE" $ioex_file` IOSTAT entries are WARNINGS!! *<br>" >> $dash_file
echo "\t<a href=\"#8\" class=\"named\">IO Config</a>\t<a href=\"#7\" class=\"named\">FS Config</a>\t<a href=\"#6\" class=\"named\">VM Config</a>\t<a href=\"#IOSTAT Fi\" class=\"named\">*IOSTAT Analysis*</a></ul>" >> $dash_file
echo "</pre> </td> </tr>" >> $dash_file

echo "<tr> <td style=\"vertical-align: top; background-color: $net_rgb;\"><span style=\"font-weight: bold; text-decoration: underline;\">NETWORK:</span><br><pre>" >> $dash_file
cat $netavg1_file >> $dash_file
cat $netavg2_file >> $dash_file
echo "<br>\t<a href=\"#10\" class=\"named\">Network Config</a>\t\t<a href=\"#NETSTAT F\" class=\"named\">*NETSTAT Analysis*</a></ul>" >> $dash_file
echo "</pre> </td> </tr> </tbody> </table>" >> $dash_file



fi	### END OF Performance Data Gathering and Analysis Section ###



############  Generate .ps output (2 pages / pg landscape)   #################

if [ $POST -ne 0 ]
then
	outfile_ps="$outfile.ps"
	/usr/openwin/bin/mp -l $outfile > $outfile_ps
fi


################################

html_file="$outfile.html"

gen_html_rpt $outfile $html_file $dash_file $PERF

#
# TAR/Compress performance data and sys_diag report (in both text and .ps)
#

if [ $TAR -ne 0 ]
then
	tar_file="./sys_diag_`uname -n`_`date '+%y%m%d_%H%M'`.tar"

        echo "\n$log_stamp ## Generating TAR file : $tar_file ..."

	tar -cvf $tar_file $sysd_dir 1>/dev/null

	compress $tar_file

	echo "\nData files have been TARed and compressed in :\n\t$tar_file.Z -------\n\n"
fi


############################################################################

echo "------- Sys_Diag Complete -------\n\n"


############################################################################


##############################################################################
### 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 2006 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
##############################################################################


