Listing 3

#!/bin/ksh
#/*  start_doc  */
#/***********************************************************************
#*                     Program Information                              *
#*                                                                      *
#* Program Name        : Inventory-Short                                *
#* Date Written        : 03/08/01                                       *
#* Author              : William D. Wood                                *
#* System              : IBM                                            *
#* Subsystem           : Administration                                 *
#* Example             : Inventory-Short > result 2>&1                  *
#* Purpose             : Create listing of system options               *
#* Description         : Uses AIX commands to list pertinent system     *
#*                       information into a single file                 *
#*                                                                      *
#************************************************************************
#*                        Revision History                              *
#*                                                                      *
#*  Name       Date      Revision                                       *
#*             Revised   Description/Authorization                      *
#* --------    --------  ---------------------------------------------- *
#* woodwd      03/08/01  Created initial script                         *
#*                                                                      *
#***********************************************************************/
#*                       Temporary Files Written                        *
#*                                                                      *
#* Filename                                     Removed when done       *
#* -------------------------------------------  ----------------------- *
#* /tmp/emcdisk.out                             yes                     *
#*                                                                      *
#***********************************************************************/
#*                                                                      *
#/*  end_doc  */
#*                                                                      *
 
 
################################################################################
##
##  Subroutine: Exit program upon operator request or if error encountered
##
################################################################################
exit_prog ()
{
  print ""
  print "Exiting program '$PROGNAME'.  Exit code = 1"
  print "Program exited on $(date '+%a, %h %d at %r')"
  print ""
  print "Thank you."
  print ""
  exit 1
}


################################################################################
##
##  Subroutine: Exit program upon interrupt request (^C)
##
################################################################################
exit_break ()
{
  print ""
  print ""
  print "Exiting program '$PROGNAME' abnormally due to interrupt request!"
  print "Please re-run program."
  print ""
  print "Program exited on $(date '+%a, %h %d at %r')"
  print ""
  print "Thank you."
  print ""
  exit 1
}

################################################################################
##
##  Subroutine: List information about CPU/version
##
################################################################################
list_machine ()
{
   print "============================"
   print "MACHINE-SPECIFIC INFORMATION"
   print "============================"
   print ""
   display_info "Hostname Information" "hostname"
   display_info "IP Address Assigned" "grep "$(hostname)" /etc/hosts | cut -f1"
   display_info "Serial Number" "lsattr -El sys0 -a systemid | cut -c18-22"
   display_info "OS System" "uname"
   display_info "OS Version" "oslevel"
   display_info "OS Maintenance Level" "instfix -i | grep AIX_ML | tail -1"
   #display_info "System Model Number" "lsattr -El sys0 -a modelname | cut -c15-23"
   display_info "System Model Number" "uname -M | cut -d, -f2"
   display_info "Number of CPU's" "lsdev -C | grep proc | wc -l"
   cpu_info
   display_info "Processor Speed" "echo $CPU_speed"
   display_info "Processor Type" "echo $Processor_type"
   display_info "RAM Installed" "lsattr -El sys0 -a realmem"
   Physical_diskspace
   display_info "Available disk space" "echo $total_disk_space"
#   display_info "RAID Level Running" "lsattr -El sys0 -a realmem"
}

################################################################################
##
##  Subroutine: get information about cpu speeds for NSI systems
##
################################################################################
cpu_info ()
{
   xx=`uname -m | cut -c1-2`
   yyyyyy=`uname -m | cut -c3-8`
   mm=`uname -m | cut -c9-10`
   ss=`uname -m | cut -c11-12`
   System_model=`uname -M | cut -d, -f2`

   case $System_model in
	7043-150)
		CPU_speed="375"
		Processor_type="PowerPC"
		;;
	7043-250)
		CPU_speed="166/233"
		Processor_type="PowerPC"
		;;
	7046-B50)
		CPU_speed="375"
		Processor_type="RS64-II"
		;;
	7026-H70)
		CPU_speed="340"
		Processor_type="RS64-II"
		;;
	7026-M80)
		CPU_speed="500"
		Processor_type="RS64-III"
		;;
	7017-S70)
		CPU_speed="125"
		Processor_type="RS64"
		;;
	7017-S7A)
		CPU_speed="262"
		Processor_type="RS64-II"
		;;
	7017-S80)
		CPU_speed="450"
		Processor_type="RS-III"
		;;
	7017-S85)
		CPU_speed="600"
		Processor_type="RS64IV"
		;;
	*)
		CPU_speed="cannot determine"
		Processor_type="cannot determine"
		;;
  esac
 
   return 0
}


################################################################################
##
##  Subroutine: Return information on Physical disk drives storage space
##
################################################################################
Physical_diskspace ()
{

   integer IBM_disk
   integer EMC_disk
   integer disk_space
   disk_space=0

   if `lsdev -Cc disk | grep power > /dev/null`

   then

   /usr/lpp/Symmetrix/bin/inq -no_dots -f_real  > /tmp/emcdisk.out
   for EMC_disk in `grep disk /tmp/emcdisk.out | cut -d: -f6`
   do
   disk_space=`expr $EMC_disk + $disk_space`
   done
   rm /tmp/emcdisk.out

   else

   for IBM_HDISK in `lsdev -Cc disk | grep -v power | cut -dA -f1`
   do
   IBM_disk=`lscfg -vl $IBM_HDISK | grep disk | cut -d\( -f2 | cut -dM -f1`
   disk_space=`expr $IBM_disk + $disk_space`
   done

   fi

   total_disk_space="$disk_space megabytes"

   return 0
}

################################################################################
##
##  Subroutine: Display command information in a nice format
##
################################################################################
display_info ()
{
   print "$1 [$2] \n------------------------------------------------------------------------------ \n$(eval $2)\n"
   return 0
}


#########################################################################
##
##  MAIN PROGRAM
##
#########################################################################
PROGNAME=$0

print "Program started on $(hostname) on $(date '+%a, %h %d at %r')"
print ""

#########################################################################
##
##  Trap for a ^C break; send to separate function
##
#########################################################################
trap exit_break 2

## List Machine/Version Information
list_machine

print ""
print "Program completed on $(hostname) on $(date '+%a, %h %d at %r')"
print ""

##
##  Exit with a successful status; Program completed
##
exit 0



