Categories
Linux

Monitoring a UPS with nut on Debian or Ubuntu Linux

There are two different ways to monitor a UPS with nut: either expose the UPS hardware to GNOME Power Manager through hal or monitor the UPS directly with upsmon and upsd. There are trade-offs with each approach. Let’s take a look at both.

Use GNOME Power Manager and hal

On Debian or Ubuntu systems, install the nut-hal-drivers package.

$ sudo apt-get install nut-hal-drivers

GNOME Power Manager should already be running and should automatically detect the UPS. If it’s not running, you can start it from the command line or set it to start automatically in each session with the Sessions system preference. An icon will appear in the system tray if everything is working.

GNOME Power Manager system tray icon and tooltip.
GNOME Power Manager system tray icon and tooltip.

Clicking the system tray icon and selecting UPS from the menu will give detailed information.

GNOME Power Manager UPS details.
GNOME Power Manager UPS details.

GNOME Power Manager can be configured to shutdown or hibernate the computer when the UPS battery level drops below certain thresholds. There are also gconf keys to change which thresholds are used, percentage or time left, and what those thresholds are.

This method of monitoring a UPS is useful for a workstation, but there are three significant disadvantages:

  1. GNOME Power Manager is not running when you aren’t logged in. If your machine loses power at the login screen, it will not shutdown automatically.
  2. Currently, the nut-hal-drivers package only supports USB-based UPS’s. Many older and higher-end UPS’s are serial-based.
  3. GNOME Power Manager’s UPS support is buggy. While it displays notifications of low battery and critically low battery, it doesn’t take any actions. See Debian bug #482431 and GNOME bug #539843.

Update on 2009-01-06:

Arnaud Quette, the nut project leader, informed me of two other significant disadvantages with using nut-hal-drivers:

  1. gnome-power-manager will not power off the UPS at the end of a shutdown from power failure. This means that either the UPS will be fully drained, or worse, power will be restored before the battery is fully drained and the computer will not automatically start up again.
  2. No further work will be done on nut-hal-drivers. HAL is going to be replaced with DeviceKit and nut-hal-drivers will be replaced with DeviceKit-power.

Conclusion: Don’t use nut-hal-drivers unless you really, really want a fancy notification icon.

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 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 0.0.0.0/0
ACL localhost 127.0.0.1/32
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.

90 replies on “Monitoring a UPS with nut on Debian or Ubuntu Linux”

Hi! Thanks for your excellent article from me, too.

Another remark: The first udevadm-line (the one before the trigger) contains a typo:
It should read udevadm control –reload-rules (no underscore in –reload-rules).

Thanks!
Oliver

thankyou muchly… after following your guide i have finally gotten my Powerware 3105 talking to my ubuntu intrepid box

Man o Man! did this tutorial work! i can finally use my not-so-smart ups to atleast shutdown my pc when battery level is low.Othewise pc just used to turn off once the ups battery runs out. Also this works flawlessly with arch!
Loads of thanks!

Great article, but needs an update for Jaunty. In particular, you simply don’t bother with
upsd.conf

anymore unless you need some fancy customization not described
here. However, you will want to set up

MODE=standalone

in /etc/nut/nut.conf, or nothing will start. Also, I found I had to power cycle my UPS before it would talk to nut.

Thanks, Dave.

I’m going to do a big revision fairly soon so that I can add some info on DeviceKit-power. I’ll be sure to fix the Jaunty stuff at the same time (seems that configuration has been simplified in nut >= 2.4).

Thanx guys this would seem tobe the place to get my eaton powerware ups going with Linux only problem being im a noob and this doesnt seem to be working for me
probably due to my lack of experiance
my flavour of linux is :-
Ubuntu juanty jackalope 9.04 x64
UPS = Eaton Powerware 5110 (USB Connection to PC)

“sudo apt-get install nut” i have run this command all good :) no errors

Installing the nut package, should add the nut user and group. If it doesn’t, you have to add those manually = HOW DO I KNOW IF IT HAS OR NOT ??? WOT DO I LOOK FOR ??? HOW DO I ADD MANUALLY ???

