NUT

About
The Network UPS Tools (NUT) provide monitoring of UPS and PDU hardware and ensure safe shutdowns of the systems which are connected.

For more information about it, you can check NUT homepage.

Introduction
I bought a Powerware 5115 UPS and wanted my computer to speak with it. NUT can speak with quite many UPS, so this howto isn't just for the Powerware 5115, although the examples in it will be for it, but it won't be difficult to merge it to your hardware. Start with surfing to the NUT's compatibility section. Is your UPS supported? If it isn't, look for a model that is in the same series. With good luck it can work, but that isn't for sure. When you find your UPS in the list, check what driver works with it, and write it down for later use.

USE Flags
If you have a USB connection to your UPS, you should build with.

Emerge
Now emerge NUT using:

Configuration
Open in an editor. Add to this file every UPS you want to monitor.

The general form is:

Change the values to something that fit's your configuration better and save. Here you can find a list of supported UPS and the according drivers.

Your entry might look like:

or like this:

for Mustek like this:

upsd
Open. This file contains access-policy to the UPS's you have.

The general form is:

To only allow the same computer to connect to them, the file should look like this:

Users
Next open. This file contains accounts for users who want's to play with the UPS:es. The following line grants acces to the user to everything.

upsmon
Next take a look at. This is the UPS Monitors configuration. Read through it. There isn't much to read, and it is easy understood. This is the only section where you have think a bit...

Be sure to create a MONITOR rule:

/etc/nut/upsmon.conf

upssched
Have a look att too, there might be something you want.

Port Ownership
If you are using RS-232 serial port to communicate with your UPS, you should run the following (so that your user will have access to ). Newer portage installs already have this done, but it won't hurt to run again:

If you are using USB port ("auto" setting) to communicate with your UPS, you should run:

Finishing
Now, start the services:

And add them to the default runlevel:

If you didn't get any error when you started the services you seemed to configure it right. Else, have a look at the error output and think what might be wrong. One error I got was the permissions of the serialport, which is easy fixed with adding to the  group. A similar error for usb-connected UPSs can be fixed by adding to the  group.

Testing
Test upsc and see if your UPS replies:

If you get "OL" (On Line) everything is working good (if it is on the line and not battery).

To see every command your UPS supports, type: