#!/bin/bash
#
# Collect EED
#
# Description: Issue to Collect EED for the machinne
#
# Change Activity:
#   02/29/2004 Maui        - initial version
#   04/04/2004 Maui        - fix up the file processing
#
#STARTUSAGE
#
# Usage:
#   collecteed -m machine -d directory
#
# Where:
#   -m   The machine to collect the data for.  It must be of the format type*mode/serial.
#
#   -d   The directory to place the results into.  The results file will be called eed.results
#
#ENDUSAGE
#****************************************************************************
noopt=1
giveUsage=0

echo the parms are "$1"

# Parse the options
while getopts 'm:d:?' optname; do
   case "$optname" in
      m) machine="$OPTARG";;
      d) directory="$OPTARG";;
      \?) giveUsage=1; break;;
   esac
   noopt=0
done

if [ "$giveUsage" -eq 1 ]; then
   # Print out the prologue comments as usage info
   sed -e '/STARTUSAGE/,/ENDUSAGE/ s/^#//' -e '1,/STARTUSAGE/ d' -e '/ENDUSAGE/,$ d' "$0"
   exit 0
fi

if [ "$noopt" -eq 1 ]; then
   # Print out the prologue comments as usage info
   sed -e '1 d' -e '2,/ENDUSAGE/ s/^#//' -e '/ENDUSAGE/,$ d' "$0"
   exit 0
fi

# get the partition map
lssyscfg -r lpar -m $machine > $directory/PMA.dat
lshwres -r proc -m $machine --level lpar >> $directory/PMA.dat
lshwres -r mem -m $machine --level lpar >> $directory/PMA.dat
lshwres -r io -m $machine --rsubtype slot >> $directory/PMA.dat
# get the rest of the data
lsdump -m $machine > $directory/SYS.dat
lssyscfg -r sys -m $machine >> $directory/SYS.dat
lssyscfg -m $machine -r sys >> $directory/SYS.dat
lssyscfg -m $machine -r lpar >> $directory/SYS.dat
lssyscfg -m $machine -r sysprof >> $directory/SYS.dat
exit 0
