Some issues with nut 2.8.0 and other modules

Edit: the first part is about the inclusion of nut 2.8.0 in the next major release. For the issues I've found and workarounds, you can begin reading at post #4.

----- Original post -----
Currently, the OpenWrt repositories include nut (Network UPS tools) 2.7.4-27. The upstream 2.7.4 dates from march 2016 (around the same time of the last apcupsd, BTW). However, the current nut release is 2.8.0 from april 2022, and it includes several improvements. Therefore I wonder: are there plans to integrate this into OpenWrt upcoming releases?

2.8.0 seems to be updated already back last year when it came out: https://github.com/openwrt/packages/commits/master/net/nut
https://github.com/openwrt/packages/commit/f5c0f8297d8fadda2f4da81f09422985e997c67f

I assume you're not on the "master" branch where all the latest/greatest comes down?

2 Likes

I'm downloading from the official target releases, currently 22.03.5. And that's what I have:

root@Router:~# cat /etc/openwrt_release
DISTRIB_ID='OpenWrt'
DISTRIB_RELEASE='22.03.5'
DISTRIB_REVISION='r20134-5f15225c1e'
DISTRIB_TARGET='ath79/generic'
DISTRIB_ARCH='mips_24kc'
DISTRIB_DESCRIPTION='OpenWrt 22.03.5 r20134-5f15225c1e'
DISTRIB_TAINTS=''
root@Router:~# opkg list-installed |grep nut
collectd-mod-nut - 5.12.0-33
nut - 2.7.4-27
nut-common - 2.7.4-27
nut-driver-usbhid-ups - 2.7.4-27
nut-server - 2.7.4-27
nut-upsc - 2.7.4-27

So what shall I do in order to take advantage of the new nut version? test the daily snapshot?
and forgive me for asking, but why is not already on the "stable releases", if the integration on github was done last september? testers or it's scheduled anyways?

I am not a developer but it has been stated that the stable releases are just a copy of the master branch that is branched off at a point in time and the added updates for stable are mostly just security patches and bug fixes based only on the branched code for that stable branch.

There are some updates to some packages and a few new devices that may be added on point releases.

There may also be a difference in updates for the core package compared to community packages like nut.

22.03 stable was branched off of Master before the new version of nut was added to Master.

The next stable branch would include whatever is in Master at that time, likely including the new nut version.

I think that IF the new nut version worked with the API interfaces of all the other parts of the 22.03.x system it interacts with it might be possible to back-port it to 22.03.x stable but someone would have to compile it, get it tested on a large range of targets and do the work to do a proper PR to get it included.

See these for entry point of documentation to explore for a better understanding: https://openwrt.org/about/history#timeline ,
https://openwrt.org/about/history#branch_logic
Info on the change process: https://openwrt.org/submitting-patches

I'll leave it to someone more experienced to answer:

Remember that OpenWrt is produced by a bunch of volunteers.

Totally understood, and thanks to everyone that make this possible (just in case, I didn't mean to be rude). I'm trying to do my part here as well, such as:

I went ahead and installed last snapshot. Indeed nut 2.8.0 is available there.

However, I think something is wrong, maybe the collecd-mod-nut plugin, as after being configured and enabled, the nut rrd's are not being generated, and the corresponding UPS tab is missing on the LuCI statistics graphs.

root@Router:~# ls /tmp/rrd/Router
cpu-0             interface-br-lan  iwinfo-wlan0      iwinfo-wlan1      load              memory

I first tried with the intended UPS directly connected, then tried with a hub and two different UPS's. upsc works for one or both, but something is wrong with the statistics on the snapshot (was working for the older UPS under 22.03.5).

collecd-mod-nut 5.12.0-42 works fine for me under snapshot r22658-2c530fcb97 of about 10 days ago, nut 2.8.0-3.

I can't install the latest snapshot to test it with it as there are issues with some packages that I need, else I would.

Interesting. Lately I've been messing with nut and several UPS's with several routers and stable releases, and I think I'm following the same procedure as before.

Please help me check:

root@Router:~# opkg list-installed |grep collectd
collectd - 5.12.0-42
collectd-mod-cpu - 5.12.0-42
collectd-mod-interface - 5.12.0-42
collectd-mod-iwinfo - 5.12.0-42
collectd-mod-load - 5.12.0-42
collectd-mod-memory - 5.12.0-42
collectd-mod-network - 5.12.0-42
collectd-mod-nut - 5.12.0-42
collectd-mod-rrdtool - 5.12.0-42
root@Router:/# opkg list-installed |grep usb
kmod-phy-ath79-usb - 5.15.110-1
kmod-usb-core - 5.15.110-1
kmod-usb-ehci - 5.15.110-1
kmod-usb-hid - 5.15.110-1
kmod-usb-ledtrig-usbport - 5.15.110-1
kmod-usb-ohci - 5.15.110-1
kmod-usb-printer - 5.15.110-1
kmod-usb2 - 5.15.110-1
libusb-1.0-0 - 1.0.26-3
libusb-compat4 - 0.1.7-2
nut-driver-usbhid-ups - 2.8.0-3
usbutils - 014-1

root@Router:/# opkg list-installed |grep nut
collectd-mod-nut - 5.12.0-42
nut - 2.8.0-3
nut-common - 2.8.0-3
nut-driver-usbhid-ups - 2.8.0-3
nut-server - 2.8.0-3
nut-upsc - 2.8.0-3
nut-web-cgi - 2.8.0-3

And here's my nut_server config file (when testing with both UPS's):

