月別アーカイブ: 2011年10月

Netgear ReadyNAS + FreeBSD + Mac on an APC UPS

(日本語版はまた後日)
There were ReadyNAS, FreeBSD box, and OS X server (Mac mini) all working in my lab. Today, I’ve installed an APC’s UPS, because we have a planned power outage tomorrow.
Since the UPS has enough output capacity for all of NAS + FreeBSD box + Mac, my first plan was:
1) connect UPS to OS X server
2) install apcupsd on FreeBSD
3) NAS + FreeBSD shares the UPS via SNMP
but the plan was soon collapsed because OS X server has no easy way to share its UPS status via SNMP.
The second plan was:
1) connect UPS to OS X server, with apcupsd installed
2) install apcupsd
3) NAS + FreeBSD shares the UPS via SNMP or apcupsd’s NIS feature
* acpupsd NIS is not the Sun’s one, but just it’s special protocol over TCP.
however, again the plan didn’t work. The UPS could be shared between the Mac and FreeBSD box pretty well by apcupsd’s NIS feature, but the NAS couldn’t communicate with the acpupsd NIS server on Mac. One more thing I got know was that apcupsd can’t share its UPS status via SNMP. apcupsd can only “refer” UPS via SNMP, but it can’t provide its status to SNMP servers.
Situation got too bad at this point. There’s no substitute plan, so I can’t go home… But suddenly I’ve found that ReadyNAS has its tcp/3493 port open, and this port is for nut (network UPS tools). So the final plan was this:
1) connect UPS to ReadyNAS
2) install nut on FreeBSD and Mac (both in ports collection and MacPorts)
3) share the UPS with nut protocol
… and I was at the gate of the hell, at this point. apcupsd doesn’t require any kind of authentication info, but nut requires UPS name to connect with a remote UPS. Netgear’s document doesn’t say anything about nut auth.
After an hour, I finally found the UPS name “UPS” on ReadyNAS. And this is everything I’ve wrote in upsmon.conf.
MONITOR UPS@192.168.x.x 1 upsmon pass master
On Mac, I had to write /Library/LaunchDaemons/org.nut.upsmon.plist:
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<dict>
<key>Label</key>
<string>org.nut.upsmon</string>
<key>RunAtLoad</key>
<false/>
<key>KeepAlive</key>
<dict>
<key>NetworkState</key>
<true/>
</dict>
<key>ProgramArguments</key>
<array>
<string>/opt/local/sbin/upsmon</string>
<string>-D</string>
</array>
</dict>
</plist>
then:
sudo launchctl load -w /Library/LaunchDaemons/org.nut.upsmon.plist
NAS, FreeBSD and Mac goes down at the battery remaining capacity that is configured in ReadyNAS’s web interface.