Q. There was talk of the script being included with the heartbeat source but this has probably fallen by the wayside as a lot has happened since then. Is it worth while resubmitting ?

I don't see why not. If you post them here (again?) someone will take care of it (and if we don't, complain loudly :-)

surely not :-)

Script is attached, many thanks

Pete




--
The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.
#!/bin/bash

#########################################################################
#                                                                       #
# External STONITH module for Sun X4200 power management, produced      #
# by Peter Clapham copyright (c) 2006 Genome Research Ltd.              #
#                                                                       #
# This program is free software; you can redistribute it and/or         #
# modify it under the terms of the GNU General Public License           #
# as published by the Free Software Foundation; either version 2        #
# of the License, or (at your option) any later version.                #
#                                                                       #
# This program is distributed in the hope that it will be useful,       #
# but WITHOUT ANY WARRANTY; without even the implied warranty of        #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
# GNU General Public License for more details.                          #
#                                                                       #
# You should have received a copy of the GNU General Public License     #
# along with this program; if not, write to the Free Software           #
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,            #
# MA  02110-1301, USA.                                                  #
#                                                                       #
#########################################################################


# The X4200's are IPMI 2.0 compliant and this script may therefore 
# also work on other ipmi compliant ILO hardware although your 
# mileage may vary. To use this you will require impitools installed
# on your servers. 

# Hostlist is a list of the hosts that are being monitored and 
# iloname are the ilo devices being used to bring the hosts up/down.
# these are configured from within heartbeat.
#
# For heartbeat configuration we need:
#
# gethosts (hostlist defined), on (bring up ilo) off (bring down ilo),
# reset (reset ilo), status (are host, ilo and ilo functionaility 
# alive ?!) getconfignames (required script parameters),  getinfo-foo
# (generic info, limited use)

# Source ocf code status.
. /usr/lib/heartbeat/ocf-shellfuncs

# IPMI communication variables
IPMITOOL="/usr/bin/ipmitool"
IPMIPASS="********"
IPMIUSER="********"

case $1 in
gethosts)
        for h in $hostlist ; do
                echo $h
        done
        exit $OCF_SUCCESS
        ;;
on)
        /usr/bin/logger -p syslog.info Sun X4200 IPMI STONITH powering on 
$iloname
        $IPMITOOL -H $iloname -U $IPMIUSER -P $IPMIPASS chassis power on > 
/dev/null 2>&1
        sleep 3
        IPMITEST=$($IPMITOOL -H $iloname -U $IPMIUSER -P $IPMIPASS chassis 
power status|awk '{print $4}')
        if [ $IPMITEST = "on" ] ; then
                exit $OCF_SUCCESS
        else
                exit $OCF_ERR_GENERIC
        fi
        ;;
off)
        /usr/bin/logger -p syslog.info Sun X4200 IPMI STONITH powering off 
$iloname
        $IPMITOOL -H $iloname -U $IPMIUSER -P $IPMIPASS chassis power off > 
/dev/null 2>&1
        sleep 3
        IPMITEST=$($IPMITOOL -H $iloname -U $IPMIUSER -P $IPMIPASS chassis 
power status|awk '{print $4}')
        if [ $IPMITEST = "off" ] ; then 
                exit $OCF_SUCCESS
        else
                exit $OCF_ERR_GENERIC
        fi
        ;;
reset)

# restart is apparently far to kind ! A SYS nuke may be required if system
# has hit a high load and has hung !
#
# Numerous checks to ensure things actually do as they are supposed to do.
# sleep entries allow chance for effects to be reported to heartbeat in 
# a sane way

        /usr/bin/logger -p syslog.info Sun X4200 IPMI STONITH restarting 
$iloname
        IPMITEST=$($IPMITOOL -H $iloname -U $IPMIUSER -P $IPMIPASS chassis 
power status|awk '{print $4}')
        if [ $IPMITEST = "on" ] ; then
                $IPMITOOL -H $iloname -U $IPMIUSER -P $IPMIPASS chassis power 
off > /dev/null 2>&1
                sleep 3 
                IPMITEST2=$($IPMITOOL -H $iloname -U $IPMIUSER -P $IPMIPASS 
chassis power status|awk '{print $4}')
                if [ $IPMITEST2 = "off" ] ; then
                        $IPMITOOL -H $iloname -U $IPMIUSER -P $IPMIPASS chassis 
power on > /dev/null 2>&1
                        sleep 3 
                        IPMITEST3=$($IPMITOOL -H $iloname -U $IPMIUSER -P 
$IPMIPASS chassis power status|awk '{print $4}')
                        if [ $IPMITEST3 = "on" ] ; then
                                exit $OCF_SUCCESS
                        else
                                exit $OCF_ERR_GENERIC
                        fi
                else 
                        exit $OCF_ERR_GENERIC
                fi
        else
                $IPMITOOL -H $iloname -U $IPMIUSER -P $IPMIPASS chassis power 
on > /dev/null 2>&1
                IPMITEST2=$($IPMITOOL -H $iloname -U $IPMIUSER -P $IPMIPASS 
chassis power status|awk '{print $4}')
                if [ $IPMITEST2 = "on" ] ; then
                        exit $OCF_SUCCESS
                else
                        exit $OCF_ERR_GENERIC
                fi
        fi
        ;;
status)
        IPMITEST=$($IPMITOOL -H $iloname -U $IPMIUSER -P $IPMIPASS chassis 
power status|awk '{print $4}')
        if [ $IPMITEST = "on" ] ; then
                exit $OCF_SUCCESS
        else
                exit $OCF_ERR_GENERIC
        fi
        ;;
getconfignames)
        echo "hostlist"
        echo "iloname"
        exit $OCF_SUCCESS
        ;;
getinfo-devid)
        echo "Sun X4200 IPMI STONITH device"
        exit $OCF_SUCCESS
        ;;
getinfo-devname)
        echo "IPMI STONITH external device"
        exit $OCF_SUCCESS
        ;;
getinfo-devdescr)
        echo "IPMI-based host power ctrl"
        echo "May not even be fine for testing !"
        exit $OCF_SUCCESS
        ;;
getinfo-devurl)
        echo "http://www.openipmi.org/";
        exit $OCF_SUCCESS
        ;;
getinfo-xml)
        cat << IPMIXML
<parameters>
 <parameter name="hostlist" unique="1">
  <content type="string" />
  <shortdesc lang="en">
   Hostlist
  </shortdesc>
  <longdesc lang="en">
   The list of hosts that the STONITH device controls
  </longdesc>
 </parameter>
 <parameter name="iloname" unique="1">
  <content type="string" />
  <shortdesc>
   iloname
  </shortdesc>
  <longdesc lang="en">
   The ilo devices STONITH is to operate with
  </longdesc>
 </parameter>
</parameters>
IPMIXML
        exit $OCF_SUCCESS
        ;;
*)
        exit $OCF_ERR_GENERIC
        ;;
esac
_______________________________________________
Linux-HA mailing list
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems

Reply via email to