<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Hello happy nuters,<DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Some complementary words about making nut 2.02 successfully run on FreeBSD with MGE Ellipse.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>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.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>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.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>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...</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>1./ The start/stop script :</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">===============================================</SPAN></FONT></DIV><DIV>#! /bin/sh</DIV><DIV>#</DIV><DIV>## /usr/local/etc/rc.d/nut.sh : start/stop nut (ups management)</DIV><DIV>#</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin</DIV><DIV>NAME=nut</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>case "$1" in</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>    start)</DIV><DIV>        echo "Starting and checking (5 times) for nut driver mge-shut"</DIV><DIV>                chmod 0600 /dev/cuaa0</DIV><DIV>                chown nut:nut /dev/cuaa0</DIV><DIV>        COUNTER=5</DIV><DIV>        until [ $COUNTER -le 0 ]; do</DIV><DIV>                let COUNTER-=1</DIV><DIV>                echo "attempt to start driver mge-shut"</DIV><DIV>                /usr/local/ups/bin/upsdrvctl start</DIV><DIV>                sleep 10</DIV><DIV>                echo "testing for success"</DIV><DIV>                if (test -f /var/state/ups/mge-shut-cuaa0.pid)</DIV><DIV>                then</DIV><DIV>                        COUNTER=0</DIV><DIV>                fi</DIV><DIV>        done</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>        echo "Starting nut daemon upsd"</DIV><DIV>                /usr/local/ups/sbin/upsd -u nut</DIV><DIV>        </DIV><DIV>        echo "Starting nut monitor upsmon"</DIV><DIV>                /usr/local/ups/sbin/upsmon</DIV><DIV>        ;;</DIV><DIV>        </DIV><DIV>    stop)</DIV><DIV>        echo "Stopping nut monitor upsmon"</DIV><DIV>                kill -9 `cat /var/run/upsmon.pid`&gt; /dev/null</DIV><DIV>                rm /var/run/upsmon.pid  </DIV><DIV>        echo "Stopping nut daemon upsd"</DIV><DIV>                kill -9 `cat /var/state/ups/upsd.pid`&gt; /dev/null</DIV><DIV>                rm /var/state/ups/upsd.pid</DIV><DIV>        echo "Stopping nut driver mge-shut"</DIV><DIV>                /usr/local/ups/bin/upsdrvctl stop       </DIV><DIV>                sleep 5</DIV><DIV>                killall -9 mge-shut</DIV><DIV>                sleep 3</DIV><DIV>                rm /var/state/ups/mge-shut-cuaa0.pid</DIV><DIV>                rm /var/state/ups/mge-shut-cuaa0</DIV><DIV>                sleep 3</DIV><DIV>        ;;</DIV><DIV>        </DIV><DIV>    *)</DIV><DIV>        echo "Usage: /usr/local/etc/rc.d/$NAME.sh start|stop" &gt;&amp;2</DIV><DIV>        ;;</DIV><DIV>esac</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>exit 0</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">===============================================</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">2./ These are the additions to the /etc/rc.shutdown file (@ the end of the file)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">===============================================</SPAN></FONT></DIV><DIV>....</DIV><DIV># Insert other shutdown procedures here</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV># shutdown ups with upsdrvctl</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>if (test -f /etc/killpower)</DIV><DIV>then</DIV><DIV>        echo "Killing the power, bye !"</DIV><DIV>#       insuring no mge-shut driver is running and cleaning pid files</DIV><DIV>        killall -9 mge-shut</DIV><DIV>        sleep 3</DIV><DIV>        rm /var/state/ups/mge-shut-cuaa0.pid</DIV><DIV>        rm /var/state/ups/mge-shut-cuaa0</DIV><DIV>        </DIV><DIV>#      a rather large sleep to insure the ups stop babbling</DIV><DIV>        sleep 20</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>#       shutting down the ups   </DIV><DIV>        /usr/local/ups/bin/upsdrvctl shutdown</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>#       sleep 120</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>        # The shutdown -p failed</DIV><DIV>        # you need to reboot</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>fi</DIV><DIV>...</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">===============================================</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">3./ the SHUTDOWNCMD</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">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 :</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">===============================================</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">...</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">SHUTDOWNCMD "/sbin/shutdown -p now"</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">...</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">===============================================</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">4./ More info on FreeBSD shutdown process</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">About the shutdown in FreeBSD please read this I quote from another ups related site : </DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Times" size="4"><SPAN class="Apple-style-span" style="font-size: 16px;">"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)</SPAN></FONT><FONT class="Apple-style-span" face="Times" size="4"><SPAN class="Apple-style-span" style="font-size: 16px;">"</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">To work around this problem this is how my ups.conf contains :</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">===============================================</SPAN></FONT></DIV><DIV>...   </DIV><DIV>     user = nut</DIV><DIV>        driverpath = /usr/local/ups/bin</DIV><DIV>        pollinterval = 15</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>[ups_myserver]</DIV><DIV>        driver = mge-shut</DIV><DIV>        port = /dev/cuaa0</DIV><DIV>        desc = "MGE Ellipse 800 powering  myserver"</DIV><DIV>        offdelay = 60</DIV><DIV>        ondelay = 9 </DIV><DIV>        nolock  </DIV><DIV>        notification = 3</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">...</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">===============================================</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">The offdelay is set to 60 seconds which is enough in my case to do the disks syncing and halt processes.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">The pollinterval is increased to limit the traffic on the serial line.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">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.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Please read the info Arnaud sent about this in the <FONT class="Apple-style-span" color="#461B8B" face="Times" size="4"><SPAN class="Apple-style-span" style="font-size: 16px; "><SPAN class="Apple-style-span" style="text-decoration: underline;">[Nut-upsuser] Re: followup : MGE Ellipse 800 USBS doesn't shutdown under FreeBSD</SPAN><FONT class="Apple-style-span" color="#000000" face="Helvetica" size="3"><SPAN class="Apple-style-span" style="font-size: 12px;"> post.</SPAN></FONT></SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">That's all for today, I hope this might help.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">François</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV></BODY></HTML>