Having a UPS (uninterruptible power supply) connected to your system is a great way to ensure uptime, but without software to monitor the status of the UPS, the benefit provided may be no benefit at all. If the battery runs out and your system still hasn't shut down, then it would be as if no UPS was connected in the first place.
One software package that works with a wide variety of UPS hardware is the NUT package, or Network UPS Tools. You can download this package from http://www.networkupstools.org/, or it may be available with your Linux distribution.
NUT is straightforward, and the configuration file samples are heavily commented. To begin, Nut must be installed and you need to configure your UPS using the /etc/ups/ups.conf configuration file (the location of the file may vary from distribution to distribution). Defining a USB-based APC UPS, you may have a configuration file consisting of:
[myups]
driver = hidups
port = /dev/usb/hiddev0
desc = "My UPS"
This uses the hidups (USB-based) driver with the /dev/usb/hiddev0 device; the name of the UPS is myups. The default /etc/ups/upsd.conf should be sufficient for local monitoring with its default ACLs that allow localhost connections to the daemon.
Next, you need to define a user in /etc/ups/upsd.users that has access to the upsd daemon:
[monuser]
password = secret
allowfrom = localhost
upsmon master
This defines the user monuser with the password secret and makes it a master upsmon user. Finally, edit /etc/ups/upsmon.conf to set a MONITOR directive for the host to monitor:
MONITOR myups@localhost 1 monuser secret master
This tells the upsmon daemon to connect to the UPS myups on the localhost as the user monuser with the password secret and indicates it is a UPS master user.
Once configuration is done, you can start the UPS daemon and monitor, usually with:
# /etc/init.d/upsd start
# /etc/init.d/upsmon start
Now, upsmon will connect to upsd and obtain status information (such as whether it's online, on battery, etc.) about the UPS.



