#!/bin/ksh # # # Title: sysinfo # Author: Scott Truesdale # Organization: Hewlett-Packard Account Support Organization # America's Engineering Services Team # # NOTE: This script is a contributed utility. No official support for it # will be provided by Hewlett-Packard. Any requests for bug fixes # or enhancements will be handled by the author, time permitting. # # Version: 1.00 08/01/96 # Changes: 1.01 08/05/96 added functions to handle each module # 1.02 \ cleaned up various # 1.03 / output screens # 1.04 08/20/96 added filesystem check using lvol # 1.05 08/25/96 added savecore flag and space check # 1.06 09/03/96 changed filesystem check to use mnttab # 1.07 09/03/96 fixed filesystem check when bdf is 2 lines # 1.08 10/10/96 general cleanup, added more dump checking # 1.09 10/10/96 added use of pager variable for output # 1.10 10/23/96 fixed dump checking section (I hope) # added 10.10 compression calculation (-s) # 1.11 10/30/96 fixed display of number of stale extents (-l) # added comments to help document functions. # 1.12 10/31/96 added -N option to disable paging option. # 1.13 11/06/96 added cpu speed display (in MHz). (-s) # 1.14 11/08/96 removed tabs and added comments. # 1.15 11/11/96 added check for non HP-UX systems. # 1.16 11/20/96 expanded mapping to include number of # extents and mirrors. (-m) # 1.17 11/21/96 added kernel size display (-k) # added check for non-LVM disks (-p) # 1.18 11/26/96 added license, machine id (-s) # added domain name (-k) # fixed batch to include header information # added check for vgcfg files > 1 year old. (-v) # added kernel size to memory dump calculations # 1.19 12/03/96 fixed error if no CD mounted in CD-ROM drive # changed help (-h) to use man page # 1.20 12/12/96 added physical disk mapping option (-M) # for 10.x systems # added dbc_max_pct kernel parm # 1.21 12/17/96 added physical disk mapping for 9.x # 1.22 01/07/97 fixed bug in path display for cdroms # 1.23 02/04/97 added last patch date display # 1.24 02/10/97 fixed bug in physical check for cdrom # device busy error # 1.25 02/12/97 fixed display of dump on default for 9.x # 1.26 02/28/97 added display of default router # 1.27 03/10/97 added display of MAC address # 1.28 03/18/97 added display of alternate links # added bootable check to Physical info # 1.29 04/15/97 added check for dynamic buffer caching # added nflocks kernel parm # added check for async disk write # added check for savecore compression in # /etc/rc.config.d/savecore # fixed exit code for warnings # added auto boot string output # 1.30 04/22/97 cleaned up swap and dump disk display # added check for cdfs to % full warning # fixed dbc and its warning for only 10.x # added ability to specify savecore # compression factor as variable # 1.31 04/22/97 fixed bug in calculating savecore capacity # 1.32 04/22/97 added display of boot disks # 1.33 07/08/97 fixed pre 10.20 warning for not # enough savecore space # 1.34 07/19/97 added dns server display # changed netmask to decimal.dot format # 1.35 07/29/97 added use of model command to detect new # system models # added following from Mike Ryan: # fixed display of multiple MAC addresses # patch for pvdisplay difference in 10.20 # fix VG display when PVG-strict policies used # (thanks Mike!) # 1.36 07/31/97 fixed bug in alternate PV link detection # 1.37 08/01/97 added super page check # removed dynamic buffer warning # improved debug message handling # changed debug messages to tee to file # 1.38 08/17/97 added check for number of volume groups equal # to maxvgs # started adding HTML hooks (-H option) # added HTML headers to each section # added HTML links to each section # added HTML info to man page # 1.39 08/20/97 added check for existing logfiles # ask user if we should delete batch logfile # automatically delete HTML logfile # changed temp file names to sysinfo.$$. # 1.40 08/26/97 changed physical disk section to not query # alternate links # 1.41 08/28/97 added kernel parms section extracted using # tools from SAM. # 1.42 09/19/97 changed network to use lanscan due to # problems with multiple I/F cards. # 1.43 10/21/97 added hw path to network card info. # added fstype display to filesystem info. # fixed display of cdfs space usage. # fixed man page that incorrectly stated free # space threshold was 10% instead of 5%. # 1.44 04/09/98 major enhancements # added ioscan listing. # added software listing (10.x only) # added listing of striped discs. # launched io, kernel and lvm scans # as background jobs to speed things up. # 1.45 04/17/98 fixed bug that caused dbc parms not to # be displayed. # 1.46 04/30/98 changed swap disk header to swap data # added fs swaptype to total swap display # 1.47 05/03/98 added warning about static buffer cache # numbers reported from kernel. # 1.48 05/20/98 added variable for logfile directory. # removed user query if removing existing logfile. # reworked logical volume section into two parts. # 1.49 07/01/98 first set of changes to work on 11.x # savecore now called savecrash # changed BOOTABLE to check for >= 10 # physmem now called phys_mem_pages # 1.49a added host name to WARNING messages # added TOP link to html output # 1.49b 07/16/98 fixed problems for 9.x induced by background # scans of sam, swap and ioscan # samscan, ioscan, swapmem # removed samscan (getkinfo) from 9.x # changed to force getkinfo to rescan (-b) # 1.49c 07/23/98 more ioscan changes for 9.x # 1.49d 07/27/98 major kernel changes # 1.49e 08/01/98 fixed problem with filesystem display # if size greater than 65 GB. # 1.49f 08/03/98 added separate 9.x kernel function # including many more kernel metrics # moved kernel size to system section # rewrote header section for HTML # added batch print for software section # changed lanscan -i for 9.x # 1.49g 08/05/98 lots # 1.50 08/06/98 fixed kernel parms on 10.x & 11.x # # # # # Acknowledgements: # I would like to acknowledge the following for assistance in # developing and testing this tool. # Mike Ryan and Bill Taylor from the Hewlett-Packard Account Support # Organization for their help in debugging and improving. # LVMcollect.* scripts from Peter Van Giel in the Hewlett-Packard # Country Response Center Belgium. # capture script from Dave Olker of the Hewlett-Packard Worldwide # Technology Expert Center. # # Most of all I would like to thank the PRODUNIX support team # at Oracle Corp. for allowing me access and time to develop # and test using their systems. # # version="1.50" # ROOT=$PWD # export RESOLV_CONF=/etc/resolv.conf # #script=`basename $0` # script="SysInfo" # typeset PAGER=${PAGER:-more} # typeset -x osmajor # typeset -R4 lcount=0 # number of logical volumes typeset -R4 pcount=0 # number of physical volumes typeset -R4 vgcount=0 # number of volume groups typeset -i total_stale=0 # number of stales extents typeset stale=0 # flag set if stale extents found typeset all_logvols # list of all logical volumes typeset -L18 physvol # name of phyical volume typeset -R14 hwpathd # path information for disk typeset -R10 vendor # vendor id string from disk typeset -R10 product # vendor model number from disk typeset -L4 bootable_pv # is disk bootable? typeset -R6 rev_level # firmware revision code from disk #typeset -R12 kernel_size #\ typeset -i shmem # \ typeset -R8 shmmni # \ typeset -R8 shmmax # \ typeset -R8 shmseg # \ typeset -R8 maxfiles # \ typeset -R8 maxfiles_lim # \ typeset -R8 maxuprc # \ typeset -R8 nproc # \ typeset -R8 fs_async # \ typeset -R8 nfile # kernel parameters typeset -R8 nflocks # typeset -R8 super_page_support # / typeset -R8 dbc_max_pct # / typeset -R8 dbc_min_pct # / typeset -R8 ninode # / typeset -R8 npty # / typeset -R8 nbuf # / typeset -R8 bufpages # / typeset -R8 maxvgs # / typeset SAVECORE # flag set if savecore is enabled typeset COMPRESS=0 # typeset COMPRESSION="N/A" # set if on 10.10 or later typeset Compress_Option="N/A" # enabled in /etc/rc.config.d/savecore typeset -R8 lv_pbuf_cnt # \ typeset -R8 lv_pbuf_inuse # \ typeset -R8 lv_pbuf_maxuse # more kernel parameters typeset -R8 lv_pbuf_pending_Q # for lvm typeset -R8 lv_vgs_opn # / typeset -R8 lv_lvs_opn # / typeset -i psize # physical disk size (in KBytes) typeset -R8 psize_mb # physical disk size (in Mbytes) typeset -R4 lu # physical disk logical unit number typeset -L20 volgroup # typeset -R6 CURLV # typeset -R10 CURPV # typeset -R8 PeSize # typeset -R9 AllocPe # typeset -R8 FreePe # typeset -R8 TotalPe # typeset -R11 AllocMb # typeset -R8 FreeMb # typeset -R8 TotalMb # typeset -R8 TotalAllocMb=0 # total allocated Megabytes typeset -R8 TotalFreeMb=0 # total free Megabytes typeset -R8 SystemTotalMb=0 # total of all Megabytes typeset -R8 MirrorMb=0 # size of mirror typeset -R8 TotalMirrorMb=0 # total size of mirrors typeset -R8 OtherMb=0 # typeset -R8 total_p_mb=0 # total physical Megabytes typeset -R8 total_l_mb=0 # total logical Megabytes typeset -R8 unused_cap=0 # typeset -L4 fs_type # typeset logvol # typeset pvol # typeset -L16 statusout # status of extents (e.g. stale) typeset -R6 LVSize # size of logical volume typeset -R7 LogicalExtents # typeset -R8 StaleExtents # typeset -L35 MOUNT # typeset -R8 MirrorCopies # number of mirrors typeset -R8 Consistency # mirror consistency strategy typeset -i REAL_MEM # memory size (in pages) typeset -i memory # memory size (in MBytes) typeset -i num_cpus # number of active CPUs typeset -i StaleMB=0 # stale Megabytes typeset -i TotalStaleMb=0 # total stale Megabytes typeset -i cpu_speed=0 # clock speed in MHz typeset exit_code=0 # exit code [ 0, 1, 2, 3 ] typeset ERROR=1 # exit condition (program error) typeset WARN=2 # exit condition (system warning) typeset SYS_ERROR=3 # exit condition (system error) typeset SYSTEM=0 # \ typeset FULL_KERNEL=0 # \ typeset LITE_KERNEL=0 # \ typeset FILESYSTEM=0 # \ typeset NETWORK=0 # \ typeset DEBUG=0 # \ typeset SWLIST=0 # \ typeset PHYSICAL=0 # flags set at runtime via typeset LOGICAL=0 # command line options typeset IOSCAN=0 # / typeset -x HTML=0 # / typeset NOPAGER=0 # / typeset VOLUMES=0 # / typeset CAPACITY=0 # / typeset BATCH=0 # / typeset LMAP=0 # / typeset PMAP=0 #/ typeset KernelSafetyFactor=2 # adds two MBytes to kernel size typeset lvm_installed=0 # flag set if lvm present typeset -R6 DumpDiskCapacity=0 # space to hold memory dump typeset -R6 CompressedMemoryDumpSize # typeset -R6 compression_factor # typeset -i MemoryDumpSize # amount of memory (in MBytes) typeset -i TotalMemoryDumpSize # amount of memory + kernel size typeset -R6 MemoryDumpSizeOut # display version of MemoryDumpSize typeset -R6 TotalMemoryDumpSizeOut # display version of TotalMemoryDumpSize typeset -R6 SaveCoreAvail_Out # space to hold savecore # can be compressed on 10.10 and later ############## # variables for io_scan section ############## GREP_ARGS="" GREP_V_ARGS="-eNO_HW" typeset -x ioscan_args="-F" typeset -x io_scan_out=/tmp/sysinfo.$$.io_scan.out typeset -x io_scan_tmp=/tmp/sysinfo.$$.ios_can.tmp typeset -x io_scan_done=/tmp/sysinfo.$$.io_scan_done typeset -x io_scan_command_file=/tmp/sysinfo.$$.io_scan_command_file ############## # variables for lvm_scan section ############## typeset -x vg_list_file=/tmp/sysinfo.$$.vg.list typeset -x vg_out_file=/tmp/sysinfo.$$.vg.out typeset -x lvol_list_file=/tmp/sysinfo.$$.lvol.list typeset -x lvol_out_file=/tmp/sysinfo.$$.lvol.out typeset -x pvol_list_file=/tmp/sysinfo.$$.pvol.list typeset -x pvol_out_file=/tmp/sysinfo.$$.pvol.out typeset -x lvm_scan_command_file=/tmp/sysinfo.$$.lvm_scan_command_file typeset -x lvm_scan_done=/tmp/sysinfo.$$.lvm_scan_done ############## # variables for sam_scan section ############## typeset -x sam_scan_command_file=/tmp/sysinfo.$$.sam_scan_command_file typeset -x sam_scan_done=/tmp/sysinfo.$$.sam_scan_done typeset -x sam_out_file=/tmp/sysinfo.$$.sam.out #typeset -x sam_kinfo=/tmp/sysinfo.$$.kinfo typeset -x sam_kinfo_new=/tmp/sysinfo.$$.kinfo_new ############## # variables for kernel section ############## typeset -x sam_kinfo=${sam_kinfo:-/tmp/sysinfo.$$.sam_kinfo} typeset -x all_parms_file=/tmp/sysinfo.$$.all_parms typeset -x all_classes_file=/tmp/sysinfo.$$.all_classes ALL="TRUE" FORCE="FALSE" TEMPFILE=/var/sam/sam.$$ save_lang=$LANG LANG=C ################################################################################ # Function: DebugOn() # Description: Turns debugging mode on. # Arguments: none # Returns: none DebugOn() { # set -o xtrace export _DEBUG=1 export _DEBUG_FILE=/tmp/sysinfo_${sysname}_`date '+%y%m%d'`_debug #Debug Debug ON: info will be logged to screen and to $_DEBUG_FILE print "\nDebug ON: info will be logged to $_DEBUG_FILE" Debug Debug ON: info will be logged to $_DEBUG_FILE } ################################################################################ # Function: DebugOff() # Description: Turns debugging mode off. # Arguments: none # Returns: none DebugOff() { Debug Debug OFF _DEBUG=0 _DEBUG_FILE=$ROOT/debug.out } ############################################################################### # Function: Debug() # Description: Prints debug statements to stderr when debug mode is on. # Arguments: Text to echo. # Returns: none Debug() { if [ "$_DEBUG" -gt 0 ] then #echo "DEBUG (PID $$): $*" | tee -a $_DEBUG_FILE 1>&2 echo "DEBUG (PID $$): $*" >> $_DEBUG_FILE 2>&1 fi } #-----------------------------------------------------------# # Exit function, called by trapped signals #-----------------------------------------------------------# function _sigexit { # print "Cleaning up, please wait." if (($DEBUG)) && ((!(($NOPAGER)) )) then read answer?"Delete temp files? [Y/n]" if [[ ${answer} = n ]] then print "O.K. Don't forget to delete /tmp/sysinfo.$$.*" print "exit value = ${exit_code}" else print "O.K. I'm deleting temp files /tmp/sysinfo.$$.*" rm -f /tmp/sysinfo.$$.* > /dev/null 2>&1 print "exit_code = ${exit_code}" fi else rm -f /tmp/sysinfo.$$.* > /dev/null 2>&1 fi exit ${exit_code} } trap _sigexit EXIT KILL HUP QUIT INT function usage { cat << EOF | $PAGER ${script} ${version} by Scott Truesdale Usage: ${script} [-afikKlmMnpsSv] [-b|-H|-N] ${script} [-h] -a displays all of the following options. -f checks filesystems for free space. -h displays detailed help message. -i displays io configuration. -k displays brief kernel parameters. -K displays verbose kernel parameters. -l displays logical volume data. -m displays logical to physical disk mapping. -M displays physical to logical disk mapping. -n displays network interface data. -p displays physical disk data. -s displays the system and root disk data. -S displays software listing (swlist). -v displays volume group data. -b send output to a logfile. -H send output to a logfile in HTML format. -N turn off paging in screen mode. Note: disk capacity data is displayed only when using -a or -lpv. EOF } # end of usage function print_help { export MANPATH=${where}:$MANPATH # to debug help -d must come before -h Debug "print_help" Debug " where=${where}" Debug " MANPATH=${MANPATH}" if [[ -f ${where}/man1/sysinfo.1 ]] then man sysinfo exit_code=0 else print "Cannot find man page for ${script}!" print "Expected to find it in ${where}/man1/" exit_code=${ERROR} fi } #=================================================================== # get_args # gets command line arguments passed in at run time #=================================================================== function get_args { if (($# == 0)) then #print "\n$Must specify one or more of the following:$\n" usage exit ${ERROR} fi while getopts :abdfhiklmnpsvHKMNS arguments do case $arguments in a) LITE_KERNEL=1 SYSTEM=1 NETWORK=1 IOSCAN=1 LVMSCAN=1 PHYSICAL=1 VOLUMES=1 LOGICAL=1 FILESYSTEM=1 SWLIST=1 PMAP=1 LMAP=1;; b) BATCH=1 LOGDIR=${SYSINFO_LOGDIR:-"/tmp"} LOGFILE="${LOGDIR}/sysinfo_${sysname}_`date '+%y%m%d'`" # if [[ -f $LOGFILE ]] # then # print -n "Logfile exists...." # read answer?"Overwrite? [Y/n]" # if [[ ${answer} = n ]] # then # print "O.K. Appending to existing logfile" # else # print "O.K. I'm deleting log file" Debug "Removing $LOGFILE" rm -f $LOGFILE > /dev/null 2>&1 # fi # fi ;; d) DEBUG=1 DebugOn;; f) FILESYSTEM=1;; h) print_help exit ${exit_code};; H) HTML=1 BATCH=1 LITE_KERNEL=1 SYSTEM=1 NETWORK=1 PHYSICAL=1 VOLUMES=1 IOSCAN=1 LVMSCAN=1 LOGICAL=1 FILESYSTEM=1 SWLIST=1 PMAP=1 LMAP=1 LOGFILE="/tmp/sysinfo_${sysname}_`date '+%y%m%d'`.html" if [[ -f ${LOGFILE} ]] then rm -f $LOGFILE >> /dev/null 2>&1 Debug "Removing $LOGFILE" fi;; i) IOSCAN=1;; k) LITE_KERNEL=1;; K) FULL_KERNEL=1;; l) LOGICAL=1 LVMSCAN=1;; m) LMAP=1;; M) PHYSICAL=1 PMAP=1;; n) NETWORK=1;; p) PHYSICAL=1;; s) SYSTEM=1;; S) SWLIST=1;; v) VOLUMES=1 LVMSCAN=1;; N) NOPAGER=1;; ?) print "\nI don't understand that option\n" usage exit ${ERROR};; esac if (($PHYSICAL)) && (($VOLUMES)) && (($LOGICAL)) then CAPACITY=1 fi if (($LITE_KERNEL)) && (($FULL_KERNEL)) then LITE_KERNEL=0 fi if (($BATCH)) && (($DEBUG)) then NOPAGER=1 fi done Debug "FLAGS: System=$SYSTEM Batch=$BATCH FullKernel=$FULL_KERNEL" Debug "FLAGS: LiteKernel=$LITE_KERNEL Network=$NETWORK" Debug "FLAGS: Volumes=$VOLUMES Capacity=$CAPACITY Logical=$LOGICAL" Debug "FLAGS: Physical=$PHYSICAL LMapping=$LMAP PMapping=$PMAP" Debug "FLAGS: Filesystem=$FILESYSTEM NoPager=$NOPAGER Html=$HTML" Debug "FLAGS: Ioscan=$IOSCAN lvm_scan=$LVMSCAN Sam_scan=$SAMSCAN" Debug "FLAGS: Swlist=$SWLIST" if (($BATCH)) then print "\nOutput going to ${LOGFILE}" fi } # end of get_args #=================================================================== # f_display_file # this function displays a file to the screen. it takes one parm, # the file to display. It uses the defined PAGER or more if that # variable is not defined. #=================================================================== function f_display_file { if [[ -s $1 ]] then if (($BATCH)) then cat $1 >> $LOGFILE elif (($NOPAGER)) then cat $1 else # not batch so use PAGER $PAGER $1 fi fi } # end of f_display_file ################################################################################ # Function: LookupName() # Description: Lookup the full name for a specified hostname. Uses nslookup. # Arguments: # Output: fully qualified hostname # Returns: 0: successfully determined name # 1: unable to find name (using /etc/hosts) # 2: unable to find name (using name server) LookupName() { # if [ $# -ne 1 ] # then # Panic "${0}: expect argument" # fi #nslookup "$1" > $_TMP 2>&1 # Return 0 if name found, 1 if not found and using /etc/hosts, # 2 if not found and using some sort of name server. # nslookup "$1" 2>&1 | awk ' BEGIN { ret_val=2 } $0 ~ "/etc/hosts" { ret_val=1 } $1 == "Name:" { print $2; ret_val=0 } END { exit (ret_val) } ' $_TMP return_value=$? case $return_value in 0) return_string="found using nslookup";; 1) return_string="found in /etc/hosts/";; 2) return_string="not found";; esac Debug " return from LookupName = $return_value ($return_string)" return $return_value } ################################################################################ # GetCurrentDNS() GetCurrentDNS() { if [ -f $RESOLV_CONF ] then # Extract the domain, address and name of nameserver set -- $(awk ' $1 == "domain" { DOMAIN=$2 } $1 == "nameserver" { ADDRESS=$2 ; exit } END { printf "%s %s\n", DOMAIN, ADDRESS }' $RESOLV_CONF) if [ $# -eq 2 ] then # See if we can get a name for the nameserver CURRENT_DOMAIN="$1" CURRENT_DNS_SERVER_IP="$2" CURRENT_DNS_SERVER=$(LookupName $CURRENT_DNS_SERVER_IP) if [ -z "$CURRENT_DNS_SERVER" ] then CURRENT_DNS_SERVER=unknown fi else unset CURRENT_DOMAIN CURRENT_DNS_SERVER_IP CURRENT_DNS_SERVER fi fi } #=================================================================== # weed_targets # # Scan the output from ioscan and filter out all SCSI "target" # lines. Also filter out entries with a low_level driver of "root" #=================================================================== weed_targets() { awk -F: ' { class = $9; low_level_driver = $10 if (class != "target" && low_level_driver != "root") print $0 }' - } #================================================================== # This routine invokes ioscan with any passed in arguments and # generates the above mentioned colon separated output. Note that # all lines begin and end with colons. This makes for easy parsing # of the output to match specific fields via grep. #=================================================================== formatter() { awk -F: ' { #===================================================================== # Not all of the fields of ioscan output are used by SAM. # They are all listed here for documentation purposes. #===================================================================== # bus_type = $1 cdio = $2 # is_block = $3 # is_char = $4 # is_pseduo = $5 # block_major_number = $6 # character_major_number = $7 # minor_number = $8 class = $9 # low_level_driver = $10 full_hw = $11 identify_bytes = $12 # device instance = $13 # module_path = $14 driver = $15 sw_status = $16 # hardware_type = $17 ident = $18 instance = $19 num_hw = split(full_hw, hw_path, "."); address = ""; unit = ""; #============================================================ # # Identifying bytes for PA Modules contain this information: # # Byte # Address Name Description # --------- --------------- -------------------------------------- # 0-1 IODC_HVERSION Hardware version number # 2 IODC_SPA Soft physical address capability # 3 IODC_TYPE Type of module # 4-7 IODC_SVERSION Software version number # 8 IODC_REV IODC revision # 9 IODV_DEP HVERSION dependent # 10-11 RESERVED # 12-13 IODC_CHECK Checksum # 14-15 IODC_LENGTH Length of entry point table # #============================================================ split(identify_bytes, id_flds, " "); hversion= (((((id_flds[1]*256)+id_flds[2])*256)+id_flds[3])*256)+id_flds[4]; sversion= (((((id_flds[5]*256)+id_flds[6])*256)+id_flds[7])*256)+id_flds[8]; if ( id_flds[9] != "" ) { device_id = id_flds[9] " " id_flds[10] " " id_flds[11] " " id_flds[12] " " id_flds[13] " " id_flds[14] " " id_flds[15] " " id_flds[16]; } else { device_id = ""; } # # Specifically for multi path environments (FiberChannel), # save the driver and last 8 bytes of the identify_bytes # of this device ("ext_bus" class; parent of actual devices) # tacking on to actual devices later. # if ( class == "ext_bus") { if ( ( identify_bytes != "") && (( driver == "fcpmux") || ( driver == "fcpdev"))) { parent_driver = driver; parent_id = device_id; } else { parent_driver="" parent_id="" } } # # Set driver to "?" if not known # if ((substr(driver, 1, 1) == "?") || (driver == "pdn0") || (driver == "")) { # # SPECIAL CASES FOR NON-AUTOCONFIGURABLE DEVICES # Check the hardware identifier field, if it matches # a non-autoconfigurable device and there is no driver # bound to the device, fill in the driver field with the # appropriate driver name flag to true # # # Change this to use the device description. # if (ident == "0x2080") { driver = "pdn0"; } # # Change this to use the device description. # else if (ident == "0x2f80") { driver = "pdn0"; } else if ((substr(driver, 1, 1) == "?") || (driver == "")) { driver = "?"; } not_configured = 1; } else not_configured = 0; if (sw_status != "CLAIMED") not_configured = 1; if ((driver == "tape1") || (driver == "tape2") || (driver == "lpr0") || (driver == "lpr1") || (driver == "disc3") || (driver == "sflop") || (driver == "schgr") || (driver == "autox0") || (driver == "cs80") || (driver == "sdisk") || (driver == "stape") || (driver == "disc4")) { address = hw_path[num_hw-1]; unit = hw_path[num_hw]; } else if ((driver == "disc1") || (driver == "disc2") || (driver == "instr0")|| (driver == "pflop")) { address = hw_path[num_hw]; } # printf(":%s:%s:%s:%s:%s:%s:%d:%s:0x%x;0x%x:%s:%s:%s:%s:\n", # cdio, driver, instance, full_hw, address, unit, # not_configured, sw_status, sversion, hversion, ident, # device_id, parent_driver, parent_id ); printf("%14s %12s %s\n", full_hw, driver, ident ); }' - } # end of formatter #=========================================================== # lvm_scan #=========================================================== function lvm_scan { # first get all volume groups, logical volumes & physical volumes vgdisplay -v | \ awk ' BEGIN { vgprinted = ""; onpvg = ""; numpvgs = 0 } /^VG Name/ { vg = substr($3, 6, length($3) - 5); vgprinted = ""; onpvg = ""; numpvgs = 0; freepe_count = 0; next; } /VG Write Access/ { vgwrite = $4; next; } /VG Status/ { vgstatus = ""; for(i=3;i<=NF;i++) vgstatus = vgstatus $i; vgstatus = vgstatus "," vgwrite "@"; next; } $2 == "Server" { vgstatus = vgstatus $1; next; } $2 == "Client" { vgstatus = vgstatus ","; vgstatus = vgstatus $1; next; } /Max LV/ { maxlv = $3; next; } /Max PV/ { maxpv = $3; next; } /Cur LV/ { numlvs = $3; next; } /Cur PV/ { numpvs = $3; next; } /PE Size/ { pesize = $4; next; } /Max PE per PV/ { maxpe = $5; next; } /Total PVG/ { numpvgs = $3; next; } /LV Name/ { if (vgprinted == "") { printf("VG:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s::::::\n", vg, vgstatus, maxlv, maxpv, numlvs, numpvs, numpvgs, pesize, maxpe, totalpe * pesize, freepe * pesize); vgprinted = "y"; } printf("LV:%s:::::::%s::::%s:::::\n", vg, pesize, $3); next; } /Alternate Link$/ { if (onpvg == "") { if (vgprinted == "") { printf("VG:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s::::::\n", vg, vgstatus, maxlv, maxpv, numlvs, numpvs, numpvgs, pesize, maxpe, totalpe * pesize, freepe * pesize); vgprinted = "y"; } printf("ALT:%s::::::::::::%s:%s:::\n", vg, pv, $3); } next; } /PV Name/ { pv = $3; if (onpvg == "") { if (vgprinted == "") { printf("VG:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s::::::\n", vg, vgstatus, maxlv, maxpv, numlvs, numpvs, numpvgs, pesize, maxpe, totalpe * pesize, freepe * pesize); vgprinted = "y"; } } else { printf("PV:%s::::::::::::%s::::%s\n",vg, pv, pvg); pvg = ""; } next; } /Free PE/ { freepe = $3; if (freepe_count > 0) { printf("PV:%s::::::::::::%s::%s:%s:\n", vg, pv, totalpe, freepe); } freepe_count ++; next; } ' >> /tmp/sysinfo.vg.tmp mv /tmp/sysinfo.vg.tmp $vg_list_file # # now get list of all logical volumes # awk ' BEGIN { FS = ":" } { type = $1; vgstatus = $2; pesize = $8; if (type == "LV") { printf ("%s\n",$13) } } ' $vg_list_file >> /tmp/sysinfo.lvol.list.tmp sort /tmp/sysinfo.lvol.list.tmp > $lvol_list_file rm -f /tmp/sysinfo.lvol.list.tmp # # now get details on each logical volume # lvol_list=$(cat $lvol_list_file) for lvol in $lvol_list do lvdisplay $lvol | \ awk ' BEGIN { mwc = 0; nummir = 0; mircon = 0; bbr = 0; conalloc = 0 ; numstripes = 0; stripesize = 0 } /LV Name/ { lvname= $3; next } /LV Permission/ { perm = $3; next } /Mirror copies/ { nummir = $3; next } /Consistency Recovery/ { mwc = $3; next } /Schedule/ { sched = $2; next } /LV Size/ { size = $4; next } /Current LE/ { les = $3; next } /Bad block/ { if ($3 == "on") bbr = 1; next } /Allocation/ { split($2, alloc, "/"); mpol = alloc[1]; if (alloc[2] == "contiguous") conalloc = 1; next; } /LV Status/ { state = $3; next } /Stripes/ { numstripes = $2; next } /Stripe Size/ { stripesize = $4; next } {next} END { if ( size == 0 ) { pesize = size; } else { pesize = size / les; } printf("%-32s %6s %4s %4s %4s %6s %16s\n", lvname, size, numstripes, stripesize, nummir, mwc, state) } ' >> /tmp/sysinfo.lvol.data.tmp done mv /tmp/sysinfo.lvol.data.tmp $lvol_out_file rm -f /tmp/sysinfo.lvol.data.tmp # # now get list of all physical volumes # awk ' BEGIN { FS = ":" } { type = $1; vgstatus = $2; pesize = $8; if (type == "PV") { printf ("%s\n",$14) } } ' $vg_list_file >> /tmp/sysinfo.pvol.list.tmp sort /tmp/sysinfo.pvol.list.tmp > $pvol_list_file rm -f /tmp/sysinfo.pvol.list.tmp # # now get details on each physical volume # pvol_list=$(cat $pvol_list_file) for pvol in $pvol_list do pvdisplay -v $pvol | \ awk ' BEGIN {found=0} /PE Size/ {pesize = $4; next} /LV Name/ {found=1; next} /Physical extents/ {exit 0} # # Print "LV_Name Logical_MB_of_LV Physical_MB_of_LV" # { if (found && NF == 3) printf("%s:%d:%d\n", $1, $2 * pesize, $3 * pesize) } ' - >> $pvol_out_file done } # end of lvm_scan #=========================================================== function launch_lvm_scan #=========================================================== { Debug "Building $lvm_scan_command_file" # change filenames to send output to parent's PID # typeset -x vg_out_file=/tmp/sysinfo.$$.vg.out # typeset -x vg_list_file=/tmp/sysinfo.$$.vg.list # typeset -x lvol_list_file=/tmp/sysinfo.$$.lvol.list # typeset -x lvol_out_file=/tmp/sysinfo.$$.lvol.out # typeset -x pvol_list_file=/tmp/sysinfo.$$.pvol.list # typeset -x pvol_out_file=/tmp/sysinfo.$$.pvol.out # typeset -x lvm_scan_done=/tmp/sysinfo.$$.lvm_scan_done rm -f $lvm_scan_done Debug "$vg_out_file, $vg_list_file, $lvol_out_file" Debug "$lvol_list_file, $pvol_list_file $pvol_out_file" Debug "$lvm_scan_done" cat <<==end_of_command== > $lvm_scan_command_file # now call the lvm_scan function (exported from parent) lvm_scan date > \$lvm_scan_done ==end_of_command== chmod +x $lvm_scan_command_file Debug " launching $lvm_scan_command_file" $lvm_scan_command_file & Debug " parent PID = $$, child PID = $!" } # end of launch_lvm_scan #=========================================================== # launch_kernel_scan #=========================================================== function launch_kernel_scan { Debug " Starting launch_kernel_scan.....building $kernel_scan_command_file" # change filenames to send output to parent's PID rm -f $kernel_scan_done Debug "$kernel_kinfo $kernel_out_file" Debug "$kernel_scan_done" cat <<==end_of_command== > $kernel_scan_command_file # now call the sam_scan function (exported from parent) kernel_scan date > \$kernel_scan_done ==end_of_command== chmod +x $kernel_scan_command_file Debug " launching $kernel_scan_command_file" $kernel_scan_command_file & Debug " parent PID = $$, child PID = $!" } # end of launch_kernel_scan #=========================================================== # launch_io_scan #=========================================================== function launch_io_scan { Debug " Starting launch_io_scan.....building $io_scan_command_file" # change filenames to send output to parent's PID rm -f $io_scan_done Debug "$io_scan_done" if (( ${osmajor} >= 10 )) then cat <<==end_of_command== > $io_scan_command_file # now call the io_scan function (exported from parent) io_scan date > \$io_scan_done ==end_of_command== chmod +x $io_scan_command_file Debug " launching $io_scan_command_file" $io_scan_command_file & Debug " parent PID = $$, child PID = $!" else Debug " on 9.x - executing ioscan" print "H/W Path LU Driver" >> ${io_scan_out} print -- "-----------------------------" >> ${io_scan_out} ioscan -f | tail +3 | \ awk '{printf ("%-14s %-6s %-20s\n", $3, $2, $4)}' \ >> ${io_scan_out} date > $io_scan_done fi } # end of launch_io_scan #=========================================================== # check_if_scan_done #=========================================================== function check_if_scan_done { scan_type=$1 done_file=/tmp/sysinfo.$$.${scan_type}_done Debug " starting check_if_scan_done for ${scan_type}." Debug " looking for /tmp/sysinfo.$$.${scan_type}_done" if (($BATCH)) then print -n "retrieving ${scan_type} data " fi if [ ! -f ${done_file} ] # enter time out loop then Debug " ${scan_type}_done file not ready, entering loop." FORCE="TRUE" for fil in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 do sleep 1 Debug " in loop $fil" if (($BATCH)) then print -n "." fi if [ -f ${done_file} ] then Debug " ${scan_type} done." FORCE="FALSE" break fi done if [ "$FORCE" = "TRUE" ] then Debug " still no file, forcing an interactive ${scan_type}." ${scan_type} fi else Debug " found ${scan_type}_done file" if (($BATCH)) then print "" fi fi } #=========================================================== # io_scan # # this routine runs ioscan with the appropriate parameters and # places the output in /var/sam/.iout It also # provides a semaphore for other asyncronous processes, by removing # and then creating /var/sam/.dion # #=========================================================== function io_scan { # bus_type = $1 # cdio = $2 # is_block = $3 # is_char = $4 # is_pseduo = $5 # block_major_number = $6 # character_major_number = $7 # minor_number = $8 # class = $9 # low_level_driver = $10 # full_hw = $11 # identify_bytes = $12 # device instance = $13 # module_path = $14 # driver = $15 # sw_status = $16 # hardware_type = $17 # ident = $18 # instance = $19 # # If an inadaquate description is given from ioscan. Initiate a diskinfo # request to force an open operation and then perform another ioscan for # that device. If the diskinfo operation results in an error containing # "Permission Denied" the device may be a tape drive needing a slightly # different device file. At the time of this modification to this script # (7/5/94) an HPFL Disc will only give a useful description when there is # a mounted file system on the disk. # # Change the Internal Field Separator to ":". All output fields of # ioscan -F are separated by a ":". # LANG=$save_lang LANG=C rm -f $io_scan_done ioscan $ioscan_args > $io_scan_tmp mv $io_scan_out $io_scan_out.old > /dev/null 2>&1 ifs_save=$IFS IFS=: cat $io_scan_tmp | \ while read p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 do if [ "$p18" = "HP-IB Device" -o "$p18" = "HP-IB Tape" -o \ "$p18" = "SCSI Tape" -o "$p18" = "HPFL Disc" ] then mksf -r -H $p11 /var/sam/sam_tmp >/dev/null 2>&1 diskinfo /var/sam/sam_tmp >/dev/null 2>/var/sam/sam_err if ( grep Permission /var/sam/sam_err >/dev/null 2>&1 ) then mksf -r -c -u 0 -H $p11 /var/sam/sam_tmp >/dev/null 2>&1 diskinfo /var/sam/sam_tmp >/dev/null 2>&1 fi ioscan -H $p11 -F >>$io_scan_out 2>/dev/null rm -f /var/sam/sam_tmp /var/sam/sam_err else echo "$p1:$p2:$p3:$p4:$p5:$p6:$p7:$p8:$p9:$p10:$p11:$p12:$p13:$p14:$p15:$p16:$p17:$p18:$p19" >>$io_scan_out fi done IFS=$ifs_save date > $io_scan_done rm $io_scan_tmp } #end of io_scan #================================================================== # sw_scan #================================================================== function sw_scan { Debug "Beginning SW_SCAN" if [[ -f /usr/sbin/swlist ]] then Debug " found swlist" if (($HTML)) then print "" >> /tmp/sysinfo.$$.swout print "" >> /tmp/sysinfo.$$.swout print "

" >> /tmp/sysinfo.$$.swout print "

TOP

" >> /tmp/sysinfo.$$.swout print "" >> /tmp/sysinfo.$$.swout print "Software Data

" >> /tmp/sysinfo.$$.swout print "
"  >> /tmp/sysinfo.$$.swout
    else
      print "" >> /tmp/sysinfo.$$.swout
      print "SOFTWARE DATA" >> /tmp/sysinfo.$$.swout
      print "=============" >> /tmp/sysinfo.$$.swout
    fi
  if (($BATCH))
  then
    print  "collecting software data "
  fi
    print    "Product                Version         Description" >> /tmp/sysinfo.$$.swout
    print -- "--------------------------------------------------" >> /tmp/sysinfo.$$.swout
    swlist -l product | grep -v "^#" >> /tmp/sysinfo.$$.swout
    f_display_file /tmp/sysinfo.$$.swout
  else
  Debug " could not find swlist."
  fi
}

#==================================================================
#f_get_sys_type
#        This function retrieves the os version information and
#        series type. It then sets the kernel pointers.
#===================================================================
function f_get_sys_type
{
  Debug "Beginning GET SYSTEM TYPE"
  osletter=$(uname -r | awk -F. '{print $1}')
  osmajor=$(uname -r | awk -F. '{print $2}')
  osminor=$(uname -r | awk -F. '{print $3}')
  system=$(uname -m | awk -F/ '{print $1}')
  series=$(uname -m | awk -F/ '{print $2}')
  machine_id=$(uname -i)
  license=$(uname -l)
  Debug "  `uname -a`"
  Debug "  system = $system"
  Debug "  series = $series"
  Debug "  OS = $osletter.$osmajor.$osminor"
  Debug "  machine = $machine_id"
  Debug "  license = $license"
  if (( `echo $series | cut -b1` == 7 )) && (( $osmajor <= 9 ))
  then
    print "\nSorry. Not supported on Series 700 running HP-UX 9.x\n"
    exit ${ERROR}
  fi
  if [[ ! -z $(whence model) ]]
  then
    series=`model`
    Debug "  model returned $series"
  else
    Debug "  model not found, using inline series check"
    case $series in
      780) series="780/C160";;
      801) series="801/DX0";;
      811) series="811/DX5";;
      806) series="806/E25";;
      807) series="807/F10";;
      809) series="809/K100";;
      816) series="816/E35";;
      817) series="817/F20";;
      819) series="819/K200";;
      821) series="821/D200/D400";;
      826) series="826/E45";;
      827) series="827/H20";;
      829) series="829/K400";;
      831) series="831/D200/D400";;
      837) series="837/F30";;
      839) series="839/K210";;
      841) series="841/D210/D410";;
      847) series="847/G30/H30";;
      851) series="851/D210/D410";;
      849) series="849/K410";;
      856) series="856/E55";;
      857) series="857/I30";;
      859) series="859/K220";;
      867) series="867/G40/H40";;
      869) series="869/K420";;
      877) series="877/I40";;
      887) series="887/G50/H50/G60/H60/G70/H70";;
      890) series="890";;
      891) series="891/T500";;
      892) series="892/T520";;
      897) series="897/I50/I60/I70";;
        *) series=$series
             Debug "Series type not found for $series" ;;
    esac
  fi
  if [ $osmajor -lt 10 ]
  then
    kernel=/hp-ux
  else
    kernel=/stand/vmunix
  fi
  Debug "  kernel=${kernel}"
  if [[ -f /etc/lvmtab ]]
  then
    lvm_installed=1
    Debug "  LVM Detected."
  else
    lvm_installed=0
    Debug "  LVM NOT Detected."
  fi
