#!/usr/bin/ksh

FC=`lsdev -Cc adapter | grep -i fc`
OS=`oslevel`

if [ -z "$FC" ]; then
    echo "Sorry you have no FC adapters installed"
    exit 1
fi

if ! [ "$OS" = "6.1.0.0" -o "$OS" = "7.1.0.0" ]; then
    echo "Script requires AIX 6.1 or 7.1"
    exit 2
fi

 

echo "                ODM       Running   ODM      Running  ODM          Running"
echo "fscsi   status  fastfail  fastfail  dyntrk   dyntrk   num_cmd_el   num_cmd_el"
echo "-----------------------------------------------------------------------------"
for fscsi in `lsdev | grep ^fscsi | grep Available | awk '{print $1}'` ; do
        lsattr -El $fscsi | grep ^dyntrk | awk '{print $2}' | grep -qi yes && odm_dyn=Yes || odm_dyn=No
        lsattr -El $fscsi | grep ^fc_err_recov | awk '{print $2}' | grep -qi fast_fail && odm_ff=Yes || odm_ff=No
        odm_cmd_elems=`lsattr -El $(echo $fscsi | sed 's/fscsi/fcs/') -a num_cmd_elems | awk '{print $2}'`

        ddi=`echo efscsi $fscsi | kdb | grep efscsi_ddi | awk '{print $5}'`
        ddi20=$(echo "obase=16; ibase=16; $(echo $ddi | sed 's/0x//' | tr -d ';') + 20" | bc )
        kdb=`echo "dd ${ddi}+20 2" | kdb | grep $ddi20`

        echo $kdb | awk '{print $2}' | cut -c9-10 | grep -q "02" && kdb_ff=Yes || kdb_ff=No
        echo $kdb | awk '{print $2}' | cut -c11-12 | grep -q "01" && kdb_dyn=Yes || kdb_dyn=No
        kdb_cmd_elems=$(( 16#`echo $kdb | awk '{print $3}' | cut -c1-8`))
        kdb_cmd_elems=`expr $kdb_cmd_elems + 20`

        status=OK
        [ "$odm_dyn" = "$kdb_dyn" ] || status="DIFF!"
        [ "$odm_ff" = "$kdb_ff" ] || status="DIFF!"
        [ "$odm_cmd_elems" = "$kdb_cmd_elems" ] || status="DIFF!"

        printf "%-7s %-7s " $fscsi $status
        printf "%-9s %-9s " $odm_ff $kdb_ff
        printf "%-8s %-8s " $odm_dyn $kdb_dyn
        printf "%-12s %-12s\n" $odm_cmd_elems $kdb_cmd_elems
done
Advertisements