NUT UPS on Container

manolis11

New Member
Nov 21, 2023
9
0
1
Hello,

I'm trying to use the NUT UPS tools service within an LCX Container but i have notice that compared to KVM when trying to use the command
sudo nut-scanner -U i receive this message.
Failed to open device bus 001,skipping: No such device.
On the KVM instead when using the same command i receive the ups info that i need wihtout any error.
I dont know why on CT i have this issue.
The UPS is correctly identified and connected via USB as listed with the lsusb command
I'm attaching you a screenshot to better describe the issue.

many thnaks
 

Attachments

  • Nut UPS.png
    Nut UPS.png
    138.3 KB · Views: 34
I'm having the same issue, just installed nut after trying apcupsd, which worked and could see my UPS (so I know the container can access it.), but it was missing some values. As apcupsd is no longer maintained since 2016, I was hoping to have better luck with nut.

I'll continue to diagnose and update here, but wanted to add my reply in case someone else can help. My container was set up for apcupsd as per my other thread here: https://forum.proxmox.com/threads/how-to-pass-apc-usb-to-lxc-container.138120/
 
Still not working, but this is what I have tried so far since my last message:
  • Changed the container config, and used "pct set 101 --dev0 path=/dev/usb/hiddev0,mode=0660" to set the pass-through - I got the 0660 from another site with instructions but even without it, it makes no difference, so maybe I need another value here
  • Set the ups.conf as follows, the remarked lines also make no difference
    Code:
    [theUPS]
    driver = usbhid-ups
    port = auto
    desc = "Firewall UPS"
    # bus = 001
    # vendorid = 051d
    # productid = 0003
  • Info on what nut sees
    Code:
    root@EDDIE:~# lsusb
    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 001 Device 004: ID 051d:0003 American Power Conversion UPS
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Code:
    root@EDDIE:~# nut-scanner -U
    Scanning USB bus.
    Failed to open device bus '001', skipping: No such device (it may have been disconnected)
    Code:
    root@EDDIE:~# upsdrvctl -D -d start
    Network UPS Tools - UPS driver controller 2.8.0
       0.000000     [D1] Starting UPS: theUPS
    Network UPS Tools - Generic HID driver 0.47 (2.8.0)
    USB communication driver (libusb 1.0) 0.43
       0.000000     [D1] debug level is '1'
       0.000840     [D1] upsdrv_initups (non-SHUT)...
       0.012288     [D1] Failed to open device (1D6B/0003), skipping: No such device (it may have been disconnected)
       0.022488     [D1] Failed to open device (051D/0003), skipping: No such device (it may have been disconnected)
       0.032719     [D1] Failed to open device (1D6B/0002), skipping: No such device (it may have been disconnected)
       0.032733     libusb1: Could not open any HID devices: insufficient permissions on everything
       0.032735     No matching HID UPS found
       0.034070     Driver failed to start (exit status=1)
 
Didn't realise that lsusb is also seeing a problem for all the USB devices, which does not happen on the host:

Code:
root@EDDIE:~# lsusb -v

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               3.10
  bDeviceClass            9 Hub
  bDeviceSubClass         0
  bDeviceProtocol         3
  bMaxPacketSize0         9
  idVendor           0x1d6b Linux Foundation
  idProduct          0x0003 3.0 root hub
  bcdDevice            6.05
  iManufacturer           3 Linux 6.5.11-7-pve xhci-hcd
  iProduct                2 xHCI Host Controller
  iSerial                 1 0000:00:14.0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x001f
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0
      bInterfaceProtocol      0 Full speed (or root) hub
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval              12
        bMaxBurst               0

Bus 001 Device 005: ID 051d:0003 American Power Conversion UPS
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x051d American Power Conversion
  idProduct          0x0003 UPS
  bcdDevice            1.06
  iManufacturer           1 American Power Conversion
  iProduct                2 Smart-UPS 750 FW:COM 02.1 / UPS.05.I
  iSerial                 3 AS1041221371 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0029
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x60
      (Missing must-be-set bit!)
      Self Powered
      Remote Wakeup
    MaxPower                2mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.00
          bCountryCode           33 US
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     425
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              10
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              10

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            9 Hub
  bDeviceSubClass         0
  bDeviceProtocol         1 Single TT
  bMaxPacketSize0        64
  idVendor           0x1d6b Linux Foundation
  idProduct          0x0002 2.0 root hub
  bcdDevice            6.05
  iManufacturer           3 Linux 6.5.11-7-pve xhci-hcd
  iProduct                2 xHCI Host Controller
  iSerial                 1 0000:00:14.0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0019
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0
      bInterfaceProtocol      0 Full speed (or root) hub
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval              12
 
