"Fossies" - the Fresh Open Source Software Archive

Member "freeha-1.0/service_scripts/vip.monitor" (23 Nov 2006, 1437 Bytes) of package /linux/privat/old/freeha-1.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 
    3 #-------------------------------------------------------------------------#
    4 # Script to monitor a "virtual IP" used by cluster services               #
    5 # Provided as a tool to be called from 'monitorhasrv'                     #
    6 #                                                                         #
    7 # USAGE:   vip.monitor IP other-IP-to-ping-for-validation                 #
    8 #    EG:   vip.monitor 10.3.5.7 10.3.5.55                                 #
    9 #  (Note: first arg MUST be ip addr, not name)                            #
   10 #                                                                         #
   11 #  Standard UNIX status: returns 0 on okay, non-0 on fail.                #
   12 #-------------------------------------------------------------------------#
   13 
   14 
   15 
   16 # This is tweaked for Solaris, because that's what I have to play with.
   17 # Please submit whatever tweaks are neccessary for your favorite OS.
   18 
   19 
   20 PATH=$PATH:/usr/sbin:/sbin
   21 
   22 if [ $# -ne 2 ] ; then
   23     echo vip.monitor: ERROR: Need to specify VIP IP addr, and external IP to ping
   24     exit 1
   25 fi
   26 
   27 #This uses the same algorithm as vip.stop
   28 name=`ifconfig -a | awk '
   29 $1 ~ /:/    {split($1,nic,":"); 
   30                  lastif=sprintf("%s:%s",nic[1],nic[2]);}
   31 $2 == "'$1'"    { print lastif ; exit; }
   32 
   33 '`
   34 
   35 
   36 if [ "$name" = "" ] ; then
   37     echo vip.monitor: IP address $1 not present as virtual interface.
   38     exit 1
   39 fi
   40 
   41 
   42 ping -i $name $2
   43 
   44 # exit status for script will fall out of ping status