I recently bought a Belkin 600VA UPS (model F6S600auUSB) and here's what I had to do to setup the monitoring and automatic shutdown on Ubuntu 9.10 (karmic). (This procedure should work on recent versions of Debian as well.)

This UPS comes with a proprietary monitoring tool (written in Java) and you can find instructions to get this working on the Ubuntu forums, but I was looking for a free solution that would integrate well with the rest of the system. So after reading this blog post I decided to go with the Network UPS Tools project:

$ apt-get install nut

Once the nut package is installed, I edited /etc/nut/nut.conf to set:


and created the following files:

$ vim /nut/ups.conf  
driver = megatec_usb  
port = auto  
desc = "Belkin UPS, USB interface"  
$ vim /etc/nut/upsd.conf  
# MAXAGE 15  
# LISTEN 3493  
# MAXCONN 1024  
$ vim /etc/nut/upsd.users  
password = MYPASSWORD  
upsmon master  
$ vim /etc/nut/upsmon.conf  
MONITOR belkinusb@localhost 1 local_mon MYPASSWORD master  
POWERDOWNFLAG /etc/killpower  
SHUTDOWNCMD "/sbin/shutdown -h +0"  

Then all that was left to do was to restart nut:

$ /etc/init.d/nut restart

and check syslog for any errors:

$ tail /var/log/syslog

While nut is running, it will monitor the UPS and report any power problems to syslog. Once the UPS is running on battery, it will make sure the computer is safely shut down before power runs out.

Hopefully future versions of GNOME Power Manager will be able to integrate with nut directly and display battery information through its notification icon.