i found the solution @Taomyn

follow those steps

im using an Unprivileged Container

all steps must be done inside pve shell

1. lsusb

find your device..

Bus 001 Device 002: ID 0665:5161 Cypress Semiconductor USB to Serial

2. ls -al /dev/bus/usb/001/002

crw-rw-r-- 1 root root 189, 1 Dec 20 19:13 /dev/bus/usb/001/002

change the permissions from 664 default to 666

3. chmod 666 /dev/bus/usb/001/002

Modify the container in my case number 114

4. nano /etc/pve/lxc/114.conf

COPY+PASTE this line then SAVE and EXIT

lxc.mount.entry: /dev/bus/usb/001 dev/bus/usb/001 none bind,optional,create=d

reboot the LCX container.

sudo apt install nut nut-client nut-server

then use the command

sudo nut-scanner -U
 
Hey @manolis11 thanks for the tip, I too have made some progress and this is what I did. I only needed to change the container conf file, no changes to permissions, but my file looks like this now:

Code:
arch: amd64
cores: 1
dev0: path=/dev/bus/usb/001/002,mode=0666
features: nesting=1
hostname: EDDIE
memory: 512
net0: name=eth0,bridge=vmbr0,firewall=1,hwaddr=BC:24:11:1F:83:CB,ip=dhcp,type=veth
ostype: debian
rootfs: local-zfs:subvol-101-disk-0,size=8G
startup: order=1
swap: 512
timezone: Europe/Luxembourg
unprivileged: 1

I'm using the new "pct set" command to set up the passthrough, as advised in another thread, so to get the "dev0:" line I used:

Code:
pct set 101 --dev0 path=/dev/bus/usb/001/005,mode=0666

No need for lxc commands:
1703105848680.png

After that the nut services could see my UPS correctly. It's still not perfect as the monitoring service won't start, but I will look at that tomorrow. So things I noted:
  • The device ID will change each time I disconnect and reconnect the USB cable, which I was doing to try and reset things, but the ID would increment by one each time making the container fail to start. Had to reboot the host to get it to reset back to the original value.
  • The other APC package, apcupsd, seems to rely on the device also being on /dev/usb/hiddev0, but not so for nut, at least not so far. I also found if I ran a test command it would remove /dev/usb/hiddev0 meaning another reboot to get it back
 
so the new pct set command is a substitute of the Bind Mounting method for mounting USB devices to pass to LCX Containers?

instead of mounting the usb device on main pve for example

mp0: /mnt/test,mp=/mnt/test
 
Last edited:
so the new pct set command is a substitute of the Bind Mounting method for mounting USB devices to pass to LCX Containers?

instead of mounting the usb device on main pve for example

mp0: /mnt/test,mp=/mnt/test
Yes, I believe that's the idea, no need to manually change the config files, you use the "pct set" to make the changes and they get added in the correct format for PvE

I need to find the documentation for the "dev0" setting and see if it supports specifying the USB device by name rather than the bus ID which as I stated keeps changing if you disconnect/reconnect the device.
 
@Taomyn Were you able to work out a working solution to get the usv surveillance running in a lxc container?
I'm facing the same use case and before start digging around maybe I can built upon your work.
 
@Taomyn Were you able to work out a working solution to get the usv surveillance running in a lxc container?
I'm facing the same use case and before start digging around maybe I can built upon your work.
I gave up with trying to use an LXC to monitor my UPS as even when getting it connected to my OPNsense VM, it wasn't able to get anywhere near the information that the native Windows service can. In the end for now I reverted to an LXC running just apcupsd but I haven't done much more. I did get hold of the RPM of Powerchute that finally got released, but I have not checked it out yet.

