NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.

Forum Discussion

Infinite's avatar
Infinite
Aspirant
Nov 15, 2009

NUT on OSX 10.6 [Sharing a UPS with ReadyNAS and Computers]

First off: I can not take much credit for this post, the majority of this write up was done by Egg in this post "NUT on OS X (10.5.7)" which was priceless in my effort to get this matter solved. It looks Egg was pulling a lot of data from other members. I have made some edits to hopefully simplify the setup for you and have updated some information for 10.6. I also wanted to clarify what NUT is and why you might want it some day.

Background
NUT, is the Network UPS Tool: http://www.networkupstools.org/. When you plug a compatible UPS into ReadyNAS it's NUT that collects the data about the UPS status.

Native OSX Support
OSX 10.5 or later has some UPS feature built in when connecting a UPS to your Mac, but it doesn't have any built in support for shared UPS. You are up a creek if you have 2 Macs on a single UPS.

APC UPS Software and 3rd Party Mac Software
In addition, if you have an APC UPS you will notice that there is no software support post 10.4.x. APC is just letting OSX handled the effort. 3rd party tools like "APC Tracker" is rather expensive, does NOT seem to work on OSX 10.6, and might not be compatible with the ReadyNAS... I don't know. And as Egg pointed out in his post the Legacy APC solution (ACPUSPd) isn't compatible with the ReadyNAS. Other network cards for your APC UPS will cost you over $250 and from what I have read they aren't supported by the ReadyNAS either.

Solution
For the best Mac and ReadyNAS support you will want to setup NUT on your Macs. From my own research it's also seem like the only solution at present, but it's also the cheapest solution (free).

The Goal
Sharing a UPS with multiple Computer and ReadyNAS devices
In this setup we are letting a ReadyNAS be the NUT server and the rest of the ReadyNAS's and Mac will be client of that ReadyNAS. The UPS will have a USB connection with the Server. All of the devices will get their power from the UPS.

Lets start.

Setup:
2x ReadyNAS NV+ 4.1.6, ReadyNAS Duo 4.1.6, MacMini (Core2 Duo) OSX Server (10.6.2), MacMini (Core Duo) OSX Server (10.5.8) all on a one UPS (APC Smart-UPS 1500 SUA1500RM2U )

ReadyNAS Duo acts as the NUT server, the 2 NV+ and 2 MacMini's are NUT client.

Installing NUT
In order to get NUT on the MacMini installed you will need to follow the following Steps:

