I have put together a STONITH script for the synaccess
(http://www.synaccess-net.com/remote_power_products.php?cat=1&id=all) devices. These devices have rs232, web, telnet and
SNMP based configuration controls. This script uses the user configured outlet name, to determine the host machine
plugged into that outlet. Stonith can then detect the controlled hosts and set their power states accordingly.
For example:
stonith -t external/synaccess synaccessip=192.245.184.102 community=public -T
on udt64-2
I have attached the script and pasted it below:
#!/bin/bash
#
# External STONITH module for synaccess.
#
# Copyright (c) 2008 Gresham Enterprise Storage
# Jeremy Linton <[EMAIL PROTECTED]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Further, this software is distributed without any warranty that it is
# free of the rightful claim of any third person regarding infringement
# or the like. Any license provided herein, whether implied or
# otherwise, applies only to this software file. Patent licenses, if
# any, provided herein do not apply to combinations of this program with
# other software, or any other product whatsoever.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
#
#
# This script requires a few things:
# net-snmp
# SYNACCESS-MIB.txt
# the hostnames that are controlled are placed in the "power outlet" "name"
field.
# The Synaccess device must have SNMP turned on
# The script must have the IP/Hostname of the synaccess device passed in via
"synaccessip"
#
# in order to use this script you must have installed the MIB that came with
the synaccess device
# in /usr/share/snmp/mibs/SYNACCESS-MIB.txt or similar. From then on the
net-snmp utilities
# are aware of the proper names.
# if you are having problems detecting the proper power status make sure the
mib power status reads:
#outletStatus OBJECT-TYPE
#SYNTAX INTEGER {
#off(0),
#on(1),
#off(2),
#on(257),
#off(256)
#}
# Check the synaccess specific mib with
# snmpwalk -c public -m SYNACCESS-MIB -v 1 x.x.x.x synAcc
# drop "public" in if the community isn't set
community=${community:-"public"}
# commands used to get/set snmp values
SNMP_GETCOMMAND="/usr/bin/snmpget -c $community -m SYNACCESS-MIB -v 1
$synaccessip"
SNMP_SETCOMMAND="/usr/bin/snmpset -c $community -m SYNACCESS-MIB -v 1
$synaccessip"
get_snmp_value()
{
echo `$SNMP_GETCOMMAND $1|cut -d: -f4`
}
# the port name given in the web interface must match the switched port number
# this discovers all the hostnames set as the outlet name
discover_hostlist()
{
portcount=`get_snmp_value SYNACCESS-MIB::powerOutletNum.0`
pc=1
for ((i=1; $i <= $portcount;i++)); do
portname=`get_snmp_value SYNACCESS-MIB::outletName.$i`
if [[ "$portname" && "$portname" != "Undefined" ]]; then
hostlist="$hostlist $portname"
fi
done
}
# this looks up the port number based on the passed hostname, using the power
outlet name
get_port_for_host()
{
hostlookup=$1
portcount=`get_snmp_value SYNACCESS-MIB::powerOutletNum.0`
pc=1
for ((i=1; $i <= $portcount;i++)); do
portname=`get_snmp_value SYNACCESS-MIB::outletName.$i`
if [[ "$portname" == "$hostlookup" ]]; then
echo "$i"
return 0
fi
done
}
# this sends a ON/OFF/RESET action to the given hostname
do_port_action()
{
portnum=`get_port_for_host $1`
if [[ "$portnum" ]]; then
out=`$SNMP_SETCOMMAND "SYNACCESS-MIB::outletAction.$portnum" = $2`
exit 0
else
exit 1
fi
}
# Handle script commands
case $1 in
gethosts)
discover_hostlist
for h in $hostlist ; do
echo $h
done
exit 0
;;
on)
do_port_action $2 1
;;
off)
do_port_action $2 2
;;
reset)
do_port_action $2 3
;;
status)
portnum=`get_port_for_host $2`
if [[ "$portnum" ]]; then
synPortStatus=`get_snmp_value SYNACCESS-MIB::outletStatus.$portnum
|cut -c1-2`
if [[ "$synPortStatus" == "on" ]]; then
exit 0
fi
else
exit 1
fi
;;
getconfignames)
echo "synaccessip community"
exit 0
;;
getinfo-devid)
echo "synaccess"
exit 0
;;
getinfo-devname)
synModel=`get_snmp_value SYNACCESS-MIB::systemModel.0`
synName=`get_snmp_value SYNACCESS-MIB::systemName.0`
echo "Synaccess netBooter $synModel $synName"
exit 0
;;
getinfo-devdescr)
echo "synaccess netbooter STONITH device"
exit 0
;;
getinfo-devurl)
echo "http://www.synaccess-net.com"
exit 0
;;
getinfo-xml)
# Parameters (hostname, synaccess IP, synaccess port)
cat << SAXML
<parameters>
<parameter name="synaccessip" unique="1" required="1">
<content type="string" />
<shortdesc lang="en">SynaccessIp</shortdesc>
<longdesc lang="en">The IP of the synaccess device controlling the
hosts</longdesc>
</parameter>
<parameter name="community" unique="1" required="0">
<content type="string" />
<shortdesc lang="en">Community</shortdesc>
<longdesc lang="en">The SNMP Community string</longdesc>
</parameter>
</parameters>
SAXML
exit 0
;;
*)
exit 1
;;
esac
#!/bin/bash
#
# External STONITH module for synaccess.
#
# Copyright (c) 2008 Gresham Enterprise Storage
# Jeremy Linton <[EMAIL PROTECTED]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Further, this software is distributed without any warranty that it is
# free of the rightful claim of any third person regarding infringement
# or the like. Any license provided herein, whether implied or
# otherwise, applies only to this software file. Patent licenses, if
# any, provided herein do not apply to combinations of this program with
# other software, or any other product whatsoever.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
#
#
# This script requires a few things:
# net-snmp
# SYNACCESS-MIB.txt
# the hostnames that are controlled are placed in the "power outlet" "name"
field.
# The Synaccess device must have SNMP turned on
# The script must have the IP/Hostname of the synaccess device passed in via
"synaccessip"
#
# in order to use this script you must have installed the MIB that came with
the synaccess device
# in /usr/share/snmp/mibs/SYNACCESS-MIB.txt or similar. From then on the
net-snmp utilities
# are aware of the proper names.
# if you are having problems detecting the proper power status make sure the
mib power status reads:
#outletStatus OBJECT-TYPE
#SYNTAX INTEGER {
#off(0),
#on(1),
#off(2),
#on(257),
#off(256)
#}
# Check the synaccess specific mib with
# snmpwalk -c public -m SYNACCESS-MIB -v 1 x.x.x.x synAcc
# drop "public" in if the community isn't set
community=${community:-"public"}
# commands used to get/set snmp values
SNMP_GETCOMMAND="/usr/bin/snmpget -c $community -m SYNACCESS-MIB -v 1
$synaccessip"
SNMP_SETCOMMAND="/usr/bin/snmpset -c $community -m SYNACCESS-MIB -v 1
$synaccessip"
get_snmp_value()
{
echo `$SNMP_GETCOMMAND $1|cut -d: -f4`
}
# the port name given in the web interface must match the switched port number
# this discovers all the hostnames set as the outlet name
discover_hostlist()
{
portcount=`get_snmp_value SYNACCESS-MIB::powerOutletNum.0`
pc=1
for ((i=1; $i <= $portcount;i++)); do
portname=`get_snmp_value SYNACCESS-MIB::outletName.$i`
if [[ "$portname" && "$portname" != "Undefined" ]]; then
hostlist="$hostlist $portname"
fi
done
}
# this looks up the port number based on the passed hostname, using the power
outlet name
get_port_for_host()
{
hostlookup=$1
portcount=`get_snmp_value SYNACCESS-MIB::powerOutletNum.0`
pc=1
for ((i=1; $i <= $portcount;i++)); do
portname=`get_snmp_value SYNACCESS-MIB::outletName.$i`
if [[ "$portname" == "$hostlookup" ]]; then
echo "$i"
return 0
fi
done
}
# this sends a ON/OFF/RESET action to the given hostname
do_port_action()
{
portnum=`get_port_for_host $1`
if [[ "$portnum" ]]; then
out=`$SNMP_SETCOMMAND "SYNACCESS-MIB::outletAction.$portnum" = $2`
exit 0
else
exit 1
fi
}
# Handle script commands
case $1 in
gethosts)
discover_hostlist
for h in $hostlist ; do
echo $h
done
exit 0
;;
on)
do_port_action $2 1
;;
off)
do_port_action $2 2
;;
reset)
do_port_action $2 3
;;
status)
portnum=`get_port_for_host $2`
if [[ "$portnum" ]]; then
synPortStatus=`get_snmp_value SYNACCESS-MIB::outletStatus.$portnum
|cut -c1-2`
if [[ "$synPortStatus" == "on" ]]; then
exit 0
fi
else
exit 1
fi
;;
getconfignames)
echo "synaccessip community"
exit 0
;;
getinfo-devid)
echo "synaccess"
exit 0
;;
getinfo-devname)
synModel=`get_snmp_value SYNACCESS-MIB::systemModel.0`
synName=`get_snmp_value SYNACCESS-MIB::systemName.0`
echo "Synaccess netBooter $synModel $synName"
exit 0
;;
getinfo-devdescr)
echo "synaccess netbooter STONITH device"
exit 0
;;
getinfo-devurl)
echo "http://www.synaccess-net.com"
exit 0
;;
getinfo-xml)
# Parameters (hostname, synaccess IP, synaccess port)
cat << SAXML
<parameters>
<parameter name="synaccessip" unique="1" required="1">
<content type="string" />
<shortdesc lang="en">SynaccessIp</shortdesc>
<longdesc lang="en">The IP of the synaccess device controlling the
hosts</longdesc>
</parameter>
<parameter name="community" unique="1" required="0">
<content type="string" />
<shortdesc lang="en">Community</shortdesc>
<longdesc lang="en">The SNMP Community string</longdesc>
</parameter>
</parameters>
SAXML
exit 0
;;
*)
exit 1
;;
esac
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/