Upsilon UPS SNMP agent extensions for Linux
The Upsonic Power UPS have a
very neat little serial port controlled UPS. The control software that
comes with it is an application called Upsilon. This includes a mode
for monitoring a remote UPS via SNMP. The device monitored uses
the UPS MIB. Unfortunately
the Upsilon daemon, doesn't seem to report the UPS MIB. If it did then
when you add a second Linux box to the UPS, you could use the remote
mode to shutdown the second server based on the state of the server
with the UPS attached.
Configuring Linux SNMP extension to provide UPS MIB
Script to implement MIB extension
(refer man page for snmpd.conf).
The crux of the code looks at the last line of the Upsilon log file,
and if it is something that indicates that the power has failed then
reports the "Input Voltage" as 0. Should power recover before shutdown,
another message is written to the file, and the value is restored.
Create the file /etc/upsilon/snmpd.sh
#!/bin/sh
# Written by David Horton 2-Oct-2005
#echo `date` " : " $* >> /tmp/ups.log
if [ "$1" != "-g" ]
then
exit 0
fi
case "$2" in
.1.3.6.1.4.1.935.1.1.1.3.2.1.0)
# upsSmartInputLineVoltage
echo .1.3.6.1.4.1.935.1.1.1.3.2.1.0
echo integer
if tail -1 /etc/upsilon/rupslog | grep 'System will be shut down' > /dev/null
then
echo 0
else
if tail -1 /etc/upsilon/rupslog | grep 'AC Power Fails' > /dev/null
then
echo 0
else
echo 2400
fi
fi
;;
.1.3.6.1.4.1.935.1.1.1.1.1.1.0)
# upsBaseIdentModel
echo .1.3.6.1.4.1.935.1.1.1.1.1.1.0
echo string
echo "PCP600 $*"
;;
# upsBaseBatteryStatus
.1.3.6.1.4.1.935.1.1.1.2.1.1.0)
echo .1.3.6.1.4.1.935.1.1.1.2.1.1.0
echo integer
# unknown(1) batteryNormal(2) batteryLow(3)
echo 2
;;
# upsSmartOutputVoltage
.1.3.6.1.4.1.935.1.1.1.4.2.1.0)
echo .1.3.6.1.4.1.935.1.1.1.4.2.1.0
echo integer
echo 2400
;;
# upsSmartOutputFrequency
.1.3.6.1.4.1.935.1.1.1.4.2.2.0)
echo .1.3.6.1.4.1.935.1.1.1.4.2.2.0
echo integer
echo 500
;;
# upsSmartOutputLoad
.1.3.6.1.4.1.935.1.1.1.4.2.3.0)
echo .1.3.6.1.4.1.935.1.1.1.4.2.3.0
echo integer
echo 100
;;
esac
exit 0
Configure the Linux NETSnmp to run the script
Configure /etc/snmp/snmpd.conf
to include the following
sections. (Some context is included).
view
systemview included .1.3.6.1.2.1.25.1.1
# Power management Upsilon
view systemview
included .1.3.6.1.4
#view systemview
included .1.3.6.1.4.1.935
####
and at the very end
# Hacked support for Upsilon MIB
pass .1.3.6.1.4.1.935 /etc/upsilon/snmpd.sh
Then restart the snmpd
service.
(Preferred remote action method)
The better method is to use a remote shutdown command. This used to be
easy with remsh, but ssh is more complicated. Note that the command has
to work unattended, and hence you can't enter a password/phrase.
e.g. to shutdown a Solaris server (wafer) on the network using remsh -:
Put this in /etc/upsilon/preshut.bat
# The commands in this file will
be executed before the system halt.
echo "Executing preshut processes ..."
sync
sync
nohup /usr/bin/rsh wafer /usr/sbin/shutdown -y -i 5 now <
/dev/null > /dev/null 2>&1 &
David Horton - 3-Oct-2005