#! /usr/bin/ksh 
# ===========================================================
#                                                           =
#  gstat3586a                         (Get C3586A STATus)   =
#                                                           =
#  HP disk array monitor daemon script                      =
#                                                           =
#  takes array device files (contents of the array file)    =
#                                                           =
#  calls scripts that                                       =
#        examine status of drives                           =
#                                                           =
#  syntax:                                                  =
#      gstat3586a <list of arrays>                          =
#                                                           =
#  calls:                                                   =
#     utilities                                             =
#            $ARM_DIR/arraydsp                              =
#            $DAEMON_DIR/aml                                =
#                                                           =
#     system utilities                                      =
#            $UXTOOL_DIR/awk                                =
#            $CMNDS_DIR/cat                                 =
#            $CMNDS_DIR/cp                                  =
#            $CMNDS_DIR/echo                                =
#            $CMNDS_DIR/grep                                =
#            $CMNDS_DIR/mktemp                              =
#            $CMNDS_DIR/rm                                  =
#            $CMNDS_DIR/touch                               =
#                                                           =
#  (c)Copyright 1995 Hewlett-Packard Company                =
#     All rights reserved.                                  =
#                                                           =
# ===========================================================

hdr="@(#) $Header: gstat3586a,v 78.3 96/03/26 19:27:59 ssa Exp $"

.  /usr/lbin/hpC2400/arraymon.hdr

   if test $# -lt $DEVS_ENTRY_CNT
   then 
      exit 2
   fi
#------------------------------------------------------------
# set up the variables used for messages in the message
# catalog file
#------------------------------------------------------------

   C3586set=4
   FewDrvs=1
   NoQuorum=2
   NoMap=3
   ShutNdown=4
   ShutDown=5
   NoCode=6
   NoErr=7
   NoWarn=8
   ShutWarn=9
   FwMismatch=10
   NoData=20
   NoRedun=21
   NoHotSpare=22
   DiskErr=23
   LowCap=24
   RbldFail=25
   LogFull=26
   Undef=27
   HotSparDisab=28
   UnusedSimm=29
   DisablCntrl=30
   UnmirrRam=31
   StatChng=32
   BattErr=40
   DeadBat=41
   WarnBat=42
   NoBatState=43
   FanFail=50
   FanBad=51
   NoFan=52
   FanUnk=53
   SupplyFail=60
   PwrSuplBad=61
   NoPwrSupl=62
   PwrSuplUnk=63
   CntrlErr=70
   CntrBad=71
   NoCntr=72
   CntrUnk=73
   NvRamErr=80
   NvRamBad=81
   NoNvRam=82
   NvRamUnk=83
   DRamErr=90
   DRamBad=91
   NoDRam=92
   DRamUnk=93
   MechNotInc=100
   MechDown=101
   MechFail=102
   PrevUse=103
   Unsuprt=104
   MechInitFail=105
   DiskMissing=110
   MissingDisk=111
   NoInfo=120
   TimeOut=121

############################################################
#-----------------------------------------------------------
# function chk_msg compares the current message with
# previously logged messages. If the message is a new
# message or the logged message has an expired time 
# interval, then mark it to be e-mailed. 
# cur_time is the number of minutes since midnight
#----------------------------------------------------------

function chk_msg
{
cur_set=$1
cur_msg=$2
arc_file=$3

elap_time=0
m_flag=$FALSE
match=0

arc_out=$(${CMNDS_DIR}/mktemp -d ${TMP_DIR} -c)
((cur_time = ($(${CMNDS_DIR}/date +%H) * 60) + $(${CMNDS_DIR}/date +%M) ))

while read entry
do
  set $entry
  arc_set=$1
  arc_msg=$2
  arc_time=$3

  if [ $arc_set -eq $cur_set ]
  then
     if [ $arc_msg -eq $cur_msg ]
     then
        match=1
        ((elap_time = cur_time - arc_time))

        if (( elap_time < 0 ))
        then
          (( elap_time = elap_time + 1440 ))
        fi

        if [ $elap_time -ge $INTRVAL ]
        then
           arc_time=$cur_time
        else
           m_flag=$TRUE
        fi
     fi
  fi

${CMNDS_DIR}/echo $arc_set $arc_msg $arc_time >> $arc_out

done < $arc_file

#----------------------------------------
# if no match was found, the message is
# new so put a copy in the archive file
#----------------------------------------

if [ $match -eq 0 ]
then
  ${CMNDS_DIR}/echo $cur_set $cur_msg $cur_time >> $arc_out
fi

${CMNDS_DIR}/cp $arc_out $arc_file
${CMNDS_DIR}/rm $arc_out 2> /dev/null

return $m_flag

}  # end chk_msg