Download Fink (http://www.finkproject.org)
At present ( Nov 14, 2009 there is no Fink binary for OSX. So you will need to download the source and build and install it. It's very easy and it's clearly defined on the site. Go to this URL for the directions to install Fink. http://www.finkproject.org/download/srcdist.php You can use all the default values, the only value that wasn't the default for me was I decided to build everything as 64bit. If you have a 32bit cpu you won't get the prompt. One of my MacMini's is a Core Duo cpu's is 32bit install while the other MacMini is Core2 Duo and is using the 64bit version, both are working just fine.

The only thing that I should point out is after you run the shell installer ( /sw/bin/pathsetup.sh ) you need to quit Terminal and the reopen it for the changes to take.

Download and Install "Fink Commander" ( http://finkcommander.sourceforge.net/ )
At present 0.5.5 is the most recent version and I would recommend just using the Universal Binary which is Snow Leopard friendly.

Download and install Nut via "Fink Commander"
At present there does not seem to be binary's for Nut for 10.6. I decided to let Fink compile the source for both Machines just because Fink Commander does all the work for your. Compiling the source just take a little more time.

Setting up the upsmon.config by Egg
[Updated by Infinite]
In order to run only the NUT client (which is what I wanted) one needs to create the upsmon.config file in the /sw/etc/nut directory.

Open Terminal:
Note: if you prefer vi or mate (TextMate) as your text editor then feel free to use them instead nano
cd /sw/etc/nut
sudo cp upsmon.conf.sample upsom.conf
sudo nano upsmon.conf


Change the values according to dbott67s advice for WinNut and quit vi by writing first the changed content to the new file 'upsmon.conf'.

Using the ReadyNAS to create a Network UPS for PCs

In order to test that the NUT client actually works, use Terminal again and start upsmon manually:
sudo upsmon


The following is slightly altered advise based on http://boxster.ghz.cc/projects/nut/wiki/NutOnMacOSX.

Now you should be able to see two upsmon processes in the Activity Monitor or use the following line in Terminal. Remember to ignore the 3rd reference to "grep".
ps aux | grep upsmon


In Terminal enter the following to test the connection from your Mac via your ReadyNAS to the UPS:
sudo upsc UPS@[Your_ReadyNAS_IP]


In the Terminal window you should get a response back based on the type of your UPS device.

Automatic Startup
[Updated for OSX 10.6 and general cleaner scripts - Infinite]
For OS X it is necessary to navigate to /System/Library/StartupItems. I started by copying another directory tree (I used 'IPFailover') as a template for 'UPS' directory. To comply with the Apple standards all user Startup items should be located in /Library/StartupItems, we'll copy the item from the System folder to there user location. Then I changed to the 'UPS' directory and renamed the 'IPFailover' file to 'UPS' using the mv command. And last I edited the files in the 'UPS' directory.

These are the terminal commands:
cd /System/Library/StartupItems
sudo cp -R IPFailover /Library/StartupItems/UPS
cd /Library/StartupItems/UPS
sudo mv IPFailover UPS
sudo nano UPS



Hint: If you don't have IPFailover then use one of the other folders from StartupItems

Edit /Library/StartupItems/UPS with a text editor:
cd /Library/StartupItems/UPS
sudo nano UPS


Now replace the the contents of /Library/StartupItems/UPS with the code:
#!/bin/sh

##
# UPS Monitor script
# Using Network UPS Tools executables
##

. /etc/rc.common

FINK_BIN="/sw/sbin"

StartService ()
{
ConsoleMessage "Starting NUT (UPS Service)"
if [ -n "`ps acxw | grep -i "upsmon" | awk {'print $1'}`" ]; then
ConsoleMessage -f "NUT (UPS Service)"
echo "Failed to start NUT (UPS Service): It is already running."
exit 0
fi
${FINK_BIN}/upsmon &
if [ -n "`ps acxw | grep -i "upsmon" | awk {'print $1'}`" ]; then
ConsoleMessage -s "NUT (UPS Service)"
echo "NUT (UPS Service) successfully started."
exit 0
else
ConsoleMessage -f "NUT (UPS Service)"
echo "Failed to start NUT (UPS Service): Either the application has been deleted or it has no execution right."
exit 0
fi
}

StopService ()
{
ConsoleMessage "Stopping NUT (UPS Service)"
if [ -z "`ps acxw | grep -i "upsmon" | awk {'print $1'}`" ]; then
ConsoleMessage -s "NUT (UPS Service)"
echo "Failed to stop NUT (UPS Service): It is not running."
exit 0
fi
${FINK_BIN}/upsmon -c stop
if [ -n "`ps acxw | grep -i "upsmon" | awk {'print $1'}`" ]; then
ConsoleMessage -s "NUT (UPS Service)"
echo "Failed to stop NUT (UPS Service) out of unknown reason."
exit 0
else
ConsoleMessage -s "NUT (UPS Service)"
echo "NUT (UPS Service) successfully stopped."
exit 0
fi
}

StopServiceForcefully()
{
ConsoleMessage "Stopping NUT (UPS Service)"
if [ -z "`ps acx | grep -i "upsmon" | awk {'print $1'}`" ]; then
echo "Failed to stop NUT (UPS Service): It is not running."
else
kill -kill `ps acxw | grep -i "upsmon" | awk {'print $1'}`
if [ -n "`ps acxw | grep -i "upsmon" | awk {'print $1'}`" ]; then
echo "Failed to stop NUT (UPS Service) out of unknown reason."
else
echo "NUT (UPS Service) successfully stopped."
fi
fi
}

RestartService()
{
ConsoleMessage "Trying to restart NUT (UPS Service)."
StopService
StartService
exit 0
}

RunService "$1"


Now edit the StartupParamerters.plist via:
cd /Library/StartupItems/StartupParamerters.plist
sudo nano UPS


Replace it's contents with the following code.


<?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>Description</key>
<string>UPS Monitor client (NUT)</string>
<key>Messages</key>
<dict>
<key>start</key>
<string>Starting UPS Monitor client (NUT)</string>
<key>stop</key>
<string>Stopping UPS Monitor client (NUT)</string>
</dict>
<key>OrderPreference</key>
<string>None</string>
<key>Provides</key>
<array>
<string>UPS</string>
</array>
<key>Requires</key>
<array>
<string>Resolver</string>
</array>
</dict>
</plist>


That's it! Now the automatic start-up should work.

Conclusion
At this point I have the two ReadyNAS NV+ and the two MacMini's communicating via NUT to the ReadyNAS Duo which is connected to the UPS via USB. I have restarted my MacMini's verified that the startup scripts are running. All is left is to simulate a power failure.

Here is the output I get from one of my MacMini's that's pulling this data from the ReadyNAS Duo:

bash$ sudo uspc UPS@192.168.1.108
sudo: uspc: command not found
miniserver:UPS admin$ sudo upsc UPS@192.168.1.108
battery.charge: 100
battery.chemistry: PbAc
battery.runtime: 20340
battery.voltage: 27.7
driver.name: hidups
driver.parameter.lowbatt_pct: 10
driver.version: 2.0.5
ups.mfr: APC
ups.model: Smart-UPS 1500 RM
ups.serial: [The Device S/N]
ups.status: OL


Enjoy!

Resources

12 Replies

NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology! 

Join Us!

ProSupport for Business

Comprehensive support plans for maximum network uptime and business peace of mind.

 

Learn More