# set PATH variable to ensure access to required commands
  for i in \
    /etc \
    /usr/sbin \
    /bin \
  ; 
  do
    if [ -d $i ]
    then
      PATH=$PATH:$i
    fi
  done
  export PATH
  Debug "  PATH = $PATH"
  if [ -f ${where}/system_db ]
  then
    conf_file=${where}/system_db
  elif [ -f /usr/local/bin/system_db ]
  then
    conf_file=/usr/local/bin/system_db
  fi
  if [[ -n ${conf_file} ]]
  then
    Debug "  Found config file = $conf_file"
    serial_number=$(grep $sysname $conf_file | awk -F: '{print $4}')
    Debug "    serial number = ${serial_number}"
  fi
  swap_devs=$(swapinfo -d | grep -v "Kb" |grep -v "TYPE" \
         | awk '{printf "%s ", $NF}')
# if (($FULL_KERNEL)) || (( ${LITE_KERNEL} ))
# then
#   if (( ${osmajor} >= 10 ))
#     rm -f $kernel_scan_done
#     launch_kernel_scan
#     Debug "Calling kernel_scan"
#     if (($BATCH))
#     then
#       print "launching background kernel scan"
#     fi
#   fi
# fi
  if (($IOSCAN)) || (($PHYSICAL))
  then
    rm -f $io_scan_done
    launch_io_scan $ioscan_args
    Debug "Calling io_scan"
    if (($BATCH))
    then
      print "launching background ioscan"
    fi
  fi
  if (($LVMSCAN))
  then
    rm -f $lvm_scan_done
    launch_lvm_scan
    Debug "Calling launch_lvm_scan"
    if (($BATCH))
    then
      print "launching background lvm scan"
    fi
  fi
}                # end of f_get_sys_type

#===================================================================
# f_get_system_data
#        This function retrieves various system  and boot data.
#        e.g. amount of memory, number of cpus, etc.
#        It also checks to see if memory dumping is properly
#        configured.
#===================================================================
function f_get_system_data
{
  Debug "Beginning SYSTEM/ROOT check."
  if (($BATCH))
  then
    print -n "collecting system data "
  fi
  # Determine cpu speed in MHz
  cpu_speed=$(echo itick_per_tick/D | adb $kernel /dev/kmem | tail -1 \
          | awk '{print $2 / 10000}')
  # Determine the memory size.
  # Real memory expressed in units of pages (4 kbytes per page).
  if [ ${osmajor} -eq 11 ]
  then
  REAL_MEM=$(echo 'phys_mem_pages/D'| adb $kernel /dev/kmem | tail -1 \
             | awk '{print $2}')
  MemoryDumpSize=$(expr ${REAL_MEM} / 256)
  else
  dumppages=$(echo 'dumpsize/D'| adb $kernel /dev/kmem | tail -1 \
              | awk '{print $2}')
  MemoryDumpSize=$(expr ${dumppages} / 256)
  REAL_MEM=$(echo 'physmem/D'| adb $kernel /dev/kmem | tail -1 \
             | awk '{print $2}')
  fi
  memory=$(expr ${REAL_MEM} / 256)
  if (($BATCH))
  then
    print -n "."
  fi
  # determine number of active processors (cpus)
  processor_count=$(echo 'processor_count/D' | adb $kernel /dev/kmem \
                    | tail -1 | awk '{print $2}')
  boot_time=$(who -b | awk '{printf "%s %s %s ", $4, $5, $6}')
  if [ -d /system ]
  then
    last_patch=$(ls -lt /system/ | egrep 'PHNE|PHCO|PHKL' | head -1 \
        | awk '{ print $6,$7,$8}')
  else
    last_patch="unknown"
  fi
  if (($BATCH))
  then
    print -n "."
  fi
  if (($BATCH))
  then
    print -n "."
  fi
  lvlnboot -v /dev/vg00 > /tmp/sysinfo.$$.root 2>&1
  rootboot=$(grep "Boot Disk" /tmp/sysinfo.$$.root \
             | awk '{printf "%s  ", $1}')
  rootroot=$(grep "^Root:" /tmp/sysinfo.$$.root \
             | awk '{print $2,$4}')
  rootswap=$(grep "^Swap:" /tmp/sysinfo.$$.root \
             | awk '{print $2,$4}')
  rootdump=$(grep "^Dump:" /tmp/sysinfo.$$.root \
             | awk '{printf  "%s ",$2}')
  if (($BATCH))
  then
    print -n "."
  fi

  kernel_size=$(ll ${kernel} | awk '{print $5}' 2>&1)
# gather memory dump parms
  (( KernelSizeMb=`ll ${kernel} | awk '{print $5}'` / 1024 / 1024 + 1 ))
  if (( $osmajor < 10 ))
  then                                        
    # it is a 9.x system
    if [[ $(grep "dumps" /etc/conf/gen/S800*) = *default* ]]
    then
      DumpDiskCapacity=$(swapinfo -mat | grep dev | head -1 | awk '{print $2}')
      rootdump="default"
      Debug "  9.x system. default found in S800."
      Debug "  rootdump=${rootdump}"
    else
      Debug "  9.x system. default not found in S800. using rootdump"
      for logvol in ${rootdump}
      do
        DumpSize=$(lvdisplay /dev/vg00/${logvol} | grep "LV Size" \
                   | awk '{print $4}')
        ((DumpDiskCapacity = DumpDiskCapacity + DumpSize))
      done
    fi
    SAVECORE=0
    grep "/etc/savecore" /etc/rc > /dev/null 2>&1
    if ((! ($?) ))
    then
      SAVECORE=1
    fi
    SAVECORE_DIR=$(grep "/etc/savecore" /etc/rc | tail -1 | awk '{print $NF}')

  elif  (( $osmajor == 11 ))
  then
    # 11.x system
    Debug "  11.x system."
    if [ -f /etc/rc.config.d/savecrash ] 
    then
      . /etc/rc.config.d/savecrash
      # check if SAVECRASH is set
      if [[ ! -z $SAVECRASH ]]
      then
      case ${COMPRESS} in
        0) Compress_Option="Turned off. ";;
        1) Compress_Option="Turned on. ";;
        2) Compress_Option="Don't care (default). ";;
        *) Compress_Option="N/A";;
      esac
      SAVECORE=$SAVECRASH
      SAVECORE_DIR=$SAVECRASH_DIR
      Debug "  found /etc/rc.config.d/savecrash with following parms:"
      Debug "    SAVECORE=$SAVECRASH"
      Debug "    SAVECORE_DIR=$SAVECRASH_DIR"
      Debug "    CHUNK_SIZE=$CHUNK_SIZE"
      Debug "    COMPRESS=$COMPRESS"
      Debug "    MIN_FREE=$MIN_FREE"
      Debug "    SWAP_LEVEL=$SWAP_LEVEL"
      Debug "    FOREGRD=$FOREGRD"
      Debug "    SAVE_PART=$SAVE_PART"
      Debug "    LOG_ONLY=$LOG_ONLY"
      else
      Debug "  SAVECRASH is DISABLED"
      SAVECORE=0
      fi
    else
      Debug "  could not find /etc/rc.config.d/savecrash"
      print "ERROR ${sysname}:/etc/rc.config.d/savecrash defaults file MISSING"
  fi
  else  
    # must be a 10.x system
    Debug "  10.x system."
    if [ -f /etc/rc.config.d/savecore ] 
    then
      . /etc/rc.config.d/savecore
      case ${COMPRESS} in
        0) Compress_Option="Turned off. ";;
        1) Compress_Option="Turned on. ";;
        2) Compress_Option="Don't care (default). ";;
        *) Compress_Option="N/A";;
      esac
      Debug "  found /etc/rc.config.d/savecore with following parms:"
      Debug "    SAVECORE=$SAVECORE"
      Debug "    SAVECORE_DIR=$SAVECORE_DIR"
      Debug "    CHUNK_SIZE=$CHUNK_SIZE"
      Debug "    COMPRESS=$COMPRESS"
      Debug "    MIN_FREE=$MIN_FREE"
      Debug "    SWAP_LEVEL=$SWAP_LEVEL"
      Debug "    FOREGRD=$FOREGRD"
    else
      Debug "  could not find /etc/rc.config.d/savecore"
      print "ERROR: ${sysname}:/etc/rc.config.d/savecore defaults file MISSING"
    fi

    if (($lvm_installed))
    then
      Debug "Checking for dump space"
      Debug "  rootdump = ${rootdump}"
      for logvol in ${rootdump}
      do
        DumpSize=$(lvdisplay /dev/vg00/${logvol} | grep "LV Size" \
                   | awk '{print $4}')
        Debug "    /dev/vg00/${logvol} DumpSize = ${DumpSize}"
        ((DumpDiskCapacity = DumpDiskCapacity + DumpSize))
      done
        Debug "  DumpDiskCapacity =${DumpDiskCapacity}"
    fi
  fi
  Debug "Checking how much to dump"
  # add kernel size to memory plus 2Mb safety factor
  ((TotalMemoryDumpSize = MemoryDumpSize + KernelSizeMb + KernelSafetyFactor))
  Debug "  REAL_MEM = $REAL_MEM"
  Debug "  memory =               $memory"
  Debug "  KernelSizeMb =           $KernelSizeMb"
  Debug "  KernelSafetyFactor =     $KernelSafetyFactor"
  Debug "                     ---------"
  Debug "  TotalMemoryDumpSize =  $TotalMemoryDumpSize"

  if (($BATCH))
  then
    print -n "."
  fi
  # now check to see if everything is okay.
  if ((DumpDiskCapacity < TotalMemoryDumpSize))
  then
    if ((! (($exit_code)) ))
    then
      exit_code=${WARN}
    fi
    print "WARNING (${sysname}): Dump space is underconfigured!" >> /tmp/sysinfo.$$.dumpwarn
  fi
  if [ ! ${SAVECORE} ]
  then 
    if ((! (($exit_code)) ))
    then
      exit_code=${WARN}
    fi
    if ((! (($exit_code)) ))
    then
      exit_code=${WARN}
    fi
    print "WARNING (${sysname}): Savecore is not enabled!" >> /tmp/sysinfo.$$.dumpwarn
  fi

  # Now check if enough disk space exists to hold savecore
  Debug "Checking for sufficient savecore space"
  COMPRESSION="Not Applicable"
  if [[ -d $SAVECORE_DIR ]] 
  then
    SaveCoreAvail=$(bdf $SAVECORE_DIR | grep /dev/ | awk '{print $4}')
    ((SaveCoreAvail = SaveCoreAvail / 1024))
    Debug "  SAVECORE=$SAVECORE"
    Debug "  SAVECORE_DIR=$SAVECORE_DIR" 
    Debug "  SaveCoreAvail=$SaveCoreAvail" 
  else
    SaveCoreAvail=0
    if ((! (($exit_code)) ))
    then
      exit_code=${WARN}
    fi
    print "WARNING (${sysname}): Directory $SAVECORE_DIR does not exist!" >> /tmp/sysinfo.$$.dumpwarn
  fi
    if (($osmajor == 10))  && (($osminor >= 10))
    then
      Debug "  Checking for savecore compression"
      Debug "    Compress_option=$Compress_Option"
      COMPRESSION="Available"
      Debug "    Compression=$COMPRESSION"
      compression_factor=${compression_factor:-50}
      Debug "    compression_factor=$compression_factor"
      ((MemoryCompression = (TotalMemoryDumpSize * $compression_factor) / 100 ))
      ((CompressedMemoryDumpSize = TotalMemoryDumpSize - MemoryCompression))
      Debug "    CompressedMemoryDumpSize after = $CompressedMemoryDumpSize"
      if (( $CompressedMemoryDumpSize  > $SaveCoreAvail ))
      then
        if ((! (($exit_code)) ))
        then
          exit_code=${WARN}
        fi
        print "WARNING (${sysname}): Insufficient file space to hold savecore!" >> /tmp/sysinfo.$$.dumpwarn
      fi
    else
      if (( $TotalMemoryDumpSize  > $SaveCoreAvail ))
      then
        if ((! (($exit_code)) ))
        then
          exit_code=${WARN}
        fi
        print "WARNING (${sysname}): Insufficient file space to hold savecore!" >> /tmp/sysinfo.$$.dumpwarn
      fi
    fi
  SaveCoreAvail_Out=$SaveCoreAvail
  if (($SAVECORE))
  then
    SAVECORE=Enabled
  else
    SAVECORE=Disabled
  fi

  TotalMemoryDumpSizeOut=$TotalMemoryDumpSize