you see im lost here as i do not know wot you are talking about = :(

Next, create or edit /etc/nut/ups.conf: = There is already a file “nut.conf” in this directory is this a typo or should i create nut.conf also???

“# /etc/nut/ups.conf

[apc]
driver = usbhid-ups
port = auto”

this realy doesnt mean a great deal to me am i suposed to add this to my ups.conf or wot you guys are really confusing me with no real description ?

i think ill leave it there i dont want to go tofar ahead whwn i dont know wot is going on

Any help is greatly appreciated thankyou

LOL i even tried the 1st option and installed the nut-hal-drivers (after removing the other nut drivers 1st to avoid conflicts) so as i could use my UPS with the Gnome Power Manager that didn’t work for me either

In ups.conf your config should say something like:

[powerware]
driver = bcmxcp_usb
port = auto
desc = “Powerware UPS”

That should get you closer with the Powerware 5110, as the config you currently have is not appropriate for the 5110. In nut.conf (already present in the nut directory) you need to add standalone as Dave suggests above.

Hope that helps a little. Not that I can get mine working ATM :-(

Great guide. I used it in the past to get nut working with a Powerware 5110 on Hardy. I’ve just upgraded my fileserver box to Jaunty, and naturally came back to your guide. Unfortunately I haven’t been able to get it working this time. Whenever I start upsdrvctrl it throws an error about not being able to find the Powerware UPS device on the USB bus. I’ve set standalone in nut.conf, and have the driver correctly set to bcmxcp_usb in ups.conf, but it doesn’t want to start. I’ll try powercycling the UPS as Dave suggested, when I get a chance. Maybe that is the key?
In any case, looking forward to your guide for Jaunty!

What’s the exact output of upsdrvctl start? I had a problem a while ago where hal was claiming the device before nut and preventing it from working right.

I’d also check that it shows up somewhere in dmesg (i.e. dmesg | grep -i powerware). If it isn’t there, re-plugging in the usb cable might get it to re-detect it.

Hi
& thanks a lot …you’re right if mode is not on “standalone” the command

sudo /etc/init.d/nut start will send a FAILED.

by the way in 2016 with jessie it’s :

“sudo /etc/init.d/nut start-client start”

Thanks for the suggestions. I rebooted the UPS last night, but still no luck with getting NUT to work. This is the output when upsdrvctl is started (sudo upsdrvctl start):

Network UPS Tools – UPS driver controller 2.4.1
Network UPS Tools – BCMXCP UPS driver 0.21 (2.4.1)
USB communication subdriver 0.17
Can’t set POWERWARE USB configuration
Unable to find POWERWARE UPS device on USB bus

Things to try:

– Connect UPS device to USB bus

– Run this driver as another user (upsdrvctl -u or ‘user=…’ in ups.conf).
See upsdrvctl(8) and ups.conf(5).

Fatal error: unusable configuration
Driver failed to start (exit status=1)

This is the only relevant line in dmesg

usb 2-4: usbfs: interface 0 claimed by usbfs while ‘bcmxcp_usb’ sets config #1

Hmm… had it running fine – then updated Ubuntu and Nut and now it doesn’t work.
ACL, ACCEPT, REJECT no longer accepted in upsd.conf use LISTEN instead.

/etc/nut$ sudo upsd
Network UPS Tools upsd 2.4.1
ACL in upsd.conf is no longer supported – switch to LISTEN
ACL in upsd.conf is no longer supported – switch to LISTEN
ACL in upsd.conf is no longer supported – switch to LISTEN
ACL in upsd.conf is no longer supported – switch to LISTEN
ACCEPT in upsd.conf is no longer supported – switch to LISTEN
ACCEPT in upsd.conf is no longer supported – switch to LISTEN
ACCEPT in upsd.conf is no longer supported – switch to LISTEN
REJECT in upsd.conf is no longer supported – switch to LISTEN
listening on 127.0.0.1 port 3493
listening on ::1 port 3493
Can’t connect to UPS [UPS] (apcsmart-UPS): No such file or directory
allowfrom in upsd.users is no longer used

Any idea on how to change the configuration to make it work again using LISTEN?
All I can find on Google are Bug reports stating that this change was made and not documented anywhere.

man upsd.conf gives this information:

LISTEN interface port

Bind a listening port to the interface specified by its Internet
address. This may be useful on hosts with multiple interfaces.
You should not rely exclusively on this for security, as it can
be subverted on many systems.

Listen on TCP port port instead of the default value which was
compiled into the code. This overrides any value you may have
set with ’configure –with-port’. If you don’t change it with
configure or this value, upsd will listen on port 3493 for this
interface.

Multiple LISTEN addresses may be specified. The default is to
bind to 127.0.0.1 if no LISTEN addresses are specified (and ::1
if IPv6 support is compiled in).

LISTEN 127.0.0.1
LISTEN 192.168.50.1
LISTEN ::1
LISTEN 2001:0db8:1234:08d3:1319:8a2e:0370:7344

Got it working again:

Replace
# /etc/nut/upsd.conf
ACL all 0.0.0.0/0
ACL localhost 127.0.0.1/32
ACCEPT localhost
REJECT all

with
# /etc/nut/upsd.conf
LISTEN 127.0.0.1
LISTEN 10.10.10.1 (use the IP address of any remote slave devices)

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

Comment out allowfrom

That should do the trick

Thanks! This is the first comprehensible info I’ve found to get nut 2.x working.

Everything else I’ve found (including readme’s etc.) is commentary, editorial, history lesson, etc.; not instructional.

I have a mustek powermust 600 and I am trying to connect it by USB. i get this:
~$ sudo upsdrvctl start
Network UPS Tools – UPS driver controller 2.4.1
Network UPS Tools – Megatec protocol driver 1.6 (2.4.1)
Serial-over-USB transport layer 0.10
Can’t claim USB device [06da:0003]: could not detach kernel driver from interface 0: Operation not permitted
Driver failed to start (exit status=1)

any ideas? I found nothing :|

10x in advance!

I have exacly the same UPS but I have an error saying:

Network UPS Tools – UPS driver controller 2.2.2
Network UPS Tools 2.2.2 – Megatec protocol driver 1.5.14 [megatec]
Carlos Rodrigues (c) 2003-2008

Unable to open auto: No such file or directory

Things to try:

– Check ‘port=’ in ups.conf

– Check owner/permissions of all parts of path

Fatal error: unusable configuration
Driver failed to start (exit status=1)

My ups.conf is exactly the same as the example, I’m using debian 5.0.

You need to reboot so that group permissions get in effect. nut has been installed and added to serial group but it only comes into effect if you reboot the machine or login again…

I was not getting past this even with the helpful hints of others. So, I tried

sudo upsdrvctl -u root start

which moved me forward a bit. I don’t know that this puts me in happy land, but I wanted to post this clue before I forgot.

You have to grant access to nut user to usb device..

First, find your usb device with “lsusb” and then

$ chmod 0666 /dev/bus/usb//

Then, it will work with:
“sudo upsdrvctl start”

Excellent tutorial!
This made an old, –no, ancient– APC UPS-PRO 650 (serial connection) work “smart”(er) under Karmic.

However, while setting things up to work with my serial port (ttyS0), I noticed that the above commands:

$ sudo udevadm control –reload_rules
$ sudo udevadm control trigger

did NOT work when I ran this. Instead, I used:

$ sudo udevadm control –reload
$ sudo udevadm trigger

and things ran fine.

Thanks again!

I am trying to configure NUT to communicate with a Mecer ME600BK UPS connected via a serial cable to a standalone machine on what I assume is ttyS1. To be sure I have also tried on ttyS0 (locked by another process) and ttyS2 with a similar output as given below.

After changing the configuration, when I enter the command:

sudo upsdrvctl start

I get this:

Network UPS Tools – UPS driver controller 2.4.1
Network UPS Tools – Megatec protocol driver 1.6 (2.4.1)
tcgetattr(/dev/ttyS1): Input/output error
Driver failed to start (exit status=1)

When I set the configuration to use ttyS0 I am told this port is locked by another application.

When I enter the command

sudo upsdrvctl stop

I get this response:

Network UPS Tools – UPS driver controller 2.4.1
Can’t open /var/run/nut/megatec-ttyS1.pid: No such file or directory

Any suggestions?

Thank you for the comment, lsof /dev/ttyS0 does not give any feedback. I came back here to have another shot at it working through from the beginning again. In the how-to above the following text appears as configuration of:

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

Remove the second = between KERNEL and “ttyS0” helped.

There are no unexpected errors until I get to:

user@machine:~$ sudo chown chmod 640 /etc/nut/*
chown: invalid user: `chmod’

Despite this, sudo /etc/init.d/nut start starts up properly and the log file confirms a goos start. But then at the final:

user@machine:~$ upsc mecer
Error: Connection failure: Connection refused.

Now I’m stumped again?

Thanks for the help.

Removing the second “=” changes the meaning (i.e. that’s not a typo). It’s possible that you’re using a different version of udev that doesn’t understand that command. To test that you can modify the permissions directly and see if it works:


$ sudo chmod 660 /dev/ttyS0
$ sudo chown root:nut /dev/ttyS0
$ sudo /etc/init.d/nut restart

As for the second error, where are you getting that command? It’s not in the post. You should be doing:


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

Thank you for the assistance, I have come back to this again and made some progress, but it is still not working properly.

I have put the double “==” back and done the restart.

“lsof” (given as sudo) shows the port “ttyS0” is connected to the ups and controlled by the megatec driver. So far so good. Everything then very much progresses as expected with no error messages and the predicted response.

BUT when I do:

user@machine:~$ sudo upsc mecer

I get this feedback:

Error: Connection failure: Connection refused

I just don’t understand this, do you have any further ideas?

I’m getting the same error when trying to run the upsc command, everything else seems to work find. I’m fairly new to both linux and ubuntu. been googling the hell out of all this trying to figure it out.

user@machine:~$ sudo upsdrvctl start
Network UPS Tools – UPS driver controller 2.4.1
Network UPS Tools – Generic HID driver 0.34 (2.4.1)
USB communication driver 0.31
Using subdriver: APC HID 0.93

user@machine:~$ sudo /etc/init.d/nut start
* Starting Network UPS Tools [ OK ]

user@machine:~$ sudo upsc apc
Error: Connection failure: Connection refused

the information seems to be getting through as I can unplug the ups and the computer detects it and pops up a little message saying ups is discharging, but never shuts the computer down, will totally discharge unit and Loss of Power turn it off.

Seems like its conflicting with the built in power management gnome as the ups info gets displayed through there.

any ideas?

I had originally installed the nut-hal-drivers when starting your guide but then removed the package and started just the nut package.

sorry to resurrect this and not sure if anyone is still monitoring.

yes the /etc/nut/nut.conf mode=standalone was my missing link.

after adding that in I did a fresh boot and loaded up the upsc command it is showed the ups unit information, then pulled the plug and the unit displayed it was unplugged in the upsc screen then shut down the system. Thank you for you help, been over this guide so many times but I had clearly overlooked some of the important comments.

Thanks again, everything appears to be working correctly now.

Glad you got it working. Unfortunately, nut 2.2 -> 2.4 was a big change to how configuration worked and I just haven’t had a the time to update the guide.

BTW running ubuntu 9.10

Ok I changed the info to LISTEN as noted above, then also tried just clearing out the file completely and leaving blank.

This is with # /etc/nut/upsd.conf Blank after fresh boot.

On fresh boot.
$ sudo upsc apc
Error: Connection failure: Connection refused

$ sudo upsd
Network UPS Tools upsd 2.4.1
listening on 127.0.0.1 port 3493
listening on ::1 port 3493
Can’t connect to UPS [apc] (usbhid-ups-apc): No such file or directory

$ sudo upsdrvctl start
Network UPS Tools – UPS driver controller 2.4.1
Network UPS Tools – Generic HID driver 0.34 (2.4.1)
USB communication driver 0.31
Using subdriver: APC HID 0.93

$ sudo upsd
Network UPS Tools upsd 2.4.1
not listening on 127.0.0.1 port 3493

$ upsc apc
***Yield UPS info****

Does not shut down computer when unplugged.

————————————————————————

This is with # /etc/nut/upsd.conf as follows after fresh boot.
# /etc/nut/upsd.conf
LISTEN 127.0.0.1

Leaving it blank seems to yeild same results

$ sudo upsc apc
Error: Connection failure: Connection refused

$ sudo upsd
Network UPS Tools upsd 2.4.1
listening on 127.0.0.1 port 3493
Can’t connect to UPS [apc] (usbhid-ups-apc): No such file or directory

$ sudo upsdrvctl start
Network UPS Tools – UPS driver controller 2.4.1
Network UPS Tools – Generic HID driver 0.34 (2.4.1)
USB communication driver 0.31
Using subdriver: APC HID 0.93

$ sudo upsd
Network UPS Tools upsd 2.4.1
not listening on 127.0.0.1 port 3493

$ upsc apc

***Yields UPS Info****

Does not shut down computer when unplugged and drained….

—-

So clearly not starting on boot, and I’ve missed something to configure how it shuts down the system?

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

still correct?

Thanks!!!
I got an Liebert PowerSure Personal XT connected to Ubuntu 9.10.
I follow your steps and after read the comments, everything is going fine.

Thanks.

Hallo,
im using Ubuntu 9.10 server 64 bit. And have problems to start nut. all the setting are done, how they are listed above, with an other dist i think it was 8.04 it runs perfectly, but i don’t know wath nut version ist was. today under 9.10 i use 2.4.1.

the problem is that upsd doesn’t start at booting, i think becourse of missing promissions. lateron starting by “sudo upsd” it work fine. but this is no acceptable solution.

Does anybody have an idea?

Hallo,
i think there are no errors. but wenn i uses
“sudo /etc/init.d/nut status” there ist noch pid for upsd
upsc is running.
i have to start upsd manually by
“sudo upsd”
than it runs fine.
but the start on boot is not possible, only by starting with sudo.

peter

Hi, I’m trying to get my Powerware 5115 to work, but i’ve tried all settings above and nothing works, here are my config files:

—nut.conf

MODE=standalone

—ups.conf

[pwups]
driver = bcmxcp_usb
port = auto
# cable = 1234
desc = “Powerware 5115 UPS”

—upsd.conf

LISTEN 127.0.0.1

—upsd.users

[root]
password = testpass
#allowfrom = localhost
instcmds = ALL
actions = SET

[upsmon]
password = testpass
upsmon master

when i run sudo upsdrvctl start i get:

waver@elefanten:/etc/nut$ sudo upsdrvctl start
Network UPS Tools – UPS driver controller 2.4.1
Network UPS Tools – BCMXCP UPS driver 0.21 (2.4.1)
USB communication subdriver 0.17
Can’t set POWERWARE USB configuration
Unable to find POWERWARE UPS device on USB bus

Things to try:

– Connect UPS device to USB bus

– Run this driver as another user (upsdrvctl -u or ‘user=…’ in ups.conf).
See upsdrvctl(8) and ups.conf(5).

Fatal error: unusable configuration
Driver failed to start (exit status=1)

lsusb gives:
Bus 006 Device 003: ID 06da:0002 Phoenixtec Power Co., Ltd UPS

and dmesg gave this when i plugged it out and in again:

[ 2186.181299] usb 6-1: usbfs: interface 0 claimed by usbfs while ‘bcmxcp_usb’ sets config #1
[ 2715.790032] usb 6-1: USB disconnect, address 2
[ 2723.660027] usb 6-1: new low speed USB device using uhci_hcd and address 3
[ 2723.839089] usb 6-1: configuration #1 chosen from 1 choice

Does anyone have a clue to solve my problem? =)

Ok guys I get this errors:

Network UPS Tools – UPS driver controller 2.4.1
Network UPS Tools – Generic HID driver 0.34 (2.4.1)
USB communication driver 0.31
No matching HID UPS found

my ups.conf is:

[ap1000]
driver = usbhid-ups
port = auto

I’ve also tried to set a specific usb port and change driver.

My ups is a AMACROX 1000
http://www.amacrox.com//english/01_product/02_01detail.aspx?pdid=46

and it should be the following usb device
lsusb -D /dev/bus/usb/008/003
Device: ID 0665:5161
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x0665
idProduct 0x5161
bcdDevice 0.02
iManufacturer 1 Cypress Semiconductor
iProduct 2 USB to Serial
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 34
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 3
bmAttributes 0x80
(Bus Powered)
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0 No Subclass
bInterfaceProtocol 0 None
iInterface 4 Sample HID
** UNRECOGNIZED: 09 21 00 01 00 01 22 1b 00
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 32
Device Status: 0x0000
(Bus Powered)

any help is welcome
thanks

Great article.

May be worth a mention to the web page for monitoring you get with it, using nutd and upsmon.
At least with Ubuntu 9.10 (and apache, of course).

Thanks

Hi guys. I have a very strange situation here. I’ve just installed and configured upsmon in fedora 12. The pc is connected on a Mustek Powermust 2000VA USB with serial port (ttyS0) and the upsd can communicate with the ups without a problem. Everything works great except one thing, when I shut down the pc the ups is also turns it’s load off, it’s like running the load.off command, therefore all the devices on the ups are turned off (adsl router, switch etc). The only way to restore the power is to turn of the power on the ups from the front button, remove power cord, wait 2-3 secs, restore power on ups and turn on from the front button.

Does anybodby knows why this happens. It seems like the os sends a load.off command during shutdown.

Also if I kill the upsd daemon before send a shutdown then the same thing happens. Only if I disconnect the RS-232 cable before shut down the ups stays on.

Does anybody have a clue?

Regards.

Nice guide. I had no problems getting my Cyberpower AVR1000 running with this guide on Ubuntu 10.04 64-bit, although I did have to set MODE=standalone in /etc/nut/nut.conf.

I on a workstation have:

# Battery powered notebooks need not be shutdown ;)
#SHUTDOWNCMD “/etc/init.d/ups-monitor poweroff”

# Regular machines either may hibernate or shutdown
SHUTDOWNCMD “/etc/init.d/ups-monitor poweroff; /usr/sbin/hibernate”
#SHUTDOWNCMD “/usr/bin/chvt 1; /sbin/shutdown -h +0”

in /etc/nut/upsmon.conf

Hibernation works like a charm, but on resume I found upsd is running whereas upsmon stopped :(

I added:

resume)
log_daemon_msg “Resuming $DESC”
start_stop_client start && log_progress_msg “upsmon”
log_end_msg 0
;;

to /etc/init.d/nut and

OnResume 20 /etc/init.d/nut resume

to /etc/hibernate/common.conf

And that’s what I wanted it to do :)

A configuration for two computers, one UPS and NUT

It took me a while to get this up and running.

I have to servers and one UPS. The server host names are named after our two cats, but changed here to felix and garfield. Both servers receive power from the UPS. The UPS is connected to a regular power outlet.

The UPS is a Eaton Powerware 5110 1000Va.

The felix system is connected to the UPS by USB. So felix will be the master and garfield is slave. They have local addresses 192.168.0.1 and 192.168.0.2.

Relevant lines in configuration files for felix (master) in /etc/nut

nut.conf
MODE=netserver

ups.conf
# this is a Powerware 5110 so the appropriate driver is bcmxcp_usb. See http://www.networkupstools.org/compat/stable.html
[Power5110]
driver = bcmxcp_usb
port = auto

upsd.conf
# this took a while, but thanks to Andy I got it working
# Comment out the Access Control List (ACL) lines
LISTEN 127.0.0.1
LISTEN 192.168.0.1

upsd.users
# Again, thanks to Andy, comment out the ‘allowfrom =’ lines
# no need to comment on the passwords, right?
[nut_master]
password = PWM
upsmon master
[nut_slave]
password = PWS
upsmon slave

upsmon.conf
# This line basically says: I want to monitor my UPS Power5110 that is connected directly as master to my system localhost. I have only 1 UPS, my username is nut_master and my password is PWM.
MONITOR Power5110@localhost 1 nut_master PWM master

/etc/default/nut
START_UPSD=yes

START_UPSMON=yes

Relevant lines in configuration files for garfield (slave) in /etc/nut

nut.conf
MODE=netclient

ups.conf
# No lines edited here. This is a slave system. It will only monitor my UPS on felix

upsd.conf
# No lines edited here. The NUT daemon runs on master felix.
upsd.users
# No lines edited here. The users are defined on the master system felix.

upsmon.conf
# monitor my ups Power5110 on system felix. Fortunately I have only 1 UPS. I am a slave, my username and password are nut_slave and PWS
MONITOR Power5110@felix 1 nut_slave PWS slave

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

Remarks
Hopefully this will be useful to someone. Stated like this, it’s not a difficult configuration. I took me a few hours though. Please feel free to remark. But I must warn you: I’m just a user. Most things I do not understand really.

UserFrodo @ Rotterdam. Sunday, November 7. It’s 7 decrees Celcius. Few clouds and showers.

Hi all,

First of all, it is a great tutorial and read a lot of comment.

But I have also a problem with nut.

I’m connecting to the ups with snmp (netvision-mibs)

but i don’t get it working always got the same errors:

# upsdrvctl start ( i get this)
Network UPS Tools – UPS driver controller 2.4.3
Network UPS Tools – Generic SNMP UPS driver 0.47 (2.4.3)
Detected MASTERYS 3/1 SYSTEM 10 kVA on host 192.168.0.20 (mib: netvision 0.1)

and syslog gives me the output:
snmp-ups[23163]: Startup successful

if i do # upsd

Network UPS Tools upsd 2.4.3
not listening on 192.168.100.10 port 3493

and syslog gives me the output:

upsmon[12374]: UPS ups1@192.168.100.10 is unavailable
upsd[23515]: not listening on 192.168.100.10 port 3493

if i do # upsdc ups1

i get some information but “ups.status: ” is empty

# /etc/init.d/nut start
* Starting Network UPS Tools [ OK ]

I searched on some forums also and sombody said that there is maybe a fault in the netvision c file

http://lists.alioth.debian.org/pipermail/nut-upsuser/2010-June/006067.html

Idno if this “bug” is already fixed but still nut isn’t working,

Any advice or some comment about some wrong config code.

Greetings

———————–
Here are my config files.

# nano nut.conf
MODE=standalone

# nano ups.conf
[ups1]
driver = snmp-ups
port = 192.168.0.20 (ip ups)
mibs = netvision
snmp_version = v1
pollfreq = 30
desc = “MASTERYS 3/1 SYSTEM 10 kVA”

# nano upsd.conf
LISTEN 127.0.0.1
LISTEN 192.168.100.10 3493

# nano upsd.users
[upsclient]
password = upsclient
upsmon slave

# nano upsmon.conf
MONITOR ups1@192.168.100.10 1 upsclient upsclient slave

When I do sudo upsdrvctl start
I got:
Network UPS Tools – UPS driver controller 2.4.3
Network UPS Tools – Megatec/Q1 protocol USB driver 0.03 (2.4.3)
Can’t chdir to /var/run/nut: No such file or directory
Driver failed to start (exit status=1)

My ups is an Atlantis Power OnePower 652 (usb) on Kubuntu 10.10.
I tried all the drivers.
Can anybody help me ??

Thank you so much. I was having the same problem with ubuntu 2.6.35-27. You saved me and I learned something about linux.

What is wrong when I get error (Debian Squeeze) (logged as root):

# udevadm control –reload
unrecognized command
#

Next one goes w/o error

# udevadm trigger
#

Seems that rebooting was enough and finally succeeded thanks to comments (guided by errors in /var/log/daemon.log).

Now upsc-command gives what I was looking forward to :-)

Guys,
Looks like everything is working on my system until I get message in the end that UPS in uneveilable.
Please advise where and what is the problem?

# upsc tripplite
battery.charge: 100
battery.runtime: 1215
battery.type: PbAC
battery.voltage: 13.5
battery.voltage.nominal: 12.0
device.mfr: Tripp Lite
device.model: Tripp Lite UPS
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.version: 2.6.0
driver.version.data: TrippLite HID 0.6
driver.version.internal: 0.35
input.frequency: 59.8
input.voltage: 121.4
input.voltage.nominal: 120
output.frequency.nominal: 60
output.voltage.nominal: 120
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.mfr: Tripp Lite
ups.model: Tripp Lite UPS
ups.power.nominal: 1000
ups.productid: 2010
ups.status: OL
ups.timer.reboot: 65535
ups.timer.shutdown: 65535
ups.vendorid: 09ae
ups.watchdog.status: 0

Broadcast Message from nut@linux
(somewhere) at 17:50 …

UPS tripplite@linux is unavailable

I had a similar problem a while ago and it was just a flaky driver. Different ups, no problem. That said, if that message is coming from upsmon check that it can communicate with uspd.

Hi
When I type “sudo upsdrvctl start” it gives me the following error.

Network UPS Tools – UPS driver controller 2.4.3
Network UPS Tools – Generic HID driver 0.34 (2.4.3)
USB communication driver 0.31
Can’t chdir to /var/run/nut: No such file or directory
Driver failed to start (exit status=1)

Can I get any help to solve this problem

hi when i type “sudo upsdrvctl start” I get this .”HIDGetDataValue: Value too large for ‘defined data type”
Any help
?

After installing and trying to run NUT with secure users, you may get “permission denied” or “driver not connected” errors, like the following: Even starting everything as root, I was seeing these symtpoms in syslog:

Apr 2 21:14:19 myserver upsd[5353]: Can’t connect to UPS [smart-ups] (apcsmart-smart-ups): Permission denied

Apr 2 21:30:16 myserver upsmon[5411]: Poll UPS [smart-ups@localhost:3493] failed – Driver not connected

After scouring the NUT documentation multiple times and a day’s worth of web searches, I finally stumbled on the fix. The UPS driver and upsd must be running as the same user in order to communicate. If these two aren’t talking, your client programs won’t talk either. There was one line buried in the documentation that supported this idea:
upsd chroots before opening any config files, so there is no way to add support for that in upsd.conf at the present time.

In the ups.conf file, you can specify the user that starts the driver daemon that talks to the UPSes with a line:
user =
is the user who will control communication to the UPS, launched by the upsdrvctl program). I created one named nutsrv to run all services.

There is no configuration line that will do the same thing for upsd, because it will change the user it is running as prior to reading the configuration files. It does support a command-line option to do that. Add the following line to nut.conf or /etc/default/nut to specify the user:
UPSD_OPTIONS=”-u ”

With the user specified in both places, NUT will start the drivers and upsd as the same user and will be able to communicate.

If you are implementing the CGI interface to supply a web interface to your monitoring, the hosts.conf, upsstats.html, and upsstats-single.html should be world-readable (or made readable by ownership or permissions to both the nut group and the group under which your web server is running). The other configuration files can be restricted to the nut group only.

Some parameter got chopped out of my reply. The ups.conf line should be “user = run_as_user”. The upsd options line should be “UPSD_OPTIONS=”-u run_as_user”.

to solve right issue between NUT and USB apc :
ln -s /lib/udev/rules.d/52-nut-usbups.rules /etc/udev/rules.d/

nut’s driving me nuts!

I’m surprised no one who has posted a response this year (2013) has mentioned that this guide doesn’t work with version 2.6!!!!!! btmorex admits that himself.

I have nut version 2.6.4-2.3 (running on Debian Wheezy). There’s no /etc/default/nut or /etc/init.d/nut file. Instead, I have /etc/init.d/nut-server and /etc/init.d/nut-client.

No more ACLs either. Instead, upsd.conf contains LISTEN statements.

So what are you people doing? Trying to configure some old version of nut on an old version or Debian?

Arnaud Quette can consider himself lucky that Debian allows packages to be hosted without any proper (and more importantly up to date) instructions on how to use them!

Could someone please post a link to a guide which is up to date?

Else I’ll have to go buy an APC UPS just so that I can use apcupsd.

I don’t have time right now to really update the guide. I’m leaving this up here because:

1.) The comments contain useful information on getting it working.
2.) Tons of people still run servers on older Linux version and this guide is still relevant (mostly).

Still usable with Kubuntu 14.04 LTS as TrippLite drivers from the manufacturer are limited to Fedora and Opensuse package.

Was very usefull, hope you read my comment and thank you.

Hi I wondered if you can please help. My server runs Ubuntu 14.04.3 and I’ve installed nut as your guide and can see the monitoring is working and I’m getting the readouts etc. But when I test unplugging the power the ups drains down until the server turns off but is not shutdown.

Is there please a way to get ubuntu to gracefully shutdown when the battery level is low rather than just dying. Seems like I may as well not have a UPS at all?

Thanks for any help!

I was experiencing issues with my APC UPS after having it not plugged into my linux server for about a year. I plugged everything and fired it back up, only to experience nagging messages through the console about lost communications with the UPS. I came across your guide and the rules.d update about changing it to ttyS1 was the fix in my case. My guess was that the UPS was plugged into a different root hub than last time.

Anyway, thank you for the guide, it helped me out !

Hi Guys,

I found that some problems are related to this issue: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=810449

It could be fixed with that PPA: https://launchpad.net/~clepple/+archive/ubuntu/nut

The unstable UPS state could arise from the Virtual VMware USB Hub, from the host USB 2.0 (or 3.0) port or even from additional hardware USB hub (used to connect few UPS devices to the same monitoring station).

Again, if you have root access to the system, you can use the syslog messages to trigger automated recovery activities as a dirty bandage :)

For example, with SysV inittab reborn monitoring process – let’s name that executalbe (755) file nut-usb-shake in the /etc/nut folder.

Two lines in the /etc/inittab file:

# Monitor and revive the NUT managed UPS devices
nut-usb-shake:12345:respawn:/etc/nut/nut-usb-shake

The /etc/nut/nut-usb-shake file:

#! /bin/sh

tail -Fn0 /var/log/syslog | \
while read line ; do
echo “$line” | grep -q “upsmon\[.*Poll UPS.*failed – Driver not connected”
if [ $? = 0 ]
then
service nut-client stop
service nut-server stop
sleep 10
service nut-server start
service nut-client start
fi
done

Finally reload the inittab context with “init q” and every-time when the monitored message is intercepted in the syslog, the remediation commands will be executed.

You can adjust to monitor and execute whatever will serve your needs – the above is just an example.

Good luck!

Can anyone point me towards a more recent article useable with Ubuntu 18.04 LTS (“Bionic Beaver”)??

Thanks in advance, and thanks for the above nonetheless.

Comments are closed.