root@Router:~# cat /etc/config/nut_server
config driver_global 'driver_global'
        option user nut

config driver 'tripplite'
        option driver usbhid-ups
        option port auto
        option vendorid 09ae

config driver 'APC'
        option driver usbhid-ups
        option port auto
        option vendorid 051d

config user
        option username upsuser
        option password upspassword
        option upsmon master

config user
        option username nut
        option password upspassword
        option actions set
        list instcmd all
        option upsmon master

config listen_address
        option address 0.0.0.0
        option port 3493

config upsd 'upsd'
        option maxage 15
        option statepath /var/run/nut
        option maxconn 1024
        option runas nut

Drivers running:

root@Router:~# lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ohci-platform/2p, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/2p, 480M
    |__ Port 1: Dev 4, If 0, Class=, Driver=hub/4p, 480M
        |__ Port 3: Dev 6, If 0, Class=, Driver=usbfs, 12M
        |__ Port 4: Dev 5, If 0, Class=, Driver=usbfs, 1.5M
root@Router:~# ps |grep ups
 1866 nut       1284 S    /usr/sbin/upsd -D -u nut
 3364 nut       1780 S    /lib/nut/usbhid-ups -D -a APC -u nut
 6334 nut       1780 S    /lib/nut/usbhid-ups -D -a tripplite -u nut
root@Router:~# upsc tripplite |grep vendorid
driver.parameter.vendorid: 09ae
ups.vendorid: 09ae
root@Router:~# upsc APC |grep vendorid
driver.parameter.vendorid: 051d
ups.vendorid: 051d

All of my packages are of the same version as yours, apart from the kmod ones as I'm still on kernel 5.15.108-1.

root@r1:~# opkg list-installed |grep collectd
collectd - 5.12.0-42
collectd-mod-cpu - 5.12.0-42
collectd-mod-interface - 5.12.0-42
collectd-mod-iwinfo - 5.12.0-42
collectd-mod-load - 5.12.0-42
collectd-mod-memory - 5.12.0-42
collectd-mod-network - 5.12.0-42
collectd-mod-nut - 5.12.0-42
collectd-mod-rrdtool - 5.12.0-42

root@r1:~# opkg list-installed |grep usb
kmod-usb-core - 5.15.108-1
kmod-usb-printer - 5.15.108-1
kmod-usb-storage - 5.15.108-1
kmod-usb-storage-uas - 5.15.108-1
kmod-usb-xhci-hcd - 5.15.108-1
kmod-usb-xhci-mtk - 5.15.108-1
kmod-usb3 - 5.15.108-1
libusb-1.0-0 - 1.0.26-3
libusb-compat4 - 0.1.7-2
nut-driver-usbhid-ups - 2.8.0-3
usbutils - 014-1

I have more nut packages installed than you. It seems you're missing nut-upsmon which is an important part of nut. I'd also install luci-app-nut as it makes it easier to look at the whole config, as well as to change it.

root@r1:~# opkg list-installed |grep nut
collectd-mod-nut - 5.12.0-42
libgnutls - 3.7.8-2
luci-app-nut - git-22.288.44337-bfc0fcf
nut - 2.8.0-3
nut-common - 2.8.0-3
nut-driver-usbhid-ups - 2.8.0-3
nut-server - 2.8.0-3
nut-upsc - 2.8.0-3
nut-upscmd - 2.8.0-3
nut-upslog - 2.8.0-3
nut-upsmon - 2.8.0-3
nut-upsmon-sendmail-notify - 2.8.0-3
nut-upsrw - 2.8.0-3
nut-upssched - 2.8.0-3

I'm using the exact same configuration I used on a different router running 22.03 and it works on both, so if this was working for you on 22.03 it should do now. If you've since made changes you're better off comparing your current config with one of your backups from 22.03 rather than with mine, which could make things more confusing.

Here are the remaining parts. My /etc/config/nut_server options are all in single quotation marks:

root@r1:~# cat /etc/config/nut_server

config user
	option username 'master'
	option password 'pass'
	option upsmon 'master'
	list instcmd 'all'

config user
	option username 'slave'
	option password 'pass'
	option upsmon 'slave'

