[Nut-upsuser] MGE Ellipse 800 USBS & FreeBSD

François Rayer francois at 4umusic.com
Wed Aug 24 08:38:37 UTC 2005


Hello happy nuters,


Some complementary words about making nut 2.02 successfully run on  
FreeBSD with MGE Ellipse.


With the usefull information Arnaud sent, it's rather obvious that  
the erratic response of the ups to the shutdown script is linked to  
its difficulty to handle large traffic on the serial line.

These are the final tweak I made to have this configuration  
satisfyingly operational. As I said in a former post, it might seem  
sometime a little rude, but it's a way to work around the serial link  
struggle which sometime might happen either at startup or shutdown,  
leading the mge-shut driver not to work properly.

As far I tested, it seems to work fine for my configuration but I  
strongly recommend you to do extensive testing of your system before  
considering it operational. Just in case you need some more tweaking...




1./ The start/stop script :

===============================================
#! /bin/sh
#
## /usr/local/etc/rc.d/nut.sh : start/stop nut (ups management)
#

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=nut

case "$1" in

     start)
         echo "Starting and checking (5 times) for nut driver mge-shut"
                 chmod 0600 /dev/cuaa0
                 chown nut:nut /dev/cuaa0
         COUNTER=5
         until [ $COUNTER -le 0 ]; do
                 let COUNTER-=1
                 echo "attempt to start driver mge-shut"
                 /usr/local/ups/bin/upsdrvctl start
                 sleep 10
                 echo "testing for success"
                 if (test -f /var/state/ups/mge-shut-cuaa0.pid)
                 then
                         COUNTER=0
                 fi
         done

         echo "Starting nut daemon upsd"
                 /usr/local/ups/sbin/upsd -u nut

         echo "Starting nut monitor upsmon"
                 /usr/local/ups/sbin/upsmon
         ;;

     stop)
         echo "Stopping nut monitor upsmon"
                 kill -9 `cat /var/run/upsmon.pid`> /dev/null
                 rm /var/run/upsmon.pid
         echo "Stopping nut daemon upsd"
                 kill -9 `cat /var/state/ups/upsd.pid`> /dev/null
                 rm /var/state/ups/upsd.pid
         echo "Stopping nut driver mge-shut"
                 /usr/local/ups/bin/upsdrvctl stop
                 sleep 5
                 killall -9 mge-shut
                 sleep 3
                 rm /var/state/ups/mge-shut-cuaa0.pid
                 rm /var/state/ups/mge-shut-cuaa0
                 sleep 3
         ;;

     *)
         echo "Usage: /usr/local/etc/rc.d/$NAME.sh start|stop" >&2
         ;;
esac

exit 0
===============================================



2./ These are the additions to the /etc/rc.shutdown file (@ the end  
of the file)

===============================================
....
# Insert other shutdown procedures here

# shutdown ups with upsdrvctl

if (test -f /etc/killpower)
then
         echo "Killing the power, bye !"
#       insuring no mge-shut driver is running and cleaning pid files
         killall -9 mge-shut
         sleep 3
         rm /var/state/ups/mge-shut-cuaa0.pid
         rm /var/state/ups/mge-shut-cuaa0

#      a rather large sleep to insure the ups stop babbling
         sleep 20

#       shutting down the ups
         /usr/local/ups/bin/upsdrvctl shutdown

#       sleep 120

         # The shutdown -p failed
         # you need to reboot

fi
...
===============================================


3./ the SHUTDOWNCMD

Please notice that most of the recent hardware might use the "-p"  
option for the shutdown command. This will automatically switch of  
the FreeBSD computer after halted. This will save battery and so  
makes the recharging process shorter. So this is the way the shutdown  
command looks like in the ups.conf :

===============================================
...
SHUTDOWNCMD "/sbin/shutdown -p now"
...
===============================================


4./ More info on FreeBSD shutdown process

About the shutdown in FreeBSD please read this I quote from another  
ups related site :

"On the FreeBSD OS, there is no known way for a user program to get  
control when all the disks are synced. This is needed for apcupsd to  
be able to issue the killpower command to the UPS so that the UPS  
shuts off the power. To accomplish the same thing on FreeBSD systems,  
make sure you have a SmartUPS and that your UPS shutdown grace period  
is set sufficiently long so that you system will power down (usually  
2 minutes)"

To work around this problem this is how my ups.conf contains :

===============================================
...
      user = nut
         driverpath = /usr/local/ups/bin
         pollinterval = 15

[ups_myserver]
         driver = mge-shut
         port = /dev/cuaa0
         desc = "MGE Ellipse 800 powering  myserver"
         offdelay = 60
         ondelay = 9
         nolock
         notification = 3
...
===============================================

The offdelay is set to 60 seconds which is enough in my case to do  
the disks syncing and halt processes.

The pollinterval is increased to limit the traffic on the serial line.


5./ Be warned that the "battery.charge: XX" reported by the ups after  
a powerfail and a ups shutdown is probably totally wrong because of  
the Ellipse design. Don't try to unplug the ups immediately or you  
may face an out of battery shut off and some serious filesystem  
problems.

Please read the info Arnaud sent about this in the [Nut-upsuser] Re:  
followup : MGE Ellipse 800 USBS doesn't shutdown under FreeBSD post.


That's all for today, I hope this might help.

François



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20050824/4c7e1ad5/attachment-0001.htm


More information about the Nut-upsuser mailing list