# now let's print it.
  if (($HTML))
  then
    print "
" >> /tmp/sysinfo.$$.sysout print "" >> /tmp/sysinfo.$$.sysout print "

" >> /tmp/sysinfo.$$.sysout print "" >> /tmp/sysinfo.$$.sysout print "System Data" >> /tmp/sysinfo.$$.sysout print "

" >> /tmp/sysinfo.$$.sysout print "
" >> /tmp/sysinfo.$$.sysout
  else
    print "" >> /tmp/sysinfo.$$.sysout
    print "SYSTEM DATA" >> /tmp/sysinfo.$$.sysout
    print "===========" >> /tmp/sysinfo.$$.sysout
  fi
  print "HOSTNAME:      ${sysname}" >> /tmp/sysinfo.$$.sysout
  print "SYSTEM:        ${system}" >> /tmp/sysinfo.$$.sysout
  print "MODEL:         ${series}" >> /tmp/sysinfo.$$.sysout
  if [[ -n ${serial_number} ]]
  then
    print "SERIAL #:      ${serial_number}" >> /tmp/sysinfo.$$.sysout
  fi
  print "SYSTEM ID:     ${machine_id}" >> /tmp/sysinfo.$$.sysout
  print "CPU SPEED:     ${cpu_speed} MHz" >> /tmp/sysinfo.$$.sysout
  print "CPUS:          ${processor_count} active processor(s) " >> /tmp/sysinfo.$$.sysout
  print "MEMORY:        ${memory} Mbytes of memory." >> /tmp/sysinfo.$$.sysout
  print "HP-UX VERSION: ${osletter}.${osmajor}.${osminor}" >> /tmp/sysinfo.$$.sysout
  print "USER LICENSE:  ${license}" >> /tmp/sysinfo.$$.sysout
  print "LAST BOOT:     ${boot_time}" >> /tmp/sysinfo.$$.sysout
  print "LAST PATCH:    ${last_patch}\n" >> /tmp/sysinfo.$$.sysout
  print "" >> /tmp/sysinfo.$$.sysout
  print "SWAP DATA" >> /tmp/sysinfo.$$.sysout
  print "=========" >> /tmp/sysinfo.$$.sysout
  if (( $osmajor >= 10 ))
  then
    Debug "`swapinfo -dtfnrMa`"
  else
    Debug "`swapinfo -dtfa`"
  fi
# print "Devices" >> /tmp/sysinfo.$$.sysout
  swapinfo -m | grep dev | \
      awk '{printf "%6s MB on %s\n",$2,$9}' >> /tmp/sysinfo.$$.sysout
# print "Filesystems" >> /tmp/sysinfo.$$.sysout
  swapinfo -m | grep fs | \
      awk '{printf "%6s MB on %s\n",$2,$9}' >> /tmp/sysinfo.$$.sysout
  swapinfo -m | grep memory | \
      awk '{printf "%6s MB on memory\n",$2}' >> /tmp/sysinfo.$$.sysout
  print -- "  ----" >> /tmp/sysinfo.$$.sysout
  if (( $osmajor >= 10 ))
  then
    swapinfo -mdfMt | grep total | \
        awk '{printf "%6s MB Total \n",$2}' >> /tmp/sysinfo.$$.sysout
  else
    swapinfo -mdft | grep tot | \
        awk '{printf "%6s MB Total \n",$2}' >> /tmp/sysinfo.$$.sysout
  fi
  print "" >> /tmp/sysinfo.$$.sysout
  print "DUMP DISKS"            >> /tmp/sysinfo.$$.sysout
  print "=========="            >> /tmp/sysinfo.$$.sysout
  lvlnboot -v /dev/vg00 2>&1 | grep Dump | awk '{print "  "$0}' >> /tmp/sysinfo.$$.sysout 
  print "" >> /tmp/sysinfo.$$.sysout
  print "DUMP DATA" >> /tmp/sysinfo.$$.sysout
  print "=========" >> /tmp/sysinfo.$$.sysout
  print "SAVECORE:                  ${SAVECORE}" >> /tmp/sysinfo.$$.sysout
  print "SAVECORE DIR:              ${SAVECORE_DIR}" >> /tmp/sysinfo.$$.sysout
  if (($osmajor == 10))  && (($osminor >= 10))
  then
    print "SAVECORE COMPRESSION:      ${COMPRESSION}" >> /tmp/sysinfo.$$.sysout
    print "COMPRESSION OPTION:        ${Compress_Option}" >> /tmp/sysinfo.$$.sysout
  fi
  print "KERNEL SIZE:                ${kernel_size} Bytes." >> /tmp/sysinfo.$$.sysout
  print "TOTAL MEMORY TO DUMP:        ${TotalMemoryDumpSizeOut} MB" >> /tmp/sysinfo.$$.sysout
  if (($osmajor == 10))  && (($osminor >= 10))
  then
    print "COMPRESSION FACTOR:          ${compression_factor} %" >> /tmp/sysinfo.$$.sysout
    print "COMPRESSED MEMORY TO DUMP:   ${CompressedMemoryDumpSize} MB" >> /tmp/sysinfo.$$.sysout
  fi
  print "DUMP DISK CAPACITY:          ${DumpDiskCapacity} MB" >> /tmp/sysinfo.$$.sysout
  print "SAVECORE CAPACITY:           ${SaveCoreAvail_Out} MB\n" >> /tmp/sysinfo.$$.sysout
  f_display_file /tmp/sysinfo.$$.sysout 
  f_display_file /tmp/sysinfo.$$.dumpwarn 

  if (($BATCH))
  then
    print 
  fi
}                # end of f_get_system_data

function f_call_getkinfo
{
/usr/sam/lbin/getkinfo -b -o ${sam_kinfo}
}

function get_all_parms
{
Debug "starting get_all_parms"
awk '
     BEGIN { FS = "\n"; RS = "}" }
     {print $0}
    ' $sam_kinfo | \
    awk '
         /KC_PARAM_NAME/      {name = $3;  printf("%s,", name)}
         /KC_PARAM_CLASS/     {class = $3 " " $4; printf("%s\n", class)}
        ' #| sed -e 's/\"*//g'
}

function get_all_classes
{
Debug "starting get_all_classes"
awk ' BEGIN { FS = "\n"; RS = "}" }
      $0 ~ /'\"$parm\"'/ {print $0}' $sam_kinfo \
        | awk '
          /^KC_PARAM_CLASS/     {printf("%s %s\n",$3,$4)}
          ' #| sed -e 's/\"*//g'
}

function f_query_sam
{
  sam_parm=$1
  type=$2
    awk ' BEGIN { FS = "\n"; RS = "}" }
      $0 ~ /'$sam_parm'/ {print $0}' $sam_kinfo \
          | awk '
          /^KC_PARAM_NAME/      {name = $3}
          /^KC_PARAM_STATUS/    {status = $3}
          /^KC_PARAM_DEFAULT/   {default = $3}
          /^KC_PARAM_MAX/       {max = $3}
          /^KC_PARAM_MIN/       {min = $3}
          /^KC_PARAM_CLASS/     {class = $3" " $4}
          /^KC_PARAM_DESC/      {desc = ""
                                 for(i=3;i<=NF;i++)
                                 desc = desc $i " ";
                                 }

          END { printf("%s@%s@%s@%s@%s@%s@%s\n",
                        name,status,default,max,min,desc,class)}
    ' | sed -e 's/\"*//g'

}