config listen_address

config listen_address
	option address '10.1.1.1'

config driver 'myups'
root@r1:~# lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci-mtk/1p, 5000M
    |__ Port 1: Dev 2, If 0, Class=, Driver=hub/4p, 5000M
        |__ Port 4: Dev 3, If 0, Class=, Driver=usb-storage, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci-mtk/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=, Driver=hub/4p, 480M
        |__ Port 1: Dev 4, If 0, Class=, Driver=usbfs, 1.5M


root@r1:~# ps |grep ups
  855 nut       1788 S    /lib/nut/usbhid-ups -D -a myups -u nut
 3586 nut       1280 S    /usr/sbin/upsd -D -u nut
 4632 root      1220 S    /usr/sbin/upsmon -D
 4668 nutmon    1220 S    /usr/sbin/upsmon -D
19154 root      1372 S    grep ups


root@r1:~# upsc myups |grep vendorid
ups.vendorid: 051d

True. In fact, I have one router+UPS running 22.03.3 and other router+UPS's running today's snapshot. I've been comparing configurations files and GUIs, and I don't notice any meaningful difference in that regard. The main differences I've noticed are the file size in other directories such as /usr/lib/collectd, usr/lib/nut, etc., but that could make sense.

Yes, I prefer to get the functions working one by one, and I'm looking at the config files because for me the nut GUI configurations perhaps are easy to compare, but not so logical at a glance.

On the other hand, I had to use opkg from SSH, because from the browser I get JSON errors for some packages.

Anyways, because my main issue with 2.7.4 is the lack of support for the Tripp·Lite, my next step it will be to backport the usbhid-ups driver to 22.03.5 to see what it happens.

As a workaround, I "downgraded" to 22.03.5 and integrated the usbhid-usb driver of 2.8.0 with nut 2.7.4. Now it seems to work properly for this new Tripp·Lite USB protocol (except for having to run upsd as root). And the collectd-mod-nut - 5.12.0-33 plugin works correctly with RRDtool:

So I don't know why I couldn't do the same with today's snapshot, but @grifo's is working with an older snapshot (and probably another SOC and UPS, which shouldn't be the reason of these issues).

Maybe it's an issue with that snapshot, try again in a few days.

Edit: as soon as the problems with gnutls are resolved I'll install the latest snapshot and report back.

Yes, I would like to confirm whether the 2.8.0 statistics are working or not before the next major release, therefore I will try again later on.

In the meantime I'm finishing integrating my hybrid nut workaround.

Another issue I've found for my current testbed, is after several .conf modifications, and several service nut-server restart and upsdrvctl stop/start, lsusb stops working until a reset.

Tried again with today's snapshot (r22878-c3e883b308), same result: nut-upsc working; nut statistics not being collected.

I'm still on snapshot r22658-2c530fcb97, hopefully I should be able to install tomorrow's snapshot as today there were commits to address the gnutls issue, I'll let you know how it goes.

Edit: tried snapshot r22899-466be0612a (2023-05-16) via the firmware selector and packages samba4-server and msmtp are still failing to build due to the libgnutls issue so I can't install the snapshot, sorry.

I've installed the latest snapshot r22995 and collectd-mod-nut 5.12.0-42 is working fine as it was with the older snapshot.

No joy here. I installed today's snapshot, with hard factory reset before and after, but the results are the same: upsc works, nut's RRD folder is not being created, nut stats are not being collected, therefore no nut tab under LuCI statistics.

On the other hand, the same UPS+router under 22.03.5 does generate nut stats (or apcupsd stats if configured that way).

I think it's unlikely to be an architecture related problem, maybe nut 2.8 behaves a bit differently to 2.7 (which per your first post is from 2016). I'd try to install nut-upsmon and luci-app-nut and play with the config from there. As the software itself is proven working on my router it may not be a too hard nut to crack :wink:

I've tried that, starting by reducing the packages to the bare-miminum for what we want to achieve. Evenmore, I've tried to copy the obvious config files from older and running OpenWrt's into the snapshot, and still can't get collectd to start gathering nut-related data. Or I'm missing something that changed from 2.7.4 to 2.8.0, and/or from release to snapshot, or something from the master branch is getting in the way for my testbed.

I also have been spanning the whole historical releases tree trying to troubleshoot an apcupsd issue, and similar to this case, I narrowed that part to a particular major release jump.

Back to the nut 2.8.0 issue, my major achievement have been to back port the usbhid 2.8.0 driver into 2.7.4, and it seems to work fine. For the rest, I've ran out of ideas :tired_face:

I concurr it doesn't look like architecture-related, but it's the only variable I haven't ruled out yet. Unfortunally I don't have other OpenWrt-snapshot-compatible USB routers in my drawer, and I don't want to bring down again my main box (which is running several services for my household).

1 Like