Listing 2

#!/bin/ksh
#/*  start_doc  */
#/***********************************************************************
#*                     Program Information                              *
#*                                                                      *
#* Program Name        : Inventory-Long                                 *
#* Date Written        : 03/08/01                                       *
#* Author              : William D. Wood                                *
#* System              : IBM SP                                         *
#* Subsystem           : Administration                                 *
#* Example             : Inventory-Long > result 2>&1                   *
#* Purpose             : Create listing of current system configuration *
#* 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                         *
#***********************************************************************/
#/*  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 "CPU Information" "uname -a"
   display_info "OS Level" "oslevel"
   display_info "OS Maintenance Level" "instfix -i | grep AIX_ML"
}

################################################################################
##
##  Subroutine: List information about volume groups
##
################################################################################
list_vgs ()
{
   print "========================"
   print "VOLUME GROUP INFORMATION"
   print "========================"
   print ""
   display_info "List of All Volume Groups" "lsvg"
   display_info "List of Varied On Volume Groups" "lsvg -o"
   VOLS="$(lsvg -o)"
   for i in $VOLS
   do
      display_info "Volume Layout of $i" "lsvg $i"
      display_info "Physical Layout of $i" "lsvg -p $i"
      display_info "Logical Layout of $i" "lsvg -l $i"
   done
  
   return 0
}


################################################################################
##
##  Subroutine: List information about logical volumes
##
################################################################################
list_lvs ()
{
   print "=========================="
   print "LOGICAL VOLUME INFORMATION"
   print "=========================="
   print ""
   VOLS="$(lsvg -o)"
   for i in $VOLS
   do
      LVS="$(lsvg -l $i | tail +3 | awk '{print $1}')"
      for j in $LVS
      do
         display_info "Logical Volume layout of $i" "lslv -l $j; print; lslv $j"
      done
   done
  
   return 0
}

################################################################################
##
##  Subroutine: List information about physical volumes
##
################################################################################
list_pvs ()
{
   print ""
   print "==========================="
   print "PHYSICAL VOLUME INFORMATION"
   print "==========================="
   print ""
   display_info "List of physical volumes" "lspv"
   VOLS="$(lspv | awk '{print $1}')"
   for i in $VOLS
   do
      display_info "Information for $i" "lspv $i"
      display_info "Logical Layout of $i" "lspv -l $i"
      display_info "Physical layout of $i" "lspv -p $i"
   done

   return 0
}


################################################################################
##
##  Subroutine: List startup information (/etc/inittab and rc.local)
##
################################################################################
list_startup ()
{
   print ""
   print "==================="
   print "STARTUP INFORMATION"
   print "==================="
   print ""
   display_info "Inittab File" "lsitab -a"
   if [ -f /etc/rc.local ]
   then
     display_info "/etc/rc.local File" "cat /etc/rc.local"
   else
     display_info "/etc/rc.local File" "print \"No rc.local file exists\" "
   fi

   return 0
}


################################################################################
##
##  Subroutine: List filesystem information
##
################################################################################
list_fs ()
{
   print ""
   print "======================"
   print "FILESYSTEM INFORMATION"
   print "======================"
   print ""
   display_info "List of filesystems" "lsfs"
   display_info "List of /etc/filesystems" "cat /etc/filesystems"

   return 0
}


################################################################################
##
##  Subroutine: List paging spaces
##
################################################################################
list_ps ()
{
   print ""
   print "========================"
   print "PAGING SPACE INFORMATION"
   print "========================"
   print ""
   display_info "Size of Real Memory" "lsattr -El sys0 -a realmem"
   display_info "List of Paging Spaces" "lsps -a"
   display_info "Paging Space Summary" "lsps -s"

   return 0
}


################################################################################
##
##  Subroutine: List user and group information
##
################################################################################
list_users ()
{
   print ""
   print "======================"
   print "USER/GROUP INFORMATION"
   print "======================"
   print ""
   display_info "Group Information" "lsgroup ALL"
   display_info "User Information" "lsuser ALL"

   return 0
}

################################################################################
##
##  Subroutine: List network information
##
################################################################################
list_net ()
{
   print ""
   print "==================="
   print "NETWORK INFORMATION"
   print "==================="
   print ""
   display_info "Network Information" "netstat -in"
   display_info "Network Route Information" "netstat -rn"
   NETS=$(netstat -in | tail +2 | awk '{print $1}' | uniq)
   for i in $NETS
   do
     display_info "Interface Configuration" "ifconfig $i"
   done
   display_info "Host Information" "cat /etc/hosts"
  
}

################################################################################
##
##  Subroutine: List network tunning parameters
##
################################################################################
list_no ()
{
   print ""
   print "============================"
   print "NETWORK OPTIONS INFORMATION"
   print "============================"
   print ""
   display_info "Network Options Information" "no -a"

   return 0
}


################################################################################
##
##  Subroutine: List licensed product information
##
################################################################################
list_lpp ()
{
   print ""
   print "============================"
   print "LICENSED PRODUCT INFORMATION"
   print "============================"
   print ""
   display_info "Licensed Program Products" "lslpp -L"

   return 0
}


################################################################################
##
##  Subroutine: List Device information
##
################################################################################
list_devs ()
{
   print ""
   print "==========================="
   print "DETAILED DEVICE INFORMATION"
   print "==========================="
   print ""
   display_info "Installed Resources" "lscfg -v"
   display_info "Customized Devices" "lsdev -C | sort"
   DEVS=$(lsdev -C | sort  | awk '{print $1}')
   for i in $DEVS
   do
      display_info "$i" "lsattr -F \"attribute value description\" -l $i"
   done

   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

## List volume group information
list_vgs

## List Logical Volume Information
list_lvs

## List Physical Volume information
list_pvs

## List Startup information 
list_startup

## List filesystem information
list_fs

## List Paging Spaces
list_ps 

## List user and group information
list_users

##  List network information
list_net

##  List network tuning information
list_no

## List Device information
list_devs

## List licensed production information
list_lpp

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

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