#===================================================================
# f_get_kernel_data
#        This function queries the kernel for various parameters.
#===================================================================
function f_get_kernel_data 
{

  Debug "Beginning KERNEL check."
  if (($BATCH))
  then
    print -n "collecting kernel data "
  fi
 
  if (($HTML))
  then
    print "
" >> /tmp/sysinfo.$$.kernout print "" >> /tmp/sysinfo.$$.kernout print "

" >> /tmp/sysinfo.$$.kernout print "

TOP

" >> /tmp/sysinfo.$$.kernout print "" >> /tmp/sysinfo.$$.kernout if (( ${FULL_KERNEL} )) then print "Kernel Parms (Verbose Listing)" >> /tmp/sysinfo.$$.kernout else print "Kernel Parms (Brief Listing)" >> /tmp/sysinfo.$$.kernout fi print "

" >> /tmp/sysinfo.$$.kernout print "
" >> /tmp/sysinfo.$$.kernout
  else
    print "KERNEL PARAMETERS" >> /tmp/sysinfo.$$.kernout
    print "=================" >> /tmp/sysinfo.$$.kernout
  fi

Debug "calling f_call_getkinfo -> ${sam_kinfo}"
f_call_getkinfo

Debug "calling get_all_parms -> ${all_parms_file}"
get_all_parms > ${all_parms_file}
Debug " parm names = `cat ${all_parms_file}`"

Debug "calling get_all_classes -> ${all_classes_file}"
get_all_classes | sort -t , -k 7 | uniq  > ${all_classes_file}
    #sed -e 's/ /_/g' -e 's/_$//g'  > ${all_classes_file}
Debug " class names = `cat ${all_classes_file}`"

exec 3< ${all_classes_file}
exec 4< ${all_parms_file}
while read -u3 class
do
  if (($BATCH))
  then
    print -n "."
  fi
  print_class=$(echo $class | sed -e 's/\"*//g')
  if (($HTML))
  then
    print "

${print_class} Metrics

" >> /tmp/sysinfo.$$.kernout else print "${print_class} Metrics" >> /tmp/sysinfo.$$.kernout print "============================" >> /tmp/sysinfo.$$.kernout fi Debug "Class = ${class}" for parm1 in $(grep "${class}" ${all_parms_file} | awk -F, '{print $1}') do Debug "Parm1 = $parm1" if (($FULL_KERNEL)) then f_query_sam ${parm1} | \ awk 'BEGIN {FS = "@"} {printf("%s\n",$1) printf(" Title: %s\n",$6) printf(" Current: %s\n",$2) printf(" Default: %s\n",$3) printf(" Min: %s\n",$5) printf(" Max: %s\n",$4) #printf(" Class: %s\n",$7) } '>> /tmp/sysinfo.$$.kernout else f_query_sam ${parm1} | \ awk 'BEGIN {FS = "@"} {printf(" %-20s %s\n",$1,$2) } ' >> /tmp/sysinfo.$$.kernout fi done print "" >> /tmp/sysinfo.$$.kernout done print "" >> /tmp/sysinfo.$$.kernout f_display_file /tmp/sysinfo.$$.kernout f_display_file /tmp/sysinfo.$$.kernwarn if (($BATCH)) then print "" fi } # end of f_get_kernel_data #=================================================================== # f_get_9x_kernel_data # This function queries the kernel for various parameters. #=================================================================== function f_get_9x_kernel_data { Debug "Beginning 9x KERNEL check." if (($BATCH)) then print -n "collecting kernel data " fi shmmni=$(echo 'shmmni/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') maxfiles=$(echo 'maxfiles/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi shmmax=$(echo 'shmmax/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') shmseg=$(echo 'shmseg/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') shmem=$(echo 'shmem/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi maxfiles_lim=$(echo 'maxfiles_lim/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') maxuprc=$(echo 'maxuprc/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi nproc=$(echo 'nproc/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') nfile=$(echo 'nfile/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi nflocks=$(echo 'nflocks/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') ninode=$(echo 'ninode/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi # PA8000 chips support variable page sizes super_page_supp=$(echo cpu_has_var_size_pages/D | adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') case $super_page_supp in 0) super_page_support=no;; 1) super_page_support=yes;; *) super_page_support=n/a;; # not found in kernel esac if (($BATCH)) then print -n "." fi npty=$(echo 'npty/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') # check for asynch disc writes enabled fs_async=$(echo 'fs_async/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') if ((${fs_async} == 0)) then fs_async=no else fs_async=yes fi if (($BATCH)) then print -n "." fi nbuf=$(echo 'nbuf/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') bufpages=$(echo 'bufpages/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi # mesg=$(echo 'mesg/D'|adb $kernel /dev/kmem \ # | tail -1 | awk '{print $2}') msgmap=$(echo 'msgmap/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi # msgmax=$(echo 'msgmax/D'|adb $kernel /dev/kmem \ # | tail -1 | awk '{print $2}') # msgmnb=$(echo 'msgmnb/D'|adb $kernel /dev/kmem \ # | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi # msgmni=$(echo 'msgmni/D'|adb $kernel /dev/kmem \ # | tail -1 | awk '{print $2}') # msgseg=$(echo 'msgseg/D'|adb $kernel /dev/kmem \ # | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi # msgssz=$(echo 'msgssz/D'|adb $kernel /dev/kmem \ # | tail -1 | awk '{print $2}') # msgtql=$(echo 'msgtql/D'|adb $kernel /dev/kmem \ # | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi maxdsiz=$(echo 'maxdsiz/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') maxssiz=$(echo 'maxssiz/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi maxtsiz=$(echo 'maxtsiz/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') maxuprc=$(echo 'maxuprc/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi ncdnode=$(echo 'ncdnode/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') # maxuprc=$(echo 'maxuprc/D'|adb $kernel /dev/kmem \ # | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi sema=$(echo 'sema/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') # semaem=$(echo 'semaem/D'|adb $kernel /dev/kmem \ # | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi semmap=$(echo 'semmap/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') # semmni=$(echo 'semmni/D'|adb $kernel /dev/kmem \ # | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi # semmns=$(echo 'semmns/D'|adb $kernel /dev/kmem \ # | tail -1 | awk '{print $2}') # semmnu=$(echo 'semmnu/D'|adb $kernel /dev/kmem \ # | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi # semume=$(echo 'semume/D'|adb $kernel /dev/kmem \ # | tail -1 | awk '{print $2}') # semvmx=$(echo 'semvmx/D'|adb $kernel /dev/kmem \ # | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi # get LVM related kernel parameters maxvgs=$(echo 'maxvgs/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') lv_vgs_opn=$(echo 'lv_vgs_opn/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi lv_lvs_opn=$(echo 'lv_lvs_opn/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') lv_pbuf_cnt=$(echo 'lv_pbuf_cnt/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi lv_pbuf_inuse=$(echo 'lv_pbuf_inuse/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') lv_pbuf_maxuse=$(echo 'lv_pbuf_maxuse/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') if (($BATCH)) then print -n "." fi lv_pbuf_pending_Q=$(echo 'lv_pbuf_pending_Q/D'|adb $kernel /dev/kmem \ | tail -1 | awk '{print $2}') if (($HTML)) then print "
" >> /tmp/sysinfo.$$.kernout print "" >> /tmp/sysinfo.$$.kernout print "" >> /tmp/sysinfo.$$.kernout print "

Kernel Data

" >> /tmp/sysinfo.$$.kernout print "
" >> /tmp/sysinfo.$$.kernout
  else
    print "KERNEL DATA" >> /tmp/sysinfo.$$.kernout
    print "===========" >> /tmp/sysinfo.$$.kernout
  fi
  print "Super page support (cpu_has_var_size_pages) $super_page_support" >> /tmp/sysinfo.$$.kernout
  print "" >> /tmp/sysinfo.$$.kernout
  print "Max shared memory segments in system (shmmni)$shmmni" >> /tmp/sysinfo.$$.kernout
  print "Enable Sys V Shared Memory(shmem)            ${shmem}" >> /tmp/sysinfo.$$.kernout
#  print "(shmmax) ${shmmax}" >> /tmp/sysinfo.$$.kernout
#  print "(shmseg) ${shmseg}" >> /tmp/sysinfo.$$.kernout

  print "" >> /tmp/sysinfo.$$.kernout
  print "Soft file limit per process (maxfiles)       $maxfiles" >> /tmp/sysinfo.$$.kernout
  print "Hard file limit per process (maxfiles_lim)   $maxfiles_lim" >> /tmp/sysinfo.$$.kernout
  print "Max number of processes (nproc)              $nproc" >> /tmp/sysinfo.$$.kernout
  print "Max number of user processes (maxuprc)       $maxuprc" >> /tmp/sysinfo.$$.kernout
  print "Number of open files in system (nfile)       $nfile" >> /tmp/sysinfo.$$.kernout
  print "Maximum number of file locks (nflocks)       $nflocks" >> /tmp/sysinfo.$$.kernout
  print "Max number of in-core inodes (ninode)        $ninode" >> /tmp/sysinfo.$$.kernout
  print "Asynchronous disk writes allowed (fs_async)  $fs_async" >> /tmp/sysinfo.$$.kernout
  print "Number of pseudo-teletypes (npty)            $npty" >> /tmp/sysinfo.$$.kernout
  print "Number of filesystem buffer headers (nbuf)   $nbuf" >> /tmp/sysinfo.$$.kernout
  print "Number of buffer pages in cache (bufpages)   $bufpages" >> /tmp/sysinfo.$$.kernout
#  print "(mesg)      $mesg" >> /tmp/sysinfo.$$.kernout
  print "Max Number of Message Map Entries (msgmap)   $msgmap" >> /tmp/sysinfo.$$.kernout
#  print "(msgmax)    $msgmax" >> /tmp/sysinfo.$$.kernout
#  print "(msgmnb)    $msgmnb" >> /tmp/sysinfo.$$.kernout
#  print "(msgmni)    $msgmni" >> /tmp/sysinfo.$$.kernout
#  print "(msgseg)    $msgseg" >> /tmp/sysinfo.$$.kernout
#  print "(msgssg)    $msgssg" >> /tmp/sysinfo.$$.kernout
#  print "(msgtql)    $msgtql" >> /tmp/sysinfo.$$.kernout
  print "Max Data Segment Size (Bytes) (maxdsiz)      $maxdsiz" >> /tmp/sysinfo.$$.kernout
  print "Max Stack Segment Size (Bytes) (maxssiz)     $maxssiz" >> /tmp/sysinfo.$$.kernout
  print "Max Text Segment Size (Bytes) (maxtsiz)      $maxtsiz" >> /tmp/sysinfo.$$.kernout
  print "Enable Sys V Semaphores (sema)               $sema" >> /tmp/sysinfo.$$.kernout
#  print "(semaem)    $semaem" >> /tmp/sysinfo.$$.kernout
#  print "(semmap)    $semmap" >> /tmp/sysinfo.$$.kernout
#  print "(semmni)    $semmni" >> /tmp/sysinfo.$$.kernout
#  print "(semmns)    $semmns" >> /tmp/sysinfo.$$.kernout
#  print "(semmnu)    $semmnu" >> /tmp/sysinfo.$$.kernout
#  print "(semume)    $semume" >> /tmp/sysinfo.$$.kernout
#  print "(semvmx)    $semvmx" >> /tmp/sysinfo.$$.kernout

  if (($lvm_installed))
  then
    print "" >> /tmp/sysinfo.$$.kernout
    print "LVM Parms" >> /tmp/sysinfo.$$.kernout
    print "  Max number of volume groups (maxvgs)       $maxvgs" >> /tmp/sysinfo.$$.kernout
    print "  Number of open volume groups (lv_vgs_opn)  $lv_vgs_opn" >> /tmp/sysinfo.$$.kernout
    print "  Number of open logical volumes (lv_lvs_opn)$lv_lvs_opn" >> /tmp/sysinfo.$$.kernout
    print "  Lvol pbuf count (lv_pbuf_cnt)              $lv_pbuf_cnt" >> /tmp/sysinfo.$$.kernout
    print "  Lvol pbuf current usage (lv_pbuf_inuse)    $lv_pbuf_inuse" >> /tmp/sysinfo.$$.kernout
    print "  Lvol pbuf high water mark (lv_pbuf_maxuse) $lv_pbuf_maxuse" >> /tmp/sysinfo.$$.kernout
    print "  lv_pbuf_pending_Q:                         $lv_pbuf_pending_Q \n" >> /tmp/sysinfo.$$.kernout
  fi
  f_display_file /tmp/sysinfo.$$.kernout
  f_display_file /tmp/sysinfo.$$.kernwarn
  if (($BATCH))
  then
    print ""
  fi
}                # end of f_get_9x_kernel_data

#===================================================================
# f_query_sam
#        This function uses /usr/sam/lbin/getkinfo to query for
#        various parameters.
#===================================================================
#function f_query_sam
#{
#  samparm=$1
#  type=$2
#  awk ' BEGIN { FS = "\n"; RS = "}" }
#    $0 ~ /'\"$samparm\"'/ {print $0}' $sam_kinfo \
#  | grep $2 | awk '{print $3}'\
#  | sed -e 's/\"*//g'
#
#}
#===================================================================
# sam_scan
#        This function queries sam for various kernel parameters.
#        It uses f_query_sam to scan the kinfo file
#===================================================================
#function sam_scan
#{
#
#  if [[ -x /usr/sam/lbin/getkinfo ]]
#  then
#    /usr/sam/lbin/getkinfo -b -o $sam_kinfo
#    shmmni_s=$(f_query_sam shmmni STATUS)
#    shmmni_s_d=$(f_query_sam shmmni DEFAULT)
#    #shmmni_s_min=$(f_query_sam shmmni MIN)
#    #shmmni_s_max=$(f_query_sam shmmni MAX)
#    shmmax_s=$(f_query_sam shmmax STATUS)
#    shmmax_s_d=$(f_query_sam shmmax DEFAULT)
#    shmseg_s=$(f_query_sam shmseg STATUS)
#    shmseg_s_d=$(f_query_sam shmseg DEFAULT)
#    msgmap_s=$(f_query_sam msgmap STATUS)
#    msgmap_s_d=$(f_query_sam msgmap DEFAULT)
#    msgmax_s=$(f_query_sam msgmax STATUS)
#    msgmax_s_d=$(f_query_sam msgmax DEFAULT)
#    msgmnb_s=$(f_query_sam msgmnb STATUS)
#    msgmnb_s_d=$(f_query_sam msgmnb DEFAULT)
#    msgmni_s=$(f_query_sam msgmni STATUS)
#    msgmni_s_d=$(f_query_sam msgmni DEFAULT)
#    msgseg_s=$(f_query_sam msgseg STATUS)
#    msgseg_s_d=$(f_query_sam msgseg DEFAULT)
#    msgssz_s=$(f_query_sam msgssz STATUS)
#    msgssz_s_d=$(f_query_sam msgssz DEFAULT)
#    msgtql_s=$(f_query_sam msgtql STATUS)
#    msgtql_s_d=$(f_query_sam msgtql DEFAULT)
#    semaem_s=$(f_query_sam semaem STATUS)
#    semaem_s_d=$(f_query_sam semaem DEFAULT)
#    semmap_s=$(f_query_sam semmap STATUS)
#    semmap_s_d=$(f_query_sam semmap DEFAULT)
#    semmni_s=$(f_query_sam semmni STATUS)
#    semmni_s_d=$(f_query_sam semmni DEFAULT)
#    semmns_s=$(f_query_sam semmns STATUS)
#    semmns_s_d=$(f_query_sam semmns DEFAULT)
#    semmnu_s=$(f_query_sam semmnu STATUS)
#    semmnu_s_d=$(f_query_sam semmnu DEFAULT)
#    semume_s=$(f_query_sam semume STATUS)
#    semume_s_d=$(f_query_sam semume DEFAULT)
#    semvmx_s=$(f_query_sam semvmx STATUS)
#    semvmx_s_d=$(f_query_sam semvmx DEFAULT)
#    maxfiles_s=$(f_query_sam maxfiles STATUS)
#    maxfiles_s_d=$(f_query_sam maxfiles DEFAULT)
#    maxfiles_lim_s=$(f_query_sam maxfiles_lim STATUS)
#    maxfiles_lim_s_d=$(f_query_sam maxfiles_lim DEFAULT)
#    maxuprc_s=$(f_query_sam maxuprc STATUS)
#    maxuprc_s_d=$(f_query_sam maxuprc DEFAULT)
#    nproc_s=$(f_query_sam nproc STATUS)
#    nproc_s_d=$(f_query_sam nproc DEFAULT)
#    nfile_s=$(f_query_sam nfile STATUS)
#    nfile_s_d=$(f_query_sam nfile DEFAULT)
#    nflocks_s=$(f_query_sam nflocks STATUS)
#    nflocks_s_d=$(f_query_sam nflocks DEFAULT)
#    ninode_s=$(f_query_sam ninode STATUS)
#    ninode_s_d=$(f_query_sam ninode DEFAULT)
#    npty_s=$(f_query_sam npty STATUS)
#    npty_s_d=$(f_query_sam npty DEFAULT)
#    nbuf_s=$(f_query_sam nbuf STATUS)
#    nbuf_s_d=$(f_query_sam nbuf DEFAULT)
#    bufpages_s=$(f_query_sam bufpages STATUS)
#    bufpages_s_d=$(f_query_sam bufpages DEFAULT)
#
#  
#    if (( ${osmajor} == 10 ))
#    then
#      dbc_max_pct_s=$(f_query_sam dbc_max_pct STATUS)
#      dbc_max_pct_s_d=$(f_query_sam dbc_max_pct DEFAULT)
#      dbc_min_pct_s=$(f_query_sam dbc_min_pct STATUS)
#      dbc_min_pct_s_d=$(f_query_sam dbc_min_pct DEFAULT)
#    else
#      dbc_max_pct="N/A"
#      dbc_min_pct="N/A"
#    fi
#
#    maxvgs_s=$(f_query_sam maxvgs STATUS)
#    maxvgs_s_d=$(f_query_sam maxvgs DEFAULT)
#    lv_vgs_opn_s=$(f_query_sam lv_vgs_opn STATUS)
#   
#    if (($HTML))
#    then
#      print "
" >> $sam_out_file # print "" >> $sam_out_file # print "

" >> $sam_out_file # print "

TOP

" >> $sam_out_file # print "Kernel Data (from SAM)

" >> $sam_out_file # print "
"       >> $sam_out_file
#    else
#      print "MISC KERNEL PARMS (from SAM)" >> $sam_out_file
#      print "============================" >> $sam_out_file
#    fi
#    print "Shared Memory Parms" >> $sam_out_file
#    print "  shmmax          $shmmax_s" >> $sam_out_file
#    print "    default       $shmmax_s_d" >> $sam_out_file
#    print "  shmmni          $shmmni_s" >> $sam_out_file
#    print "    default       $shmmni_s_d" >> $sam_out_file
#    print "  shmseg          $shmseg_s" >> $sam_out_file
#    print "    default       $shmseg_s_d" >> $sam_out_file
#    print "" >> $sam_out_file
#    print "Messaging Parms" >> $sam_out_file
#    print "  msgmap          $msgmap_s" >> $sam_out_file
#    print "    default       $msgmap_s_d" >> $sam_out_file
#    print "  msgmax          $msgmax_s" >> $sam_out_file
#    print "    default       $msgmax_s_d" >> $sam_out_file
#    print "  msgmnb          $msgmnb_s" >> $sam_out_file
#    print "    default       $msgmnb_s_d" >> $sam_out_file
#    print "  msgmni          $msgmni_s" >> $sam_out_file
#    print "    default       $msgmni_s_d" >> $sam_out_file
#    print "  msgseg          $msgseg_s" >> $sam_out_file
#    print "    default       $msgseg_s_d" >> $sam_out_file
#    print "  msgssz          $msgssz_s" >> $sam_out_file
#    print "    default       $msgssz_s_d" >> $sam_out_file
#    print "  msgtql          $msgtql_s" >> $sam_out_file
#    print "    default       $msgtql_s_d" >> $sam_out_file
#    print "" >> $sam_out_file
#    print "Semaphore Parms" >> $sam_out_file
#    print "  semaem          $semaem_s" >> $sam_out_file
#    print "    default       $semaem_s_d" >> $sam_out_file
#    print "  semmap          $semmap_s" >> $sam_out_file
#    print "    default       $semmap_s_d" >> $sam_out_file
#    print "  semmni          $semmni_s" >> $sam_out_file
#    print "    default       $semmni_s_d" >> $sam_out_file
#    print "  semmns          $semmns_s" >> $sam_out_file
#    print "    default       $semmns_s_d" >> $sam_out_file
#    print "  semmnu          $semmnu_s" >> $sam_out_file
#    print "    default       $semmnu_s_d" >> $sam_out_file
#    print "  semume          $semume_s" >> $sam_out_file
#    print "    default       $semume_s_d" >> $sam_out_file
#    print "  semvmx          $semvmx_s" >> $sam_out_file
#    print "    default       $semvmx_s_d" >> $sam_out_file
#
#    print "" >> $sam_out_file
#    print "File System Parms" >> $sam_out_file
#    print "  maxfiles        $maxfiles_s" >> $sam_out_file
#    print "    default       $maxfiles_s_d" >> $sam_out_file
#    print "  maxfiles_lim    $maxfiles_lim_s" >> $sam_out_file
#    print "    default       $maxfiles_lim_s_d" >> $sam_out_file
#    print "  nproc           $nproc_s" >> $sam_out_file
#    print "    default       $nproc_s_d" >> $sam_out_file
#    print "  maxuprc         $maxuprc_s" >> $sam_out_file
#    print "    default       $maxuprc_s_d" >> $sam_out_file
#    print "  nfile           $nfile_s" >> $sam_out_file
#    print "    default       $nfile_s_d" >> $sam_out_file
#    print "  nflocks         $nflocks_s" >> $sam_out_file
#    print "    default       $nflocks_s_d" >> $sam_out_file
#    print "  ninode          $ninode_s" >> $sam_out_file
#    print "    default       $ninode_s_d" >> $sam_out_file
#    print "  npty            $npty_s" >> $sam_out_file
#    print "    default       $npty_s_d" >> $sam_out_file
#    print "  nbuf            $nbuf_s" >> $sam_out_file
#    print "    default       $nbuf_s_d" >> $sam_out_file
#    print "  bufpages        $bufpages_s" >> $sam_out_file
#    print "    default       $bufpages_s_d" >> $sam_out_file
#    print "  dbc_max_pct     $dbc_max_pct_s" >> $sam_out_file
#    print "    default       $dbc_max_pct_s_d" >> $sam_out_file
#    print "  dbc_min_pct     $dbc_min_pct_s" >> $sam_out_file
#    print "    default       $dbc_min_pct_s_d" >> $sam_out_file
#  
#    print "" >> $sam_out_file
#    print "LVM Parms" >> $sam_out_file
#    print "  maxvgs          $maxvgs_s" >> $sam_out_file
#    print "    default       $maxvgs_s_d" >> $sam_out_file
#    print "  lv_vgs_opn      $lv_vgs_opn_s" >> $sam_out_file
#    print "" >> $sam_out_file
#  else
#    Debug " program file /usr/sam/lbin/getkinfo not found!"
#    print " program file /usr/sam/lbin/getkinfo not found!"
#  fi
#}                # end of f_get_sam_kernel_data 
 
