symlink | misc | UPS

Configuring NUT to recognize multiple units

Sometimes you have two of the same UPS, for example, Orvaldi V1100 (2U), and want to monitor them from the same machine. You cannot have NUT filter them by vendorid or productid for obvious reasons, and you also cannot filter them by serial because:

nutdrv_qx[3300585]: device.serial: UPS reported a non-significant serial [00000000000000]

It is also not really possible to use bus/device as the latter is assigned by the kernel incrementally, so the same USB device might not always remain "device 004".

One might think that it should be possible to write a udev rule that creates fixed symlinks for a certain ENV{ID_PATH}, which is indeed possible with udev (the path is based on physical PCI slots and USB port numbers) but NUT drivers will not be able to use it, because – as the manpage notes – the drivers only accept port=auto, so you cannot pass a /dev/bus/usb-style path nor a symlink to one.

With most recent NUT & libusb builds, there is one option that works, which is busport to select a specific physical USB port. (Though this is still scoped to a given bus, but at least the bus number is likely to remain static as long as you are not using external USB hubs.)

The port number is the one shown by lsusb -tv (e.g. as "Port 002"), but it's easiest to run nut-scanner to generate a config and uncomment the bus/busport parameters (but not the device number):

# nut-scanner -U
Scanning USB bus.
[nutdev-usb1]
        driver = "nutdrv_qx"
        port = "auto"
        vendorid = "0665"
        productid = "5161"
        # bus = "002"
        # device = "006"
        # busport = "004"
[nutdev-usb2]
        driver = "nutdrv_qx"
        port = "auto"
        vendorid = "0665"
        productid = "5161"
        # bus = "002"
        # device = "007"
        # busport = "002"