############################################################
#-----------------------------------------------------------
# function no_info outputs standard error messages for
# a non-responding array
#-----------------------------------------------------------

function no_info
{
  set=$1
  msg=$2
  dev_file=$3
  node_nam=$4
  msg_arch=$5

  ${DAEMON_DIR}/aml -s $set -m $msg -p $dev_file -n $node_nam -f $msgFile
  chk_msg $set $msg $msg_arch 

  if [ $? -eq 0 ]
  then
     m_flg=$FALSE
  else
     m_flg=$TRUE
  fi

  if [[ -s $msgFile ]]
  then
     $NOTIFY $m_flg $msgFile `cat $NOTIFY_WHOM` > /dev/null 2>&1
     ${CMNDS_DIR}/rm $msgFile 2> /dev/null
  fi 

} # end no_info

############################################################
#-----------------------------------------------------------
# function chk_hardware checks which component has failed
#
# the variable 'type' is based on the warning state bit
# returned from arraydsp and is used to synchronize error
# messages in case multiple warnings occur in the array at
# the same time
#-----------------------------------------------------------

function chk_hardware
{
  type=$1
  h_file=$2 

  GOOD=1
  FAILED=2
  REMOVED=3
  outf=$(${CMNDS_DIR}/mktemp -d ${TMP_DIR} -c)

#----------------------------------------------------------------
# Parse out colon delimiter and adjust for empty fields in
# the hardware data file. Skip the first record in the file.
# Scan the resulting output file for error states for the
# failing component.  Status should never be good at this
# point, but just in case don't send a message for a good state.
#----------------------------------------------------------------

  ${UXTOOL_DIR}/awk '
  BEGIN { FS = ":" } {
    while (getline <FILENAME > 0) {
      for ( i = 1; i <= NF; i = i + 1 ) {
      if ($i == "")
        $i = "#"
      }
      print($4,$5,$6,$7) > ARGV[2]
    } exit
  }' $h_file $outf

  while read entry
  do
    set $entry
    compid=$1
    compn=$2
    cntrid=$3
    stat=$4
    h_mesg=0
    status=$TRUE

    case $type in

       2) if [[ $compid -eq 8 || $compid -eq 9 ]]
          then

             if [ $stat -eq 1 ]
             then
               h_mesg=$DeadBat
             elif [ $stat -eq 2 ]
             then
               h_mesg=$WarnBat
             elif [ $stat -eq 3 ]
             then
               status=$FALSE
             else
               h_mesg=$NoBatState
             fi

             if [ $status -eq $TRUE ]
             then
                ${DAEMON_DIR}/aml -h -s $C3586set -m $h_mesg -L $cntrid -f $msgFile
             fi

          fi;;

       7) if [[ $compid -eq 5 || $compid -eq 7 ]]
          then

             if [ $stat -eq $FAILED ]
             then
               h_mesg=$NvRamBad
             elif [ $stat -eq $REMOVED ]
             then
               h_mesg=$NoNvRam
             elif [ $stat -eq $GOOD ]
             then
               status=$FALSE
             else
               h_mesg=$NvRamUnk
             fi

             if [ $status -eq $TRUE ]
             then
               ${DAEMON_DIR}/aml -h -s $C3586set -m $h_mesg -L $compn -L $cntrid -f $msgFile
             fi

          fi;;

       8) if [ $compid -eq 2 ]
          then

             if [ $stat -eq $FAILED ]
             then
               h_mesg=$CntrBad
             elif [ $stat -eq $REMOVED ]
             then
               h_mesg=$NoCntr
             elif [ $stat -eq $GOOD ]
             then
               status=$FALSE
             else
               h_mesg=$CntrUnk
             fi

             if [ $status -eq $TRUE ]
             then
               ${DAEMON_DIR}/aml -h -s $C3586set -m $h_mesg -L $cntrid -f $msgFile
             fi

          fi;;

       9) if [[ $compid -eq 4 || $compid -eq 6 ]]
          then

             if [ $stat -eq $FAILED ]
             then
               h_mesg=$DRamBad
             elif [ $stat -eq $REMOVED ]
             then
               h_mesg=$NoDRam
             elif [ $stat -eq $GOOD ]
             then
               status=$FALSE
             else
               h_mesg=$DRamUnk
             fi

             if [ $status -eq $TRUE ]
             then
               ${DAEMON_DIR}/aml -h -s $C3586set -m $h_mesg -L $compn -L $cntrid -f $msgFile
             fi

          fi;;

      10) if [ $compid -eq 0 ]
          then

             if [ $stat -eq $FAILED ]
             then
               h_mesg=$FanBad
             elif [ $stat -eq $REMOVED ]
             then
               h_mesg=$NoFan
             elif [ $stat -eq $GOOD ]
             then
               status=$FALSE
             else
               h_mesg=$FanUnk
             fi

             if [ $status -eq $TRUE ]
             then
               ((compn = compn + 1))
               ${DAEMON_DIR}/aml -h -s $C3586set -m $h_mesg -L $compn -f $msgFile
             fi

          fi;;

      11) if [ $compid -eq 1 ]
          then

             if [ $stat -eq $FAILED ]
             then
               h_mesg=$PwrSuplBad
             elif [ $stat -eq $REMOVED ]
             then
               h_mesg=$NoPwrSupl
             elif [ $stat -eq $GOOD ]
             then
               status=$FALSE
             else
               h_mesg=$PwrSuplUnk
             fi

             if [ $status -eq $TRUE ]
             then
               ((compn = compn + 1))
               ${DAEMON_DIR}/aml -h -s $C3586set -m $h_mesg -L $compn -f $msgFile
             fi

          fi;;

       *) j=0;;

    esac

  done < $outf

  ${CMNDS_DIR}/rm $outf 2> /dev/null
   
} # end chk_hardware

