#!/usr/bin/ksh 
###
#
# ISD . YLC le 29/05/98
# ESI . JoF le 17/07/00 test pour charger LISTE_MAC selon le cluster
###

QUEL_CLUSTER=$(cmviewcl|grep "deficluster1 up"|wc -l)
CLUSTER=`cmviewcl|grep "deficluster" | awk -F" "  '{print $1}'`
if [ $QUEL_CLUSTER -ne 0 ]
then
      LISTE_MAC="defipno defipsu defipbx defipli"
      else
      LISTE_MAC="defipne defiply defipni defipso"
fi

FTMP=/tmp/cmviewcl_$$

### test si machine coordinatrice. Si oui , on lance
### le test du cluster.
NTCP=$(netstat -a|grep "hacl-hb"|grep ESTABLISH|wc -l)
if [ $NTCP -gt 4 ]
then
    cmviewcl -v > $FTMP

    cat $FTMP|grep $CLUSTER|grep up >/dev/null

    for i in $LISTE_MAC
       do
         cat $FTMP|grep p$i|grep running 
         if [ $? -ne 0 ] 
           then
               /logiciel/OpC/opcmon ESO_clrunpkg=1
           else
               /logiciel/OpC/opcmon ESO_clrunpkg=0
         fi
    done

    rm -f $FTMP
else
    /logiciel/OpC/opcmon ESO_clrunpkg=0
fi