#===================================================================
# f_display_sam_kernel
#===================================================================
#function f_display_sam_kernel_data
#{
#  Debug "Beginning SAM KERNEL check."
#  Debug "  calling check_if_scan_done"
#  check_if_scan_done sam_scan
#
#  if (($BATCH))
#  then
#    print ""
#  fi
#  Debug " attempting to display sam_out_file $sam_out_file"
#  f_display_file $sam_out_file
#  f_display_file /tmp/sysinfo.$$.kernwarn_sam 
#
#} # end of f_display_sam_kernel

#===================================================================
# f_get_network_data
#        This function queries each lan card and retrieves information
#        for each one.
#===================================================================
function f_get_network_data
{
  Debug "Beginning NETWORK check."
  if (($BATCH))
  then
    print -n "scanning network cards "
  fi
  GetCurrentDNS
  #DOMAIN=$(nslookup ${sysname} | grep Name | grep -v Server | cut -d. -f2-6)
  default_router=$( netstat -r | grep default | awk '{print $2}')
  default_router_ip=$( netstat -rn | grep default | awk '{print $2}')
  if (($HTML))
  then
    print "
" >> /tmp/sysinfo.$$.netout print "" >> /tmp/sysinfo.$$.netout print "

" >> /tmp/sysinfo.$$.netout print "

TOP

" >> /tmp/sysinfo.$$.netout print "" >> /tmp/sysinfo.$$.netout print "Network Data

" >> /tmp/sysinfo.$$.netout print "
" >> /tmp/sysinfo.$$.netout
  else
    print "NETWORK DATA" >> /tmp/sysinfo.$$.netout
    print "============" >> /tmp/sysinfo.$$.netout
  fi
  print "DOMAIN NAME:    ${CURRENT_DOMAIN}" >> /tmp/sysinfo.$$.netout
  print -n "DNS SERVER:     ${CURRENT_DNS_SERVER}  " >> /tmp/sysinfo.$$.netout
  print "(${CURRENT_DNS_SERVER_IP})" >> /tmp/sysinfo.$$.netout
  print -n "DEFAULT ROUTER: ${default_router}  "  >> /tmp/sysinfo.$$.netout
  print "(${default_router_ip})"  >> /tmp/sysinfo.$$.netout
  print "" >> /tmp/sysinfo.$$.netout

  #for CARD in $(netstat -in | grep lan | awk '{print $1}' | sed 's/\*//')
  # 1.42 change to handle multiple I/F cards
  if (( ${osmajor} >= 10 ))
  then
    card_list=$(/etc/lanscan -i)
    Debug " 10.x using lanscan -i"
  else
    card_list=$(/etc/lanscan | tail +3 | awk '{printf("%s\n",$5)}')
    Debug " 9.x using lanscan -i"
  fi
  for CARD in ${card_list}
  do
    ifconfig "$CARD" > /tmp/sysinfo.$$.ipdata 2>&1
    if [ $? -eq 0 ]
    then
      Debug " checking lan card -> $CARD"
      #lanconfig "$CARD" >> /tmp/sysinfo.$$.ipdata 2>&1
      #card_type=$(lanconfig "$CARD" | grep ${CARD} | awk '{print $2}')
      card_type=$(lanscan  | grep ${CARD} | awk '{print $8}')
      Debug "  card_type=$card_type"
      #MWR fix for incorrect handling of multiple lan cards
      #macaddr=$(/etc/lanscan | grep x | awk '{print $2}')
      macaddr=$(/etc/lanscan | grep $CARD | awk '{print $2}')
      lan_hw_addr=$(/etc/lanscan | grep $CARD | awk '{print $1}')
      nmid=$(/etc/lanscan | grep $CARD | awk '{print $7}')
      ip_addr=$(grep inet /tmp/sysinfo.$$.ipdata | awk '{print $2}')
      netmask=$(grep inet /tmp/sysinfo.$$.ipdata | awk '{print $4}')

      #convert hex netmask to decimal-dot.
      typeset -Z8  hex=0${netmask#0x}; typeset +Z hex
      typeset -L2  ott=
      typeset -i10 dec=
      netmask=""
      while [ "$hex" ]; do
        ott=$hex
        dec=16#$ott
        netmask=$netmask.$dec
        hex=${hex#??}
      done
      netmask=${netmask#.}

      broadcast=$(grep inet /tmp/sysinfo.$$.ipdata | awk '{print $6}')
      if (($HTML))
      then
        print "
" >> /tmp/sysinfo.$$.netout print "

INTERFACE DATA for ${CARD}

" >> /tmp/sysinfo.$$.netout print "
" >> /tmp/sysinfo.$$.netout
      else
        print "INTERFACE DATA for ${CARD}" >> /tmp/sysinfo.$$.netout
        print "===========================" >> /tmp/sysinfo.$$.netout
      fi
      #print "NMID:        ${nmid}" >> /tmp/sysinfo.$$.netout
      print "H/W ADDR:    ${lan_hw_addr}" >> /tmp/sysinfo.$$.netout
      print "CARD TYPE:   ${card_type}" >> /tmp/sysinfo.$$.netout
      print "MAC ADDRESS: ${macaddr}" >> /tmp/sysinfo.$$.netout
      print "IP ADDRESS:  ${ip_addr}" >> /tmp/sysinfo.$$.netout
      print "BROADCAST:   ${broadcast}" >> /tmp/sysinfo.$$.netout
      print "NETMASK:     ${netmask}\n" >> /tmp/sysinfo.$$.netout
    fi
    if (($BATCH))
    then
      print -n "."
    fi
  done
  f_display_file /tmp/sysinfo.$$.netout 
  if (($BATCH))
  then
    print
  fi
}                # end of f_get_network_data

#===================================================================
# f_get_physical_disk_data
#        This function scans each physical disk.
#        It uses ioscan to collect disk info and the queries each
#        device using diskinfo. 
#        The output is displayed in sorted order.
#===================================================================
function f_get_physical_disk_data
{
  Debug "Beginning PHYSICAL DISK check."
# first let's print header information
  if (($HTML))
  then
    print "
" >> /tmp/sysinfo.$$.physinfoh print "" >> /tmp/sysinfo.$$.physinfoh print "

" >> /tmp/sysinfo.$$.physinfoh print "

TOP

" >> /tmp/sysinfo.$$.physinfoh print "" >> /tmp/sysinfo.$$.physinfoh print "Physical Disk Data

" >> /tmp/sysinfo.$$.physinfoh print "
"                       >> /tmp/sysinfo.$$.physinfoh
    print "
" >> /tmp/sysinfo.$$.boot print "

Bootable Disks

" >> /tmp/sysinfo.$$.boot print "
"                >> /tmp/sysinfo.$$.boot
    print    "Volume Name       Auto Boot String" >> /tmp/sysinfo.$$.boot
    print -- "--------------    ----------------" >> /tmp/sysinfo.$$.boot
    print ""                     >> /tmp/sysinfo.$$.boot
  else
    print    "PHYSICAL DISK DATA" >> /tmp/sysinfo.$$.physinfoh
    print    "==================" >> /tmp/sysinfo.$$.physinfoh
    print    "BOOTABLE DISKS" >> /tmp/sysinfo.$$.boot
    print    "==============" >> /tmp/sysinfo.$$.boot
    print    "Volume Name       Auto Boot String" >> /tmp/sysinfo.$$.boot
    print -- "--------------    ----------------" >> /tmp/sysinfo.$$.boot
  fi
  if (($PMAP))
  then
    if (($HTML))
    then
      print "
" >> /tmp/sysinfo.$$.pmap print "" >> /tmp/sysinfo.$$.pmap print "

" >> /tmp/sysinfo.$$.pmap print "

TOP

" >> /tmp/sysinfo.$$.pmap print "" >> /tmp/sysinfo.$$.pmap print "Physical Disk To Logical Volume Mapping

" >> /tmp/sysinfo.$$.pmap print "
"        >> /tmp/sysinfo.$$.pmap
    else
      print    "PHYSICAL DISK TO LOGICAL VOLUME MAPPING" >> /tmp/sysinfo.$$.pmap
      print    "=======================================" >> /tmp/sysinfo.$$.pmap
    fi
    print -n "Physical Disk                           " >> /tmp/sysinfo.$$.pmap
    print    "     Alternate Link" >> /tmp/sysinfo.$$.pmap
    print    "       Logical Volume     LE        PE" >> /tmp/sysinfo.$$.pmap
    print -n -- "----------------------------------------" >> /tmp/sysinfo.$$.pmap
    print --    "-----------------------" >> /tmp/sysinfo.$$.pmap
  fi
  Debug "  calling check_if_scan_done"
  check_if_scan_done io_scan
  print -n "scanning physical disks "

#get physical disk names
  if (( $osmajor >= 10 ))
  then
    Debug "Found 10.x system"
#   hw_path=$(ioscan -kfC disk | sed '1,/^=/d' | awk '{print $3}')
    hw_path=$(grep disk $io_scan_out | awk -F: '{print $11}' | sort)
    Debug "hw_path=$hw_path"
    for hwpath in ${hw_path}
    do
      Debug "hwpath=${hwpath}"
      tmpin=$(echo $hwpath | cut -d. -f1)
      inst=$(ioscan -kf | grep "^ext_bus" | grep " ${tmpin}" \
                  | grep -v fcpdev | awk '{print $2}')
      scsi_addr=$(echo $hwpath | cut -d. -f2)
      unit_addr=$(echo $hwpath | cut -d. -f3)
      physvol="/dev/dsk/c${inst}t${scsi_addr}d${unit_addr}"
      rphysvol="/dev/rdsk/c${inst}t${scsi_addr}d${unit_addr}"
      Debug "Physical volume ${physvol}"
      Debug "  tmpin=${tmpin}"
      Debug "  inst=${inst} scsi_addr=${scsi_addr} unit_addr=${unit_addr}"
# Check for alternate link so that we don't try to access it
      Debug "  Checking if this is an alternate link"
      pvdisplay -v ${physvol} > /tmp/sysinfo.$$.pvdisp 2>&1
      grep "Using Primary Link" /tmp/sysinfo.$$.pvdisp > /dev/null 2>&1
      detect_alt_link=$?
      if ((detect_alt_link == 0))
      then
        Debug "  this IS an alternate link, so skip"
      else
        Debug "  this is NOT an alternate link, so query disk"
        hwpathd=${hwpath} # for display purposes
        info=$(diskinfo -v /dev/rdsk/c${inst}t${scsi_addr}d${unit_addr} 2>&1)
        if echo $info | grep "Device busy" > /dev/null
        then
          Debug "  diskinfo reports Device Busy Error on $rphysvol"
          #lu="N/A"
          #lu=$(ioscan -kfCdisk | grep " ${hwpath}" | awk '{print $2}')
          lu=$(grep ${hwpath} $io_scan_out  grep -v target | awk '{print $2}')
          vendor=$(ioscan -H $hwpath | tail -1 | awk '{print $3}')
          product=$(ioscan -H $hwpath | tail -1 | awk '{print $NF}')
          print "${physvol}${lu}${hwpathd}${vendor}${product}" \
                   >> /tmp/sysinfo.$$.physinfo
          Debug "  ${physvol}${lu}${hwpathd}${vendor}${product}" 
        elif echo $info | grep "No such device or address" > /dev/null 
        then
          Debug "  diskinfo reports No such device or address on $physvol"
          lu="N/A"
          vendor=$(ioscan -H $hwpath | tail -1 | awk '{print $3}')
          product=$(ioscan -H $hwpath | tail -1 | awk '{print $NF}')
          print "${physvol}${lu}${hwpathd}${vendor}${product}" \
                   >> /tmp/sysinfo.$$.physinfo
          Debug "  ${physvol}${lu}${hwpathd}${vendor}${product}" 
        else              
          Debug "  found a device (no diskinfo error)...so follow it"
          product=$(echo $info | sed -e 's/^.*product id: //' -e 's/ .*$//')
          psize=$(echo $info | sed -e 's/^.*size: //' -e 's/ .*$//')
          psize_mb=$(expr ${psize} / 1024)
          vendor=$(echo $info | sed -e 's/^.*vendor: //' -e 's/ .*$//')
          rev_level=$(echo $info | sed -e 's/^.*rev level: //' -e 's/ .*$//')
          #rev_level=$(echo $info | grep "rev level" \
          #       | awk '{print $3}')
          ((total_p_mb=total_p_mb + psize_mb))
          ((pcount=pcount + 1))
          Debug "    vendor=$vendor"
          Debug "    product=$product"
          Debug "    rev_level=$rev_level"
          Debug "    psize=$psize"
          Debug "    psize_mb=$psize_mb"
          Debug "  Checking for Bootable PV"
          lifls ${physvol} 2> /dev/null | grep -i isl > /dev/null 2>&1
          if [ $? -eq 0 ]
          then   
            Debug "    Found Bootable PV at ${physvol}"
            bootable_pv="Yes"
            lifls ${rphysvol} | grep AUTO > /dev/null 2>&1
            if [ $? -eq 0 ]
            then   
              Debug "    Found auto_string=$auto_string"
              auto_string=$(lifcp ${rphysvol}:AUTO -)
              print "${physvol}${auto_string}" >> /tmp/sysinfo.$$.boot
            else
              Debug "    Did not find auto_string."
            fi
          else 
            Debug "    Did not find Bootable PV on ${physvol}"
            bootable_pv="No"
          fi
          if grep "find the volume group" /tmp/sysinfo.$$.pvdisp > /dev/null
          then
            Debug "  NON-LVM   /dev/dsk/c${inst}t${scsi_addr}d${unit_addr}" 
            Debug "    id as::${vendor}${product}${psize_mb} Mbytes." 
            lu="N/A"
          else            
             Debug "  LVM disk"
            lu=$(ioscan -kfCdisk | grep " ${hwpath}" | awk '{print $2}')
            if (($PMAP))
            then
              Debug "  Begin PHYSICAL TO LOGICAL Mapping"
              alt_link=""
              if (($osmajor == 10)) && (($osminor >= 20))
              then
                # PVdisplay looks different on 10.20 (MWR)
                alt_link=$(grep "^PV Name" /tmp/sysinfo.$$.pvdisp | \
                   grep "Alternate Link" | awk '{printf "%s ", $3}' )
                Debug "  >=10.20     alt_link=$alt_link"
              else 
                #less than 10.20
                alt_link=$(grep "^   PV Name" /tmp/sysinfo.$$.pvdisp | \
                   grep "Alternate Link" | awk '{printf "%s ", $3}' )
                Debug "  <10.20   alt_link=$alt_link"
              fi
              if  [ "$alt_link" = "" ]
              then
                alt_link="None"
              fi
              Debug "    alt_link=$alt_link"
              print "${physvol}                           ${alt_link}" \
                 >> /tmp/sysinfo.$$.pmap
              sed '1,15d;/current/d;/Status/d;/free/d;' \
		/tmp/sysinfo.$$.pvdisp | \
                sed '/^$/d;/---/d;/LV/d; s/\/dev/    \/dev/' \
                >> /tmp/sysinfo.$$.pmap
            fi   # end of PMAP
          fi
          print -n "${physvol}${lu}${hwpathd}${vendor}${product}" >> /tmp/sysinfo.$$.physinfo
          print "${psize_mb}   ${bootable_pv}${rev_level}" >> /tmp/sysinfo.$$.physinfo
        fi
        print -n "."
      fi
    done # end of hwpath loop
    # end of 10.x system
  else      
    Debug "must be a 9.x system"
    pvol=$(vgdisplay -v 2>&1 | grep "^   PV Name" | grep -v "Alternate Link" \
           | sort | awk '{printf "%s ", $3}' )
    ioscan -kfCdisk | sort > /tmp/sysinfo.$$.io_disk
    #now force access to disks.
    for physvol in ${pvol}                        # loop through all phys vols
    do
      hwpath=$(lssf ${physvol} | awk '{printf "%s ", $(NF -1)}')
      hwpathd=${hwpath} # for display purposes
      disktype=$(echo ${physvol} | sed s/dsk/rdsk/)
      diskinfo -v ${disktype} > /tmp/sysinfo.$$.diskinfo 2>&1
      if (($?))
      then
        print "ERROR:${sysname}: diskinfo reports an error on ${physvol}."
        exit_code=${SYS_ERROR}
      else
        vendor=$(grep "vendor" /tmp/sysinfo.$$.diskinfo \
                 | awk '{printf "%s ", $2}')
        product=$(grep "product id" /tmp/sysinfo.$$.diskinfo \
                 | awk '{printf "%s ", $3}')
        type=$(grep "type" /tmp/sysinfo.$$.diskinfo \
                 | cut -b22- )
        psize=$(grep "size" /tmp/sysinfo.$$.diskinfo \
                 | awk '{printf "%s ", $2}')
        psize_mb=$(expr ${psize} / 1024)
        lu=$(grep " ${hwpath}" /tmp/sysinfo.$$.io_disk | awk '{print $2}')
        rev_level=$(grep "rev level" /tmp/sysinfo.$$.diskinfo \
                 | awk '{print $3}')
        ((total_p_mb=total_p_mb + psize_mb))
        ((pcount=pcount + 1))
        if (($PMAP))
        then
          pvdisplay -v ${physvol} > /tmp/sysinfo.$$.pvdisp 2>&1
          alt_link=""
          alt_link=$(grep "^   PV Name" /tmp/sysinfo.$$.pvdisp | \
               grep "Alternate Link" | awk '{printf "%s ", $3}' )
          #alt_link="/dev/dsk/cxtxdx"
          if  [ "$alt_link" = "" ]
          then
            alt_link="None"
          fi
          print "${physvol}                           ${alt_link}" \
             >> /tmp/sysinfo.$$.pmap
          sed '1,15d;/current/d;/Status/d;/free/d;' /tmp/sysinfo.$$.pvdisp | \
            sed '/^$/d;/---/d;/LV/d; s/\/dev/    \/dev/' \
            >> /tmp/sysinfo.$$.pmap
        fi
        Debug "\ndisktype=$disktype"
        Debug "hwpath=$hwpath"
        Debug "vendor=$vendor"
        Debug "product=$product"
        Debug "psize=$psize"
        Debug "psize_mb=$psize_mb"
        Debug "lu=$lu"
        Debug "type=$type"
        Debug "total_p_mb=$total_p_mb"
        Debug "pcount=$pcount"
        Debug "rev_level=$rev_level"
        Debug "alt_link=$alt_link"
        print -n "."
        print "${physvol}${lu}${hwpathd}${vendor}${product}${psize_mb}${rev_level}" >> /tmp/sysinfo.$$.physinfo
      fi
    done
  fi # end of 9.x

# now print out totals

  sort -k2. -o /tmp/sysinfo.$$.physinfos /tmp/sysinfo.$$.physinfo
  rm -f /tmp/sysinfo.$$.physinfo 2>&1
  print
  print     "\n\n" >> /tmp/sysinfo.$$.boot
# print     "" >> /tmp/sysinfo.$$.physinfoh
  print  -n "                         " >> /tmp/sysinfo.$$.physinfoh
  print     "                                   Size  Boot   Rev" >> /tmp/sysinfo.$$.physinfoh
  print  -n " Volume Name       LU#   " >> /tmp/sysinfo.$$.physinfoh
  print     " H/W Path     Vendor  /  Model     (MB)  able  Level" >> /tmp/sysinfo.$$.physinfoh
  print  -n " --------------    --- " >> /tmp/sysinfo.$$.physinfoh
  print     " ------------  ------------------   -----  ----  -----" >> /tmp/sysinfo.$$.physinfoh
  print     "                                                          ======" >> /tmp/sysinfo.$$.physinfot
  print     "                                              Total (MB)${total_p_mb}" >> /tmp/sysinfo.$$.physinfot
  cat /tmp/sysinfo.$$.physinfo? > /tmp/sysinfo.$$.physinfod
  f_display_file /tmp/sysinfo.$$.physinfod
  f_display_file /tmp/sysinfo.$$.boot
  if (($PMAP))
  then
    f_display_file /tmp/sysinfo.$$.pmap
  fi
  
}                # end of f_get_physical_disk_data

#===================================================================
# f_get_ioscan_data
#===================================================================
function f_get_ioscan_data
{
  Debug "  calling check_if_scan_done"
  check_if_scan_done io_scan
  GREP_V_ARGS="-eboot_console $GREP_V_ARGS"
  if (($HTML))
  then
    print "
" >> /tmp/sysinfo.$$.ioout print "" >> /tmp/sysinfo.$$.ioout print "

" >> /tmp/sysinfo.$$.ioout print "

TOP

" >> /tmp/sysinfo.$$.ioout print "" >> /tmp/sysinfo.$$.ioout print "I/O Configuration Data

" >> /tmp/sysinfo.$$.ioout print "
"   >> /tmp/sysinfo.$$.ioout
  else
    print "I/O CONFIGURATION DATA" >> /tmp/sysinfo.$$.ioout
    print "======================" >> /tmp/sysinfo.$$.ioout
  fi
  print "" >> /tmp/sysinfo.$$.ioout
  print "      H/W Path       Driver  Identifier String" >>/tmp/sysinfo.$$.ioout
  print "      --------       ------  -----------------" >>/tmp/sysinfo.$$.ioout
 
  Debug "  `cat ${io_scan_out}`"
  if (( ${osmajor} >= 10 ))
  then
    Debug "found 10.x or later"
    Debug "sending $io_scan_out to formatter"
    Debug "  GREP_V_ARGS = $GREP_V_ARGS"

    cat $io_scan_out | weed_targets | formatter | \
        grep -F -v $GREP_V_ARGS >> /tmp/sysinfo.$$.ioout
  else
    Debug "found 9.x"
    cp ${io_scan_out} /tmp/sysinfo.$$.ioout
  fi
  Debug "  `cat /tmp/sysinfo.$$.ioout`"
  
  #rm -f $io_scan_tmp
  print "" >>/tmp/sysinfo.$$.ioout
  f_display_file /tmp/sysinfo.$$.ioout

}                # end of f_get_ioscan_data

#===================================================================
# f_get_volume_group_data
#        This function retrieves volume group data using vgdisplay
#        and by scannig /etc/lvmconf for config files.
#===================================================================
function f_get_volume_group_data
{
  Debug "Beginning VOLUME GROUP check."
  # first print header information

  if (($HTML))
  then
    print "
" >> /tmp/sysinfo.$$.vginfoh print "" >> /tmp/sysinfo.$$.vginfoh print "

" >> /tmp/sysinfo.$$.vginfoh print "

TOP

" >> /tmp/sysinfo.$$.vginfoh print "" >> /tmp/sysinfo.$$.vginfoh print "Volume Group Data

" >> /tmp/sysinfo.$$.vginfoh print "
"     >> /tmp/sysinfo.$$.vginfoh
  else
    print                     >> /tmp/sysinfo.$$.vginfoh
    print "VOLUME GROUP DATA" >> /tmp/sysinfo.$$.vginfoh
    print "=================" >> /tmp/sysinfo.$$.vginfoh
  fi
  Debug "  calling check_if_scan_done"
  check_if_scan_done lvm_scan

  vgdisplay -v > /tmp/sysinfo.$$.vgout 2>&1
  #MWR fix when PVG-strict policies used
  #all_volgroups=$(grep "VG Name" /tmp/sysinfo.$$.vgout | awk '{print $3}' | sort)
  all_volgroups=$(grep -v "PVG Name" /tmp/sysinfo.$$.vgout | \
     grep "VG Name" | awk '{print $3}' | sort)
  all_logvols=$(grep "LV Name" /tmp/sysinfo.$$.vgout | awk '{print $3}' | sort)
  #Debug "all_volgroups=\n$all_volgroups"
  #Debug "all_logvols=\n$all_logvols"
  
  for volgroup in ${all_volgroups}
  do
    Debug "Volumegroup = $volgroup"
    vgdisplay $volgroup > /tmp/sysinfo.$$.volgroup 2>&1
    #Debug "vgdisplay=\n`cat /tmp/sysinfo.$$.volgroup`"
    ((vgcount=vgcount + 1))
    CURLV=$(grep "Cur LV" /tmp/sysinfo.$$.volgroup | awk '{print $3}')
    CURPV=$(grep "Cur PV" /tmp/sysinfo.$$.volgroup | awk '{print $3}')
    AllocPe=$(grep "Alloc PE" /tmp/sysinfo.$$.volgroup | awk '{print $3}')
    FreePe=$(grep "Free PE" /tmp/sysinfo.$$.volgroup | awk '{print $3}')
    TotalPe=$(grep "Total PE" /tmp/sysinfo.$$.volgroup | awk '{print $3}')
    PeSize=$(grep "PE Size" /tmp/sysinfo.$$.volgroup | awk '{print $4}')
    ((AllocMb = AllocPe * PeSize))
    ((FreeMb = FreePe * PeSize))
    ((TotalMb = TotalPe * PeSize))
    ((TotalAllocMb = TotalAllocMb + AllocMb))
    ((TotalFreeMb = TotalFreeMb + FreeMb))
    ((SystemTotalMb = SystemTotalMb + TotalMb))
    Debug "  Physical Extent Size = ${PeSize}"
    Debug "  Number of Allocated Physical Extents = ${AllocPe}"
    Debug "  Free Physical Extents = ${FreePe}"
    Debug "  Total Physical Extents = ${TotalPe}"
    Debug "  Allocated Mb = ${AllocMb}"
    Debug "  Free Mb = ${FreeMb}"
    Debug "  Total Mb = ${TotalMb}"
    Debug "  Total Allocated Mb = ${TotalAllocMb}"
    Debug "  Total Free Mb = ${TotalFreeMb}"
    Debug "  System Total Mb = ${SystemTotalMb}"
    print -n "."
    print -n "${volgroup}${CURLV}${CURPV}${PeSize}" >> /tmp/sysinfo.$$.vginfos
    print    "${AllocMb}${FreeMb}${TotalMb}" >> /tmp/sysinfo.$$.vginfos
  done
  print  
  Debug "Checking for vgcount = maxvgs"
  if [[ -z $maxvgs ]]
  then
    maxvgs=$(echo 'maxvgs/D'|adb $kernel /dev/kmem \
             | tail -1 | awk '{print $2}')
  fi
  Debug " vgcount = $vgcount"
  Debug " maxvgs = $maxvgs"
  if ((vgcount == maxvgs))
  then
    if ((! (($exit_code)) ))
    then
      exit_code=${WARN}
    fi
    print "WARNING (${sysname}): number of volume groups is at maximum."\
           >> /tmp/sysinfo.$$.novgcfg
  fi
  
# now check for a cfg backup file for each volume group.

  print -n "scanning config files "
  Debug "Checking vg config files"
  for volgroup in ${all_volgroups}
  do
    Debug "  volgroup ${volgroup}"
    vg=$(echo ${volgroup} | awk -F/ '{print $3}')
    print -n "."
    if [ -f /etc/lvmconf/${vg}.conf ]
    then
      # this is a kludge. if file is less than 6 months old then 
      # ls -l prints the time, so scan for a colon.
      ls -l /etc/lvmconf/${vg}.conf | awk '{print $8}' | grep ":" > /dev/null
      if (($?))
      then
        if ((! (($exit_code)) ))
        then
          exit_code=${WARN}
        fi
        print "WARNING (${sysname}): vgconfig file > 6 months old for /etc/lvmconf/${vg}.conf"\
               >> /tmp/sysinfo.$$.novgcfg
      fi
    else
      if ((! (($exit_code)) ))
      then
        exit_code=${WARN}
      fi
      print -n "WARNING (${sysname}): no config " >> /tmp/sysinfo.$$.novgcfg
      print    "file found for volume group ${vg}." >> /tmp/sysinfo.$$.novgcfg
      if ((! (($exit_code)) ))
      then
        exit_code=${WARN}
      fi
    fi
  done
  print  ""
  f_display_file /tmp/sysinfo.$$.novgcfg 
  print    "" >> /tmp/sysinfo.$$.vginfoh
  print    " Volume               Logical  Physical  Extent   MBs of Physical Space" >> /tmp/sysinfo.$$.vginfoh
  print    " Group                Volumes  Volumes  Size(MB)  Alloc    Free   Total"  >> /tmp/sysinfo.$$.vginfoh
  print    " ---------            -------  --------  ------   -----    ----   -----"  >> /tmp/sysinfo.$$.vginfoh
  print    "                                                  =====    ====   =====" >> /tmp/sysinfo.$$.vginfot
  print -n "                                        Totals " >> /tmp/sysinfo.$$.vginfot
  print     "${TotalAllocMb}${TotalFreeMb}${SystemTotalMb}" >> /tmp/sysinfo.$$.vginfot
  cat /tmp/sysinfo.$$.vginfo? > /tmp/sysinfo.$$.vginfod
  f_display_file /tmp/sysinfo.$$.vginfod

} # end of f_get_volume_group_data

#===================================================================
# f_get_logical_volume_data
#        This function uses lvdisplay to scan logical volumes.
#        It retrieves information about the logvol and also checks
#        for stale mirrors (if used).
#===================================================================
function f_get_logical_volume_data
{
  Debug "Beginning LOGICAL DISK check."
  # first print out header information
  
  if (($HTML))
  then
    print "
" >> /tmp/sysinfo.$$.lvinfoh print "" >> /tmp/sysinfo.$$.lvinfoh print "

" >> /tmp/sysinfo.$$.lvinfoh print "

TOP

" >> /tmp/sysinfo.$$.lvinfoh print "" >> /tmp/sysinfo.$$.lvinfoh print "Logical Volume And Extent Data

" >> /tmp/sysinfo.$$.lvinfoh print "
"           >> /tmp/sysinfo.$$.lvinfoh
  else
    print                                     >> /tmp/sysinfo.$$.lvinfoh
    print  "LOGICAL VOLUME AND EXTENT DATA"   >> /tmp/sysinfo.$$.lvinfoh  
    print  "=============================="   >> /tmp/sysinfo.$$.lvinfoh
  fi
  Debug "  calling check_if_scan_done"
  check_if_scan_done lvm_scan
  
  print -n "scanning logical volumes "
  if [[ ! -f /tmp/sysinfo.$$.vgout ]]
  then
    vgdisplay -v > /tmp/sysinfo.$$.vgout 2>&1
    all_volgroups=$(grep "VG Name" /tmp/sysinfo.$$.vgout | awk '{print $3}' | sort)
    all_logvols=$(grep "LV Name" /tmp/sysinfo.$$.vgout | awk '{print $3}' | sort)
  fi
  for logvol in ${all_logvols}
  do
    Debug "lvdisplay of ${logvol}"
    lvdisplay -v ${logvol} > /tmp/sysinfo.$$.logical 2>&1
    STATUS=$(grep "LV Status" /tmp/sysinfo.$$.logical | awk '{print $3}')
    LVSize=$(grep "LV Size" /tmp/sysinfo.$$.logical | awk '{print $4}')
    LogicalExtents=$(grep "Current LE" /tmp/sysinfo.$$.logical \
                  | awk '{print $3}')
    StaleExtents=$(grep stale /tmp/sysinfo.$$.logical | wc -l)
    MirrorCopies=$(grep "Mirror copies" /tmp/sysinfo.$$.logical \
                  | awk '{print $3}')
    Consistency=$(grep "Consistency Recovery" /tmp/sysinfo.$$.logical \
                  | awk '{print $3}')
  
  
    ((total_l_mb = total_l_mb + LVSize))
    ((MirrorMb = LVSize * MirrorCopies))
    ((TotalMirrorMb = TotalMirrorMb + MirrorMb))
    
  # check to make sure lvol has extents allocated to it
    if (( $LogicalExtents > 0 ))                 
    then
      MOUNT=$(cat /etc/mnttab | grep ${logvol} | cut -f 2 -d" ")
      if [[ ${swap_devs} = *${logvol}* ]]
      then
        MOUNT="(swapdisk)"
      fi
      ((lcount=lcount + 1))
      if (( ${StaleExtents} > 0 ))        # we found stale extents
      then
        Debug " Found ${StaleExtents} STALE extents on ${logvol}!"
        stale=1
        ((StaleMB = (LVSize / LogicalExtents) * StaleExtents ))
        ((TotalStaleMb = TotalStaleMb + StaleMB))
        ((total_stale = $total_stale + $StaleExtents))
      fi                                # end of stale extents
    else                                # no extents allocated
      if ((! (($exit_code)) ))
      then
        exit_code=$WARN
      fi
      zero_length=1
      print -n "\nWARNING (${sysname}): Detected logical " >> /tmp/sysinfo.$$.nolvext
      print "volume (${logvol}) with no extents!\n" >> /tmp/sysinfo.$$.nolvext
    fi                                # end of check for allocated extents
    Debug "  STATUS= ${STATUS}"
    Debug "  LVSize= ${LVSize}"
    Debug "  LogicalExtents = ${LogicalExtents}"
    Debug "  StaleExtents = ${StaleExtents}"
    Debug "  StaleMb= $StaleMB"
    Debug "  TotalStaleMb= $TotalStaleMb "
    Debug "  TotalMb checked= $total_l_mb"

# now let's print out the results.
    print -n "."
    print -n "${logvol}                       " >> /tmp/sysinfo.$$.lvinfos
    print    "${MOUNT}"             >> /tmp/sysinfo.$$.lvinfos
    #print    "${LogicalExtents}${StaleExtents}" >> /tmp/sysinfo.$$.lvinfos
    #print    "${MirrorCopies}${Consistency}"    >> /tmp/sysinfo.$$.lvinfos
  done                                
# end of loop for all log vols
# now print out any errors or warnings.
  f_display_file /tmp/sysinfo.$$.nolvext 
# print    "" >> /tmp/sysinfo.$$.lvinfoh
  print    "                                     "  >> /tmp/sysinfo.$$.lvinfoh
  print -n " Volume Name                          " >> /tmp/sysinfo.$$.lvinfoh
  print    "Mounted File System"  >> /tmp/sysinfo.$$.lvinfoh
  print -n " --------------                       " >> /tmp/sysinfo.$$.lvinfoh
  print -- "--------------------"  >> /tmp/sysinfo.$$.lvinfoh
  print    "" >> /tmp/sysinfo.$$.lvinfos
  cat /tmp/sysinfo.$$.lvinfo? > /tmp/sysinfo.$$.lvinfod
  f_display_file /tmp/sysinfo.$$.lvinfod 


# test display using batch lvm_scan
  print    "" > /tmp/sysinfo.$$.lvinfoh
  print -n "                                 "  >> /tmp/sysinfo.$$.lvinfoh
  print    "  Size   Stripes    Mirrors   " >> /tmp/sysinfo.$$.lvinfoh
  print -n " Volume Name                     "  >> /tmp/sysinfo.$$.lvinfoh
  print    "  (MB)    # Size    #  Const  Status" >> /tmp/sysinfo.$$.lvinfoh
  print -n " --------------                  "  >> /tmp/sysinfo.$$.lvinfoh
  print    " -----   -------   ---------  ----------"  >> /tmp/sysinfo.$$.lvinfoh
  f_display_file /tmp/sysinfo.$$.lvinfoh
  f_display_file $lvol_out_file
  if (($BATCH))
  then
    print
  fi

}         # end of f_get_logical_volume_data


#===================================================================
# f_logical_to_physical
#        This function produces a cross reference of physical disks
#        for each logical volume.
#===================================================================
function f_logical_to_physical
{
  Debug "Beginning LOGICAL TO PHYSICAL Mapping."
  
  if [[ ! -f /tmp/sysinfo.$$.vgout ]]
  then
    Debug "/tmp/sysinfo.$$.vgout not found....building."
    vgdisplay -v > /tmp/sysinfo.$$.vgout 2>&1
    all_logvols=$(grep "LV Name" /tmp/sysinfo.$$.vgout | awk '{print $3}' |sort)
  fi
  if (($HTML))
  then
    print "
" >> /tmp/sysinfo.$$.l2p print "" >> /tmp/sysinfo.$$.l2p print "

" >> /tmp/sysinfo.$$.l2p print "

TOP

" >> /tmp/sysinfo.$$.l2p print "" >> /tmp/sysinfo.$$.l2p print "Logical Volume To Physical Disk Mapping

" >> /tmp/sysinfo.$$.l2p print "
"             >> /tmp/sysinfo.$$.l2p
  else
    print    "" >> /tmp/sysinfo.$$.l2p
    print    "LOGICAL VOLUME TO PHYSICAL DISK MAPPING                 " >> /tmp/sysinfo.$$.l2p
    print    "=========================================================" >> /tmp/sysinfo.$$.l2p
  fi
  print "Logical Volume" >> /tmp/sysinfo.$$.l2p
  print " extents  Primary disk     Mirror Disk 1    Mirror Disk 2" >> /tmp/sysinfo.$$.l2p
  print -- "---------------------------------------------------------" >> /tmp/sysinfo.$$.l2p
  print -n "generating disk mappings "

  for logvol in ${all_logvols}
  do
    Debug "  scanning ${logvol}"
    lvdisplay -v ${logvol} > /tmp/sysinfo.$$.logical 2>&1
    PhysicalDisks=$(awk '$1 ~ /\/dev\/dsk\/.*/ {printf "%s\n",$1}' \
                     /tmp/sysinfo.$$.logical \
                     | sed -e 's/\/dev\/dsk\///' | sort)
    # output physical disk data for each logical volume
    print    "${logvol}    " >> /tmp/sysinfo.$$.l2p
#   print -n "     Disks = " >> /tmp/sysinfo.$$.l2p

# count the number of physical disks found.
    diskcount=0
    for disk in ${PhysicalDisks}
    do
      ((diskcount = diskcount + 1))
    done
    Debug "    found $diskcount physical disks"
    lvdisplay -v $logvol | sed '1,/   LE/d' | awk '{print $2, $5, $8}' \
                     | sort | grep "dev" | uniq -c | awk \
                     '{printf "%6s %18s %16s %16s\n",$1,$2,$3,$4}' \
                     >> /tmp/sysinfo.$$.l2p
#   print "" >> /tmp/sysinfo.$$.l2p
    print -n "."
  done
  print "" >> /tmp/sysinfo.$$.l2p
  f_display_file /tmp/sysinfo.$$.l2p 
  print  ""

}        # end of f_logical_to_physical


#===================================================================
# f_filesystem_check
#        This function checks mounted filesystems and reports 
#        capcity information. It prints warnings if greater than
#        95% full.
#===================================================================

function f_filesystem_check
{
  Debug "Beginning FILE SYSTEM check."

  # first print out headers
  if (($HTML))
  then
    print "
" >> /tmp/sysinfo.$$.bdf_outh print "" >> /tmp/sysinfo.$$.bdf_outh print "

" >> /tmp/sysinfo.$$.bdf_outh print "

TOP

" >>/tmp/sysinfo.$$.bdf_outh print "" >> /tmp/sysinfo.$$.bdf_outh print "File System Data

" >> /tmp/sysinfo.$$.bdf_outh print "
" >> /tmp/sysinfo.$$.bdf_outh
  else
    print    "" >> /tmp/sysinfo.$$.bdf_outh
    print    "FILE SYSTEM DATA" >> /tmp/sysinfo.$$.bdf_outh
    print    "================" >> /tmp/sysinfo.$$.bdf_outh
  fi
  print -n "scanning filesystems "

  typeset -R10 kbytes used avail iused ifree
  typeset -R5 percent_used
# if [[ ! -f /tmp/sysinfo.$$.vgout ]]
# then
#   vgdisplay -v > /tmp/sysinfo.$$.vgout 2>&1
#   all_volgroups=$(grep "VG Name" /tmp/sysinfo.$$.vgout | awk '{print $3}' | sort)
#   all_logvols=$(grep "LV Name" /tmp/sysinfo.$$.vgout | awk '{print $3}' | sort)
# fi
  mnttab=$(cat /etc/mnttab | grep /dev  | awk '{printf "%s\n", $2}')
  num_fs=$(bdf -il | wc -l)
  ((num_fs = num_fs -1))
  Debug "Found $num_fs mounted file systems"
# bdf -i | tail -${num_fs} > /tmp/sysinfo.$$.bdf_data 2>&1
  for mounted in ${mnttab}
  do
    bdf -i ${mounted} | tail -1 > /tmp/sysinfo.$$.bdf_data 2>&1
    fs_type=$(cat /etc/mnttab | grep " ${mounted} " | awk '{printf "%s\n", $3}')
    Debug "filesys = ${mounted}  fs_type = ${fs_type}"
    Debug "  `cat /tmp/sysinfo.$$.bdf_data`"
    kbytes=$(awk '{if (NF == 9) print $2; else print $1}' /tmp/sysinfo.$$.bdf_data) 
    used=$(awk '{if (NF == 9) print $3; else print $2}' /tmp/sysinfo.$$.bdf_data)
    if [[ $fs_type  != "cdfs" ]]
    then
      avail=$(awk '{if (NF == 9) print $4; else print $3}' /tmp/sysinfo.$$.bdf_data)
      iused=$(awk '{if (NF == 9) print $6; else print $5}' /tmp/sysinfo.$$.bdf_data)
      ifree=$(awk '{if (NF == 9) print $7; else print $6}' /tmp/sysinfo.$$.bdf_data)
      #((percent_used = (used * 100) / (used + avail) ))
      percent_used=$(echo $used $avail | \
	awk '{ used = $1
               avail = $2
               pct_used =  ($1 * 100) / ($1 + $2)
               printf("%d", pct_used)
	      } ' )

      if (($percent_used > 95)) && [[ $fs_type  != "cdfs" ]]
      then
        if ((! (($exit_code)) ))
        then
          exit_code=${WARN}
        fi
        print "WARNING (${sysname}): ${mounted} has less than 5% free space left!" >> /tmp/sysinfo.$$.bdf_warn
      fi
    else #must be a cdrom, so don't calculate free space
      avail=0
      iused="-"
      ifree="-"
      percent_used="-"
    fi
    print "${mounted}" >> /tmp/sysinfo.$$.bdf_outs
    print "              ${fs_type} ${kbytes}${used}${avail}${percent_used}${iused}${ifree}" >> /tmp/sysinfo.$$.bdf_outs
    print -n "."
  done
  print "" >> /tmp/sysinfo.$$.bdf_outs
  print    "Mounted" >> /tmp/sysinfo.$$.bdf_outh
  print -n "Filesystems   Type     Kbytes      Used     Avail" >> /tmp/sysinfo.$$.bdf_outh
  print    "   %      Iused     Ifree" >> /tmp/sysinfo.$$.bdf_outh
  print -n " ----------   ----     ------    ------    ------" >> /tmp/sysinfo.$$.bdf_outh
  print -- "  ---     -----     -----" >> /tmp/sysinfo.$$.bdf_outh
  cat /tmp/sysinfo.$$.bdf_out? > /tmp/sysinfo.$$.bdf_outd
  f_display_file /tmp/sysinfo.$$.bdf_outd 
  f_display_file /tmp/sysinfo.$$.bdf_warn 
  print ""

}        # end of f_filesystem_check

#===================================================================
# f_disk_capacity
#        This function displays total disk, group, and lvol capacities.
#        The data comes from the logical, physical, & volume functions.
#        Therefore, this function does not stand alone. It must be run
#        with the l, p, & v options.
#===================================================================
function f_disk_capacity
{
  Debug "Beginning DISK CAPACITY calculations."
  if (($HTML))
  then
    print "
" >> /tmp/sysinfo.$$.capacity print "" >> /tmp/sysinfo.$$.capacity print "

" >> /tmp/sysinfo.$$.capacity print "

TOP

" >>/tmp/sysinfo.$$.capacity print "" >> /tmp/sysinfo.$$.capacity print "Disk Capacity Data

" >> /tmp/sysinfo.$$.capacity print "
" >> /tmp/sysinfo.$$.capacity
  else
    print "DISK CAPACITY DATA" >> /tmp/sysinfo.$$.capacity
    print "==================" >> /tmp/sysinfo.$$.capacity
  fi
  ((unused_cap = total_p_mb - TotalAllocMb))
  ((OtherMb = TotalAllocMb - total_l_mb - TotalMirrorMb))
  print "Logical Volume Space  = $total_l_mb MB" >> /tmp/sysinfo.$$.capacity
  print "Mirror Space          = $TotalMirrorMb MB" >> /tmp/sysinfo.$$.capacity
  print "Other Space Allocated = $OtherMb MB" >> /tmp/sysinfo.$$.capacity
  print "                          ---------" >> /tmp/sysinfo.$$.capacity
  print "Total Disk Allocated  = $TotalAllocMb MB" >> /tmp/sysinfo.$$.capacity
  print "Unallocated Disk      = $unused_cap MB" >> /tmp/sysinfo.$$.capacity
  print "                          =========" >> /tmp/sysinfo.$$.capacity
  print "Total Physical Disk   = $total_p_mb MB\n" >> /tmp/sysinfo.$$.capacity

  print "Checked:" >> /tmp/sysinfo.$$.capacity
  print "${pcount} physical volumes" >> /tmp/sysinfo.$$.capacity
  print "${vgcount} volume groups" >> /tmp/sysinfo.$$.capacity
  print "${lcount} logical volumes" >> /tmp/sysinfo.$$.capacity

  Debug "  found ${pcount} physical volumes"
  Debug "  found ${vgcount} volume groups"
  Debug "  found ${lcount} logical volumes"
  
  if  ((${stale}))
  then
    Debug "found ${total_stale} STALE extents"
    Debug "  calculating re-syncing time"
    exit_code=${SYS_ERROR}
    print -n "\n\nERROR:${sysname}: ${total_stale}" >> /tmp/sysinfo.$$.capacity
    print    " stale extents detected.\n" >> /tmp/sysinfo.$$.capacity
    print -n "Estimated time to re-sync ${total_stale}" >> /tmp/sysinfo.$$.capacity
    print    " stale extents is" >> /tmp/sysinfo.$$.capacity
    if ((${TotalStaleMb} < 100))
    then
      print " less than 1 minute." >> /tmp/sysinfo.$$.capacity
      Debug " less than 1 minute" 
    else
      ((TIME = TotalStaleMb / 100))
      ((HOURS = TIME /60))
      ((MINUTES = TIME % 60))
      print " ${HOURS} hours and ${MINUTES} minutes." >> /tmp/sysinfo.$$.capacity
      Debug " ${TIME} total minutes or" 
      Debug "     ${HOURS} hours and ${MINUTES} minutes" 
    fi
    print >> /tmp/sysinfo.$$.capacity
  else
    print "with no stale extents detected.\n"   >> /tmp/sysinfo.$$.capacity
    Debug "No stale extents detected"
  fi
  f_display_file /tmp/sysinfo.$$.capacity

}                 # end of f_disk_capacity


#===================================================================
# f_check_root
#        This function checks to see if the user is root.
#===================================================================
function f_check_root
{
  id | grep '(root)' > /dev/null
  if (($?))
  then
    print "\nYou must be super-user to run ${script}.\n"
    exit ${ERROR}
  fi
}                # end of check_root

#===================================================================
# f_check_hpux
#        This function checks to see if running on HP-UX
#===================================================================
function f_check_hpux
{
  uname -s | grep HP-UX > /dev/null
  if (($?))
  then
    print "\nThis utility is only supported on HP-UX systems!\n"
    exit ${ERROR}
  fi
}                # end of check_hpux


#===================================================================
# BEGIN MAIN CODE
#===================================================================
typeset -fx lvm_scan
typeset -fx sam_scan
typeset -fx io_scan
typeset -fx f_query_sam
sysname=$(hostname)
where=`dirname ${0}`
f_check_hpux
f_check_root
get_args $*
if (($BATCH))
then
  print "\n${script} ${version} by Scott Truesdale\n"
  if (($HTML))
  then
    print ""                                 >> $LOGFILE
    print "Sysinfo for ${sysname}"        >> $LOGFILE
    print ""              >> $LOGFILE
    print "
" >> $LOGFILE print "" >> $LOGFILE print "Configuration Data for" >> $LOGFILE print "${sysname}
" >> $LOGFILE print "Collected on `date`.
" >> $LOGFILE print "
" >> $LOGFILE print "${script} ${version} " >> $LOGFILE print "by Scott Truesdale
" >> $LOGFILE print "System" >> $LOGFILE print "Kernel" >> $LOGFILE print "Network" >> $LOGFILE print "File System" >> $LOGFILE print "
" >> $LOGFILE print "IO Configuration" >> $LOGFILE print "Physical Disks" >> $LOGFILE print "Physical Mapping" >> $LOGFILE print "Volume Groups" >> $LOGFILE print "
" >> $LOGFILE print "Logical Disks" >> $LOGFILE print "Logical Mapping" >> $LOGFILE print "Disk Capacity" >> $LOGFILE print "Software List" >> $LOGFILE print "
" >> $LOGFILE else print "\n${script} ${version} by Scott Truesdale\n" >> $LOGFILE print "Configuration data for ${sysname}\ncollected on `date`\n" >> $LOGFILE fi else print "\n${script} ${version} by Scott Truesdale\n" print "Configuration data for ${sysname}\ncollected on `date`.\n" fi #=================================================================== # SYSTEM CHECK AND ROOT DATA #=================================================================== f_get_sys_type if (($SYSTEM)) then f_get_system_data fi #=================================================================== # KERNEL DATA #=====