##############################################################
#-------------------------------------------------------------
# function chk_disks_present checks disks that are present
# in the array that are in a state that prevents active
# use of that mechanism
#-------------------------------------------------------------

function chk_disks_present
{
  d_file=$1

  out_pd=$(${CMNDS_DIR}/mktemp -d ${TMP_DIR} -c)
  out_f=$(${CMNDS_DIR}/mktemp -d ${TMP_DIR} -c)

  grep PD: $d_file > $out_pd

  if [[ -s $out_pd ]]
  then

    ${UXTOOL_DIR}/awk '
    BEGIN { FS = ":" } {
      while (getline <FILENAME > 0) {
        for ( i = 1; i <= NF; i = i + 1 ) {
        if ($i == "")
          $i = "#"
        }
        print($2,$3) > ARGV[2]
      } exit
    }' $out_pd $out_f

    while read entry
    do
      set $entry
      slot=$1
      state=$2
      dp_mesg=0

      case $state in

        2) dp_mesg=$MechNotInc;;

        3) dp_mesg=$MechDown;;

        4) dp_mesg=$MechFail;;

        5) dp_mesg=$PrevUse;;

        6) dp_mesg=$Unsuprt;;

        7) dp_mesg=$MechInitFail;;

        *) dp_mesg=0;;

      esac

      if [ $dp_mesg -ne 0 ]
      then
         ${DAEMON_DIR}/aml -h -s $C3586set -m $dp_mesg -L $slot -f $msgFile
      fi

    done < $out_f

  fi

  ${CMNDS_DIR}/rm $out_f 2> /dev/null
  ${CMNDS_DIR}/rm $out_pd 2> /dev/null

} # end chk_disks_present

