Search:  
Gentoo Wiki

NUT


This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

Contents

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.

Note: This tutorial is quite limited. You might also want to read this so that you can consider other setup options.

Install

Now emerge nut using emerge -av sys-power/nut.

Configuring

Open /etc/nut/ups.conf in an editor. Add to this file every UPS you want to monitor. Mine looks like this:

File: /etc/nut/ups.conf
       [powerware]
          driver = bcmxcp
          port = /dev/ttyS0
          desc = "Server, adsl, 3com"

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. If you have a USB connection to your UPS, you should build sys-power/nut with USE="hal usb". Your entry might look like:

File: /etc/nut/ups.conf
       [apc500]
          driver = newhidups
          port = auto
          desc = "APC Back-UPS 500"

for Mustek:

File: /etc/nut/ups.conf
       [Mustek]
          driver = megatec_usb
          port = auto
          desc = "Power Mustek 800 USB"

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

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

File: /etc/nut/upsd.conf
      ACL all 0.0.0.0/0
      ACL localhost 127.0.0.1
      
      ACCEPT localhost
      REJECT all

The ACL-lines are used to add hosts. The syntax is ACL name IP. If the name is placed after ACCEPT connections from there are accepted, if it's placed under REJECT, connections are rejected.

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

File: /etc/nut/upsd.users
        [server]
           password = changeme
           allowfrom = localhost
           actions = SET
           instcmds = ALL
           upsmon master

Next take a look at upsmon.conf. 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.

Have a look att upssched.conf 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 nut user will have access to /dev/ttyS*). Newer portage installs already have this done, but it won't hurt to run again: usermod -G uucp nut. If you are using USB port ("auto" setting) to communicate with your UPS, you should run usermod -G usb nut.

Finishing

Now, start the services:

/etc/init.d/upsdrv start
/etc/init.d/upsd start
/etc/init.d/upsmon start

And add them to the default runlevel:

rc-update add upsdrv default
rc-update add upsd default
rc-update add upsmon default

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 nut to the tty-group. A similar error for usb-connected UPSs can be fixed by adding nut to the plugdev group.

Testing

Test upsc and see if your UPS replies: upsc yourupsname@yourupshost ups.status.

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 upsc yourupsname@yourupshost.

See also

Retrieved from "http://www.gentoo-wiki.info/NUT"

Last modified: Tue, 23 Sep 2008 18:34:00 +0000 Hits: 14,639