The issue with passing the device through to the LXC is definitely sorted though.
 
In the end for now I reverted to an LXC running just apcupsd but I haven't done much more.

The issue with passing the device through to the LXC is definitely sorted though.
Same here.

At the moment apcupsd works in an lxc. Minimum setup in my case would be to receive an email, when power outage occurs.
Everything else is nice to have at the moment for my case.
 
  • Like
Reactions: Taomyn
dont waste your time and mind status... i just install a minimal trimed windows image and run the windows software of my UPS there on a VM
 
So to confirm : having a nut in a LXC unpriv, fully connected to the ups : is the shutdown command can be pass to the host or they just stay inside the lxc ?
 
So to confirm : having a nut in a LXC unpriv, fully connected to the ups : is the shutdown command can be pass to the host or they just stay inside the lxc ?
I may not completely (correctly) understand your English, but if you are asking whether the LXC can successfully shutdown/power off the node - then obviously the answer is no. However you could use the API or SSH method to accomplish this.
 
The issue with passing the device through to the LXC is definitely sorted though.
Hi @Taomyn , I saw that you mentioned an issue where the USB device ID changes every time the device is disconnected and reconnected, and that you had to reboot the Proxmox server to reset the ID back to its original value. How did you handle this problem in the end? Did you find a workaround or solution to avoid having to reboot the entire Proxmox server each time? Any advice would be appreciated!
 
Hi @Taomyn , I saw that you mentioned an issue where the USB device ID changes every time the device is disconnected and reconnected, and that you had to reboot the Proxmox server to reset the ID back to its original value. How did you handle this problem in the end? Did you find a workaround or solution to avoid having to reboot the entire Proxmox server each time? Any advice would be appreciated!
Unfortunately I haven't, I just avoided the issue so far, but it would be better if this simply didn't happen - I just wish I could pass the device the same way I can for VMs using USB Vendor/Device ID as I have no issues with that for a Windows server I use to monitor another UPS.
 
I may not completely (correctly) understand your English, but if you are asking whether the LXC can successfully shutdown/power off the node - then obviously the answer is no. However you could use the API or SSH method to accomplish this.
Hi,

I have NUT Server installed in a CT, recognized and all is ok.
You say that the CT cannot shutdown (or control) the host, totally understand this. You're mentioning API or SSH, is there a tutorial somewhere?
Would a different solution be to have the host function as a client for the NUT Container and so when power becomes critical the CT will just send the command to the client to power down the host and then everything will be shut down properly.

Or is this not going to work?

ps. I'm going for this setup since I'm planning to later on have a dedicated RPi or old laptop controlling the servers. This way I'm trying to keep the OS as clean as possible.
 
You're mentioning API or SSH, is there a tutorial somewhere?
SSH command/s for shutting down host are pretty vanilla Linux style. Just setup a pair of SSH keys between the CT & the node host & then issue the shutdown command via SSH from the CT.

As far as the API method goes, this is more Proxmox-centric, but basically what you will do is setup an API token with User Name & Token ID, & then issue the shutdown command from the CT.

For more info, see this post of mine. Maybe read that whole thread, you'll also find info there to issue VM specific commands. Also in this post you'll also see the SSH method.
 
  • Like
Reactions: Pato_77
SSH command/s for shutting down host are pretty vanilla Linux style. Just setup a pair of SSH keys between the CT & the node host & then issue the shutdown command via SSH from the CT.

As far as the API method goes, this is more Proxmox-centric, but basically what you will do is setup an API token with User Name & Token ID, & then issue the shutdown command from the CT.

For more info, see this post of mine. Maybe read that whole thread, you'll also find info there to issue VM specific commands. Also in this post you'll also see the SSH method.
Thanks!
After a bit of fiddling I generated a SSH Key-pair for my NUT-CT to get into the PVE and (tnx to the reference to your other post) give the power down command. Works excellent!

Now I need to figure out if my UPS is a 20% (LB) how much time is remaining, for the host to shutdown. Also, I need to see if it's possible to have the clients to shutdown when the UPS is at 50% battery. So for the clients 50% should be LowBatt. Is that possible?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!