##############################################################
#-------------------------------------------------------------
# function chk_disks_missing checks for disks that are in the
# array's missing disk list.
#-------------------------------------------------------------

function chk_disks_missing
{
  d_file=$1

  out_md=$(${CMNDS_DIR}/mktemp -d ${TMP_DIR} -c)
  out_f=$(${CMNDS_DIR}/mktemp -d ${TMP_DIR} -c)

  grep MD: $d_file > $out_md

  if [[ -s $out_md ]]
  then
     ${UXTOOL_DIR}/awk '
     BEGIN { FS = OFS = ":" } {
       while (getline <FILENAME > 0) {
         for ( i = 1; i <= NF; i = i + 1 ) {
         if ($i == "")
           $i = "#"
         }
         print($2,$3,$7) > ARGV[2]
       } exit
     }' $out_md $out_f

     saved_ifs=$IFS
     IFS=:

     while read entry
     do
       set $entry
       vendr=$1
       prod_num=$2
       ser_num=$3

       ${DAEMON_DIR}/aml -h -s $C3586set -m $MissingDisk -L $vendr $prod_num -L $ser_num -f $msgFile

     done < $out_f

     IFS=$saved_ifs

  fi

  ${CMNDS_DIR}/rm $out_f 2> /dev/null
  ${CMNDS_DIR}/rm $out_md 2> /dev/null

} # end chk_disks_missing

############################################################
#-----------------------------------------------------------
# function chk_warn checks for all possible warning states
# and as necessary does further inquiries for specific
# failure information
#-----------------------------------------------------------

function chk_warn
{
typeset -i16 hex_warn
typeset -i16 drv_mask
typeset -i16 hrd_mask
typeset -i2 bin_warn

hex_warn=$1
hot_spare=$2
arr_dev=$3
node_name=$4
mail_flg=$5
mesg_arch=$6

#-----------------------------------------------------------
# convert warning state hex value to binary. Use drv_mask
# to check bits indicating mechanism related failures and
# hrd_mask to check bits indicating other hardware related 
# failures 
#-----------------------------------------------------------

bin_warn=hex_warn
bit=0
mask=1
drv_mask=16#201b 
hrd_mask=16#f84

((drvbits = bin_warn & drv_mask))
((hardbits = bin_warn & hrd_mask))

if [ $drvbits -ne 0 ]
then
   drive_file=$(${CMNDS_DIR}/mktemp -d ${TMP_DIR} -c)
  ${ARM_DIR}/arraydsp -d -S $arr_dev > $drive_file 2> /dev/null
fi

if [ $hardbits -ne 0 ]
then
   hardw_file=$(${CMNDS_DIR}/mktemp -d ${TMP_DIR} -c)
  ${ARM_DIR}/arraydsp -h -S $arr_dev > $hardw_file 2> /dev/null
fi

#-----------------------------------------------------------
# test each individual bit in the warning field 
#-----------------------------------------------------------

phys_drive_chk=0
missng_drive_chk=0
hard_chk=0
mult_warn=0
mesg=0

while ((bin_warn != 0))
do
  ((result = mask & bin_warn))
    
  if [ $result -ne 0 ]
  then

    case $bit in

      0) mesg=$NoData
         ((phys_drive_chk = phys_drive_chk + 1))
         ((missng_drive_chk = missng_drive_chk + 1));;

      1) mesg=$NoRedun
         ((phys_drive_chk = phys_drive_chk + 1))
         ((missng_drive_chk = missng_drive_chk + 1));;

      2) mesg=$BattErr 
         ((hard_chk = hard_chk + 1));;

      3) if [ $hot_spare -eq 1 ]
         then
            mesg=$HotSparDisab
         else
            mesg=$NoHotSpare
         fi

         ((phys_drive_chk = phys_drive_chk + 1))
         ((missng_drive_chk = missng_drive_chk + 1));;

      4) if [[ $phys_drive_chk -gt 0 || $missng_drive_chk -gt 0 ]]
         then
            mesg=0
         else
            mesg=$DiskErr
         fi

         ((phys_drive_chk = phys_drive_chk + 1));;

#-----------------------------------------------
# bit position 5 is reserved for future use
#-----------------------------------------------

      5) mesg=0;;

      6) mesg=$RbldFail;;

      7) if [ $hard_chk -eq 0 ]
         then
            mesg=$NvRamErr
         else
            mesg=0
         fi

         ((hard_chk = hard_chk + 1));;

      8) if [ $hard_chk -eq 0 ]
         then
            mesg=$CntrlErr 
         else
            mesg=0
         fi

         ((hard_chk = hard_chk + 1));;

      9) if [ $hard_chk -eq 0 ]
         then
            mesg=$DRamErr
         else
            mesg=0
         fi

         ((hard_chk = hard_chk + 1));;

     10) if [ $hard_chk -eq 0 ]
         then
            mesg=$FanFail
         else
            mesg=0
         fi

         ((hard_chk = hard_chk + 1));;

     11) if [ $hard_chk -eq 0 ]
         then
            mesg=$SupplyFail
         else
            mesg=0
         fi

         ((hard_chk = hard_chk + 1));;

     12) mesg=$LogFull;;

     13) if [[ $phys_drive_chk -gt 0 || $missng_drive_chk -gt 0 ]]
         then
            mesg=0
         else
            mesg=$DiskMissing
         fi

         ((missng_drive_chk = missng_drive_chk + 1));;

     14) mesg=$UnusedSimm;;

     15) if [ $mult_warn -eq 0 ]
         then
            ${DAEMON_DIR}/aml -s $C3586set -m $DisablCntrl -L Y -p $arr_dev -n $node_name -f $msgFile 
         else
            ${DAEMON_DIR}/aml -h -s $C3586set -m $DisablCntrl -L Y -p $arr_dev -n $node_name -f $msgFile 
         fi

         chk_msg $C3586set $DisablCntrl $mesg_arch

         if [ $? -eq 0 ]
         then
           mail_flg=$FALSE
         fi

         mesg=0;;

     16) mesg=$UnmirrRam;;

     17) mesg=$StatChng;;

      *) mesg=$Undef;; 

    esac

#---------------------------------------------------------------------
# If a warning  message isn't a repeat of a previous error, e-mail it.
# In the case of multiple warnings, any new warning that hasn't been
# e-mailed will cause all previous warnings to be e-mailed again
# along with the new warning.
#---------------------------------------------------------------------

    if [ $mesg -ne 0 ]
    then
      if [ $mult_warn -eq 0 ]
      then
         ${DAEMON_DIR}/aml -s $C3586set -m $mesg -p $arr_dev -n $node_name -f $msgFile 
      else
         ${DAEMON_DIR}/aml -h -s $C3586set -m $mesg -p $arr_dev -n $node_name -f $msgFile 
      fi

      chk_msg $C3586set $mesg $mesg_arch

      if [ $? -eq 0 ]
      then
        mail_flg=$FALSE
      fi
    fi

    if [ $phys_drive_chk -eq 1 ]
    then
       if [[ -s $drive_file ]]
       then
          chk_disks_present $drive_file
	  ((phys_drive_chk = phys_drive_chk + 1))
       fi
    fi

    if [ $missng_drive_chk -eq 1 ]
    then
       if [[ -s $drive_file ]]
       then
          chk_disks_missing $drive_file
         ((missng_drive_chk = missng_drive_chk + 1))
       fi
    fi
    
    if [ $hard_chk -eq 1 ]
    then
       if [[ -s $hardw_file ]]
       then
          chk_hardware $bit $hardw_file
	  ((hard_chk = hard_chk + 1))
       fi
    fi

    if [ $mesg -ne 0 ]
    then
      ((mult_warn = mult_warn + 1))
    fi

  fi

  ((bit = bit + 1))
  ((bin_warn = bin_warn >> 1))
  mesg=0

done

if [[ -s $msgFile ]]
  then
     $NOTIFY $mail_flg $msgFile `cat $NOTIFY_WHOM` > /dev/null 2>&1
     ${CMNDS_DIR}/rm $msgFile 2> /dev/null
  fi

${CMNDS_DIR}/rm $drive_file 2> /dev/null
${CMNDS_DIR}/rm $hardw_file 2> /dev/null

}  # end chk_warn

