Sou a: Inici / Usuaris / rborrell / articles / UPS Eaton Ellipse 600 with Ubuntu Lucid 10.04

UPS Eaton Ellipse 600 with Ubuntu Lucid 10.04

Use nutd and upsmon

Install the nut package. This should conflict with nut-hal-drivers if it’s already installed.

$ sudo apt-get install nut

Installing the nut package, should add the nut user and group. If it doesn’t, you have to add those manually. Next, create or edit /etc/nut/ups.conf:

# /etc/nut/ups.conf

[apc] driver = usbhid-ups port = auto

The label in the square brackets can be anything. It identifies the UPS to upsd and upsmon. Find your UPS model on the NUT hardware compatibility list and substitute the corresponding driver for usbhid-ups above. If your UPS isn’t listed, find similar ones. They probably use the same driver. If you have a USB-based UPS, you can leave the port as auto; it’s ignored. Otherwise, the port will usually be /dev/ttyS0, the first serial port, or /dev/ttyS1, the second. If your UPS is connected via the serial port, you’ll need to modify the permissions on the serial port device so that nut can access it. Create the file /etc/udev/rules.d/99_nut-serialups.rules:

# /etc/udev/rules.d/99_nut-serialups.rules KERNEL=="ttyS0", GROUP="nut"

Replace ttyS0 with ttyS1 if your UPS is connected to the second serial port. Next, issue the following two commands to force udev to make the necessary permissions change:

$ sudo udevadm control --reload_rules $ sudo udevadm control trigger

Note that the preceding two steps are unnecessary if you have USB-based UPS. Finally, we can make sure that nut properly detects the UPS:

$ sudo upsdrvctl start

You should see something like the following:

Network UPS Tools - UPS driver controller 2.2.2 Network UPS Tools: 0.29 USB communication driver - core 0.33 (2.2.2)

Using subdriver: APC HID 0.92

Now, we need to configure upsd and upsmon. upsd communicates with the UPS driver that we just started. upsmon communicates with upsd and actually shuts down the machine in the event of a power failure. Why the extra level of indirection? Multiple instances of upsmon can be started on different machines. They can all share the same physical UPS. Create the file /etc/nut/upsd.conf as follows:

# /etc/nut/upsd.conf ACL all ACL localhost ACCEPT localhost REJECT all

This rejects all connections not originating from the local machine. If you need to monitor from multiple machines, see the man page for upsd.conf. Next, create /etc/nut/upsd.users:

# /etc/nut/upsd.users [local_mon] password = PASSWORD_HERE allowfrom = localhost upsmon master

Replace PASSWORD_HERE with a real password. You should add multiple users if you are monitoring from multiple machines. See the man page for upsd.users for more information. Now we need to configure upsmon. Create /etc/nut/upsmon.conf as follows:

# /etc/nut/upsmon.conf MONITOR apc@localhost 1 local_mon PASSWORD_HERE master POWERDOWNFLAG /etc/killpower SHUTDOWNCMD "/sbin/shutdown -h now"

Replace apc with the name you have your UPS in /etc/nut/ups.conf and PASSWORD_HERE with the password you set in /etc/nut/upsd.users. Since these files contain sensitive data, we should fix the permissions:

$ sudo chown root:nut /etc/nut/ $ sudo chmod 640 /etc/nut/

Finally, edit /etc/default/nut so that upsd and upsmon will start at system boot:

# /etc/default/nut START_UPSD=yes START_UPSMON=yes

The moment of truth:

$ sudo /etc/init.d/nut start

Check the end of /var/log/daemon.log to make sure everything started up. Also, you can run the following command which should print out some statistics:

$ upsc apc

Replace apc with whatever you named your UPS. What’s left? Save your work, unplug the UPS, and make sure your machine shuts down cleanly. This may take a while. By default, upsmon waits until the battery is at a critically low level before initiating a shutdown. What’s the point of having 20 minutes of battery life if you aren’t going to use it?

As you can see, this second method is quite a bit more difficult to configure. That said, using upsd and upsmon, as opposed to nut-hal-drivers, is probably the more reliable method of monitoring a UPS. It’s also the only option available if you need to monitor one UPS from multiple machines.