#!/bin/sh
#@(#)u4ft	1.2 06/18/99 01:23:40

#
# Collate Diagnostic information from an FT1800 machine
#
# This script is based on information from: Hugh Barney; hugh.barney@UK
#


CMSHOME=/usr/platform/SUNW,Ultra-4FT/SUNWcms
export CMSHOME

if [ ! -d $CMSHOME ]
then
   # not a FT1800 system.
   exit 0
fi

# Note: sbin needs to come before lib as we want cmsfruinfo from sbin
PATH=$PATH:$CMSHOME/sbin:$CMSHOME/lib
export PATH

CURR_DIR=`pwd`

mkdir u4ft

# collect status-logs. Use cpio to preserve symbolic links
mkdir u4ft/var_SUNWlogu
cd /var/SUNWlogu
find . -depth -mount -print | cpio -pdlm $CURR_DIR/u4ft/var_SUNWlogu 2>/dev/null
cd $CURR_DIR


# collect nvram and debug logs
cat /dev/u4ftlog:nvlog,nodelay > u4ft/nvlog
cat /dev/u4ftlog:debug,nodelay > u4ft/debug

# collecting cms config files
mkdir u4ft/etc_SUNWcms_.config
cd /etc/SUNWcms/.config
find . -depth -mount -print | cpio -pdlm $CURR_DIR/u4ft/etc_SUNWcms_.config \
								2>/dev/null
cd $CURR_DIR

# grab states of all devices according to FT framework
u4ftctl find / | while read cookie;do
    path=`u4ftctl get_path $cookie`
    state=`u4ftctl get_state $cookie`
    echo "$cookie $state $path"
done > u4ft/all-device-states.u4ftctl

# collect eeprom data
mkdir u4ft/fru_eeproms
for LOCATION in \
A-MBD B-MBD A-CPU B-CPU A-CAF B-CAF \
A-PCI0 A-PCI1 A-PCI2 A-PCI3 A-PCI4 A-PCI5 A-PCI6 A-PCI7 \
B-PCI0 B-PCI1 B-PCI2 B-PCI3 B-PCI4 B-PCI5 B-PCI6 B-PCI7 \
A-RMM B-RMM A-DSK B-DSK \
A-PSU0 A-PSU1 A-PSU2 B-PSU0 B-PSU1 B-PSU2
do
    cmsfruinfo -i -l $LOCATION EE_EEPROM 1> \
		u4ft/fru_eeproms/$LOCATION 2>&1
done