#############################################################
#------------------------------------------------------------
# =====  MAIN  =====    
#------------------------------------------------------------

   out_one=$(${CMNDS_DIR}/mktemp -d ${TMP_DIR} -c)
   out_two=$(${CMNDS_DIR}/mktemp -d ${TMP_DIR} -c)

   vendor=$1
   prod_id=$2
   array=$3
   arr_status=$4
   prog_status=$5
   time_outs=$6

   mail_flag=$FALSE

#------------------------------------------------------------
# get the host system node name
#------------------------------------------------------------
   node=$(${CMNDS_DIR}/uname -n)

#------------------------------------------------------------
# assign the variable to use for data file names based on the
# device file name
#------------------------------------------------------------

   devname=$(${CMNDS_DIR}/echo $array | ${UXTOOL_DIR}/awk 'BEGIN { FS = "/" } { print $4 }')

#-------------------------------------------
# assign a name to the message archive file
# and make sure the file exists.
#-------------------------------------------

   m_arch="$MISC_DIR/"$devname".arc"

   if [[ ! -f $m_arch ]]
   then
     ${CMNDS_DIR}/touch $m_arch 2>&1
   fi 

#------------------------------------------------------------
#  examine drive status
#                                          
#  if we can't talk to the array after a minimum number of
#  tries, report an error message
#------------------------------------------------------------

   ${ARM_DIR}/arraydsp -s -S $array > $out_one 2> /dev/null 

   adsp_stat=$?

   case $adsp_stat in

      1) err_set=$MonSet
         err_msg=$NoResponse;;

      3) err_set=$C3586set
         err_msg=$TimeOut;;
#------------------------------------------------------------
# the array state has changed since the ARMServer was started
# perform a RESCAN to update the ARMServer status
#------------------------------------------------------------

      4) ${CMNDS_DIR}/rm $out_one 2> /dev/null
         ${CMNDS_DIR}/rm $out_two 2> /dev/null
         exit 4;;

   esac

   if [ $adsp_stat -eq 1 ]
   then 
      ((prog_status = prog_status + 1))
      if (( (prog_status % MAX_PROG_ERR) == 0 ))
      then
        no_info $err_set $err_msg $array $node $m_arch
      fi

   elif [ $adsp_stat -eq 3 ]
   then 
      ((time_outs = time_outs + 1))
      if (( (time_outs % MAX_PROG_ERR) == 0 ))
      then
        no_info $err_set $err_msg $array $node $m_arch
      fi

   elif [ $adsp_stat -eq 0 ]
   then
      prog_status=0
      time_outs=0
      state_info=$(${UXTOOL_DIR}/awk '{FS = ":"} {print $13,$28,$29}' $out_one)
      set $state_info
      hot_spare=$1
      arr_state=$2
      ascii_hex_warn=$(${CMNDS_DIR}/echo $3 | ${UXTOOL_DIR}/awk '{FS = "x"} {print $2}')
      warn_hex=16#$ascii_hex_warn

#----------------------------------
# Check to see if the array is in 
# an optimal or non-optimal state
#----------------------------------

      if [ $arr_state -ne 0 ]
      then
         
#--------------------------------------------------------------------------
# Assume the error hasn't been reported yet so call chk_msg to verify if
# this is a new error. If the error message has already been reported, 
# then send it to to the specified console only. Don't e-mail it again 
# until the time interval for repeat mailings has elapsed. Function 
# chk_warn will handle checking of messages for warning states.
#--------------------------------------------------------------------------

         case $arr_state in

            1) mail_flag=$TRUE
               if [ $warn_hex -ne 0 ]
               then
                 chk_warn $warn_hex $hot_spare $array $node $mail_flag $m_arch
               else
                 ${DAEMON_DIR}/aml -s $C3586set -m $NoWarn -p $array -n $node -f $msgFile
                 chk_msg $C3586set $NoWarn $m_arch
                 if [ $? -eq 0 ]
                 then
                    mail_flag=$FALSE
                 fi
               fi;;

            2) ${DAEMON_DIR}/aml -s $C3586set -m $FewDrvs -p $array -n $node -f $msgFile
               chk_msg $C3586set $FewDrvs $m_arch

               if [ $? -ne 0 ]
               then
                  mail_flag=$TRUE 
               fi;;

            3) ${DAEMON_DIR}/aml -s $C3586set -m $NoQuorum -p $array -n $node -f $msgFile
               chk_msg $C3586set $NoQuorum $m_arch

               if [ $? -ne 0 ]
               then
                  mail_flag=$TRUE 
               fi

               ${ARM_DIR}/arraydsp -d -S $array > $out_two 2> /dev/null

               if [ $? -ne 0 ]
               then
                  no_info $C3586set $NoInfo $array $node $m_arch 
               else
                  if [ -s $out_two ]
                  then
                     chk_disks_present $out_two
                     chk_disks_missing $out_two
                  fi
               fi;;
                  
            4) ${DAEMON_DIR}/aml -s $C3586set -m $NoMap -p $array -n $node -f $msgFile
               chk_msg $C3586set $NoMap $m_arch

               if [ $? -ne 0 ]
               then
                  mail_flag=$TRUE
               fi

               if [ $warn_hex -gt 0 ]
               then
                 chk_warn $warn_hex $hot_spare $array $node $mail_flag $m_arch
               fi;;

            5) ${DAEMON_DIR}/aml -s $C3586set -m $ShutNdown -p $array -n $node -f $msgFile
               chk_msg $C3586set $ShutNdown $m_arch

               if [ $? -ne 0 ]
               then
                  mail_flag=$TRUE
               fi;;

            6) ${DAEMON_DIR}/aml -s $C3586set -m $ShutDown -p $array -n $node -f $msgFile
               chk_msg $C3586set $ShutDown $m_arch

               if [ $? -ne 0 ]
               then
                  mail_flag=$TRUE 
               fi;;

#---------------------------------------------------------
# No message will be issued for the array start up state
#---------------------------------------------------------

            7) no_mesg=0;;

            8) ${DAEMON_DIR}/aml -s $C3586set -m $NoCode -p $array -n $node -f $msgFile
               chk_msg $C3586set $NoCode $m_arch

               if [ $? -ne 0 ]
               then
                  mail_flag=$TRUE 
               fi;;

           10) ${DAEMON_DIR}/aml -s $C3586set -m $ShutWarn -p $array -n $node -f $msgFile
               chk_msg $C3586set $ShutWarn $m_arch

               if [ $? -ne 0 ]
               then
                  mail_flag=$TRUE 
               fi;;

           12) ${DAEMON_DIR}/aml -s $C3586set -m $FwMismatch -p $array -n $node -f $msgFile
               chk_msg $C3586set $FwMismatch $m_arch

               if [ $? -ne 0 ]
               then
                  mail_flag=$TRUE 
               fi;;

            *) ${DAEMON_DIR}/aml -s $C3586set -m $NoErr -p $array -n $node -f $msgFile
               chk_msg $C3586set $NoErr $m_arch

               if [ $? -ne 0 ]
               then
                  mail_flag=$TRUE
               fi;;

         esac

      else

#-------------------------------------------
# The array returned good status so delete
# any entries in the message archive file
#-------------------------------------------

         if [ -s $m_arch ]
         then
            ${CMNDS_DIR}/cat /dev/null > $m_arch
         fi
      fi
   fi

#-------------------------------------------
# If there are errors to output, do it now
#-------------------------------------------

   if [[ -s $msgFile ]]
   then
      $NOTIFY $mail_flag $msgFile `cat $NOTIFY_WHOM` > /dev/null 2>&1
      ${CMNDS_DIR}/rm $msgFile 2> /dev/null
   fi

   ${CMNDS_DIR}/rm $out_one 2> /dev/null
   ${CMNDS_DIR}/rm $out_two 2> /dev/null

   ${CMNDS_DIR}/echo $vendor "  " $prod_id "  " $array "  " $arr_status "  " $prog_status "  " $time_outs


#------------------------------------------------------------
# end of gstat3586a
#------------------------------------------------------------
