Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NUT 2.8.1-3 "Can't claim USB device [051d:0002]@0/0: Entity not found" using usbhid-ups #2666

Open
ErikDB87 opened this issue Oct 30, 2024 · 35 comments
Labels
APC DDL impacts-release-2.8.1 Issues reported against NUT release 2.8.1 (maybe vanilla or with minor packaging tweaks) USB

Comments

@ErikDB87
Copy link

ErikDB87 commented Oct 30, 2024

Hi all,

Yesterday, I bought a UPS for the first time in my life, and was eager to dive into NUT. But not all is working as expected... I saw a similar thread started on 18 October, but it didn't help me. (I also spent a handful of hours searching the web for solutions, and of course read the manual and FAQ - "queequeg".)

I tried shutting my UPS (APC "Back-UPS BX750MI FW:295202G -302202G") down with sudo upsdrvctl shutdown, but no response. Digging around, I found a few things that raised my suspicion, but I can't figure it out...

I followed this fine gentleman's guide (but tweaked it a bit - I don't know why he uses master and slave for example?): https://technotim.live/posts/NUT-server-guide/.
I must add that I created a few users and user groups during installation and configuration, following the documentation. But in the end, I lost oversight, and everything didn't work. So it's entirely possible there's a permissions issue somewhere. But I don't have any idea where...

Because of the trial-and-error approach, in the .conf files (shown below), a lot of stuff is commented out. I assume I can delete it, but I also assume the # should be adequate? Anyway, I keep it in the output below for clarity.

I'll just paste various outputs here, I hope that's a reasonable approach?

Thanks in advance for anyone's help!

Kind regards,

Erik

erik@MinipcLG2:/$ sudo upsdrvctl shutdown apcupskelder
Network UPS Tools - UPS driver controller 2.8.1
Network UPS Tools - Generic HID driver 0.52 (2.8.1)
USB communication driver (libusb 1.0) 0.46
select with socket: Invalid argument
Can't claim USB device [051d:0002]@0/0: Entity not found
upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it
Driver failed to start (exit status=1)
erik@MinipcLG2:/$ sudo nut-scanner -U
Scanning USB bus.
[nutdev1]
        driver = "usbhid-ups"
        port = "auto"
        vendorid = "051D"
        productid = "0002"
        product = "Back-UPS BX750MI  FW:295202G -302202G"
        serial = "9B2416A22014"
        vendor = "American Power Conversion"
        bus = "001"
        device = "004"
        busport = "002"
        ###NOTMATCHED-YET###bcdDevice = "0106"
erik@MinipcLG2:/etc/nut$ sudo usbhid-ups -a apcupskelder
sudo: usbhid-ups: opdracht niet gevonden

This seems strange? But after some googling, I found the below alternative - although I would expect it to work without /lib/nut/):

erik@MinipcLG2:/$ sudo /lib/nut/usbhid-ups -a apcupskelder
Network UPS Tools - Generic HID driver 0.52 (2.8.1)
USB communication driver (libusb 1.0) 0.46
Duplicate driver instance detected (PID file /run/nut/usbhid-ups-apcupskelder.pid exists)! Terminating other driver!

Bericht aan allen van root@MinipcLG2 (somewhere) (Wed Oct 30 10:27:32 2024):

Communications with UPS apcupskelder@localhost lost


Bericht aan allen van root@MinipcLG2 (somewhere) (Wed Oct 30 10:27:32 2024):

Communications with UPS apcupskelder@localhost lost

HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be incorrect; interpreting LogMax -1 as 255 in ReportID: 0x0c
HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be incorrect; interpreting LogMax -1 as 255 in ReportID: 0x22
HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be incorrect; interpreting LogMax -1 as 255 in ReportID: 0x40
Using subdriver: APC HID 0.100

Bericht aan allen van root@MinipcLG2 (somewhere) (Wed Oct 30 10:27:40 2024):

Communications with UPS apcupskelder@localhost established


Bericht aan allen van root@MinipcLG2 (somewhere) (Wed Oct 30 10:27:48 2024):

Communications with UPS apcupskelder@localhost lost


Bericht aan allen van root@MinipcLG2 (somewhere) (Wed Oct 30 10:27:56 2024):

Communications with UPS apcupskelder@localhost established
erik@MinipcLG2:/$ cat /etc/group | grep nut
users:x:100:nutuser,nutmon
nut:x:130:
nutuser:x:1002:
nutgroup:x:1003:nutuser
nutmon:x:1004:
nutmongroep:x:1005:nutmon
erik@MinipcLG2:/$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
Bus 001 Device 004: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
erik@MinipcLG2:/$ ls -l /dev/bus/usb/001/004
crw-rw-r-- 1 root nut 189, 3 okt 30 10:31 /dev/bus/usb/001/004
erik@MinipcLG2:/$ cat /etc/os-release
NAME="Linux Mint"
VERSION="22 (Wilma)"
ID=linuxmint
ID_LIKE="ubuntu debian"
PRETTY_NAME="Linux Mint 22"
VERSION_ID="22"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=wilma
UBUNTU_CODENAME=noble
erik@MinipcLG2:/$ hostnamectl
 Static hostname: MinipcLG2
       Icon name: computer-desktop
         Chassis: desktop 🖥️
      Machine ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
         Boot ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Operating System: Linux Mint 22
          Kernel: Linux 6.8.0-47-generic
    Architecture: x86-64
 Hardware Vendor: HP
  Hardware Model: HP EliteDesk 800 G2 DM 65W
Firmware Version: N21 Ver. 02.10
   Firmware Date: Sun 2016-01-24
    Firmware Age: 8y 9month 6d
erik@MinipcLG2:/$ uname -r
6.8.0-47-generic
erik@MinipcLG2:/$ sudo apt list nut*
Bezig met oplijsten... Klaar
nut-cgi/noble,now 2.8.1-3.1ubuntu2 amd64 [geïnstalleerd]
nut-client/noble,now 2.8.1-3.1ubuntu2 amd64 [geïnstalleerd]
nut-doc/noble 2.8.1-3.1ubuntu2 all
nut-i2c/noble 2.8.1-3.1ubuntu2 amd64
nut-ipmi/noble 2.8.1-3.1ubuntu2 amd64
nut-modbus/noble 2.8.1-3.1ubuntu2 amd64
nut-monitor/noble 2.8.1-3.1ubuntu2 all
nut-powerman-pdu/noble 2.8.1-3.1ubuntu2 amd64
nut-server/noble,now 2.8.1-3.1ubuntu2 amd64 [geïnstalleerd]
nut-snmp/noble 2.8.1-3.1ubuntu2 amd64
nut-xml/noble 2.8.1-3.1ubuntu2 amd64
nut/noble,now 2.8.1-3.1ubuntu2 all [geïnstalleerd]
nutcracker/noble 0.5.0+dfsg-2 amd64
nutsqlite/noble 2.0.6-4 all
nuttcp/noble 6.1.2-4build1 amd64
erik@MinipcLG2:/$ sudo /lib/nut/usbhid-ups -DDD -a apcupskelder
Network UPS Tools - Generic HID driver 0.52 (2.8.1)
USB communication driver (libusb 1.0) 0.46
   0.000000     [D3] do_global_args: var='pollinterval' val='1'
   0.000024     [D1] testval_reloadable: setting 'pollinterval' exists and differs: new value '1' vs. '2'
   0.000057     [D3] do_global_args: var='maxretry' val='3'
   0.000083     [D3] main_arg: var='driver' val='usbhid-ups'
   0.000108     [D3] main_arg: var='port' val='auto'
   0.000136     [D3] main_arg: var='desc' val='Back-UPS BX750MI  FW:295202G -302202G'
   0.000152     [D3] main_arg: var='vendorid' val='051d'
   0.000179     [D3] main_arg: var='productid' val='0002'
   0.000203     [D3] main_arg: var='serial' val='9B2416A22014'
   0.000248     [D1] Network UPS Tools version 2.8.1 (release/snapshot of 2.8.1) built with gcc (Ubuntu 13.2.0-23ubuntu2) 13.2.0 and configured with flags: --build=x86_64-linux-gnu --prefix=/usr --includedir=${prefix}/include --mandir=${prefix}/share/man --infodir=${prefix}/share/info --sysconfdir=/etc --localstatedir=/var --disable-option-checking --disable-silent-rules --libdir=${prefix}/lib/x86_64-linux-gnu --runstatedir=/run --disable-maintainer-mode --disable-dependency-tracking --prefix= --sysconfdir=/etc/nut --includedir=/usr/include --mandir=/usr/share/man --libdir=${prefix}/lib/x86_64-linux-gnu --libexecdir=/usr/libexec --with-ssl --with-nss --with-cgi --with-dev --enable-static --with-statepath=/run/nut --with-altpidpath=/run/nut --with-drvpath=/lib/nut --with-cgipath=/usr/lib/cgi-bin/nut --with-htmlpath=/usr/share/nut/www --with-pidpath=/run/nut --datadir=/usr/share/nut --with-pkgconfig-dir=/usr/lib/x86_64-linux-gnu/pkgconfig --with-user=nut --with-group=nut --with-udev-dir=/lib/udev --with-systemdsystemunitdir=/lib/systemd/system --with-systemdshutdowndir=/lib/systemd/system-shutdown --with-systemdtmpfilesdir=/usr/lib/tmpfiles.d --with-python=python3 --with-python3=/usr/bin/python3 --with-doc=man,html-single,html-chunked,pdf
   0.000352     [D1] debug level is '3'
   0.002200     [D1] Succeeded to become_user(nut): now UID=121 GID=130
   0.002266     [D1] upsdrv_initups (non-SHUT)...
   0.002285     [D2] Initializing an USB-connected UPS with library libusb-1.0.27 (API: 0x100010a) (NUT subdriver name='USB communication driver (libusb 1.0)' ver='0.46')
   0.008020     [D2] Checking device 1 of 4 (1D6B/0003)
   0.008045     [D1] Failed to open device (1D6B/0003), skipping: Access denied (insufficient permissions)
   0.008052     [D2] Checking device 2 of 4 (0403/6001)
   0.008064     [D1] Failed to open device (0403/6001), skipping: Access denied (insufficient permissions)
   0.008079     [D2] Checking device 3 of 4 (051D/0002)
   0.010003     [D2] - VendorID: 051d
   0.010014     [D2] - ProductID: 0002
   0.010018     [D2] - Manufacturer: American Power Conversion
   0.010022     [D2] - Product: Back-UPS BX750MI  FW:295202G -302202G
   0.010026     [D2] - Serial Number: 9B2416A22014
   0.010030     [D2] - Bus: 001
   0.010034     [D2] - Bus Port: 002
   0.010038     [D2] - Device: 004
   0.010042     [D2] - Device release number: 0106
   0.010046     [D2] Trying to match device
   0.010058     [D2] match_function_subdriver (non-SHUT mode): matching a device...
   0.010068     [D3] match_function_regex: matching a device...
   0.010145     [D2] Device matches
   0.010155     [D2] Reading first configuration descriptor
   0.010172     [D3] libusb_kernel_driver_active() returned 0: Success
   0.010186     [D2] failed to claim USB device: Resource busy
   0.010198     [D2] Kernel driver already detached
   0.010210     [D2] failed to claim USB device: Resource busy
   0.010225     [D2] Kernel driver already detached
   0.010237     [D2] failed to claim USB device: Resource busy
   0.010249     [D2] Kernel driver already detached
   0.010263     [D2] failed to claim USB device: Resource busy
   0.010275     [D2] Kernel driver already detached
   0.010286     Can't claim USB device [051d:0002]@0/0: Entity not found
   0.010300     upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it
erik@MinipcLG2:/etc/nut$ sudo cat /etc/nut/hosts.conf
MONITOR apcupskelder@localhost "APC-UPS kelder"
erik@MinipcLG2:/etc/nut$ sudo cat /etc/nut/nut.conf
MODE=netserver
erik@MinipcLG2:/etc/nut$ sudo cat /etc/nut/ups.conf
pollinterval = 1
maxretry = 3


[apcupskelder]
        driver = usbhid-ups
        port = auto
        desc = "Back-UPS BX750MI  FW:295202G -302202G"
        vendorid = 051d
        productid = 0002
        serial = 9B2416A22014
#        vendor = "American Power Conversion"
#        bus = 001
#        device = 005
#        busport = 002
        ###NOTMATCHED-YET###bcdDevice = "0106"
erik@MinipcLG2:/etc/nut$ sudo cat /etc/nut/upsd.conf
LISTEN 0.0.0.0 3493
erik@MinipcLG2:/etc/nut$ sudo cat /etc/nut/upsd.users
#[bespieder]
[monuser]
  password  = indUStr*a
#  bekijker primary
#  admin master
  admin primary
erik@MinipcLG2:/etc/nut$ sudo cat /etc/nut/upsmon.conf
#RUN_AS_USER nutgebruiker
RUN_AS_USER root
#MONITOR apcupskelder@localhost 1 bekijker indUStr*a primary
#MONITOR apcupskelder@localhost 1 admin indUStr*a master
MONITOR apcupskelder@localhost 1 admin indUStr*a primary


MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
NOTIFYCMD /usr/sbin/upssched
POLLFREQ 2
POLLFREQALERT 1
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/nut/killpower

NOTIFYMSG ONLINE    "UPS %s on line power"
NOTIFYMSG ONBATT    "UPS %s on battery"
NOTIFYMSG LOWBATT   "UPS %s battery is low"
NOTIFYMSG FSD       "UPS %s: forced shutdown in progress"
NOTIFYMSG COMMOK    "Communications with UPS %s established"
NOTIFYMSG COMMBAD   "Communications with UPS %s lost"
NOTIFYMSG SHUTDOWN  "Auto logout and shutdown proceeding"
NOTIFYMSG REPLBATT  "UPS %s battery needs to be replaced"
NOTIFYMSG NOCOMM    "UPS %s is unavailable"
NOTIFYMSG NOPARENT  "upsmon parent process died - shutdown impossible"

NOTIFYFLAG ONLINE   SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT   SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT  SYSLOG+WALL
NOTIFYFLAG FSD      SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK   SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD  SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL
NOTIFYFLAG NOCOMM   SYSLOG+WALL+EXEC
NOTIFYFLAG NOPARENT SYSLOG+WALL

RBWARNTIME 43200

NOCOMMWARNTIME 600

FINALDELAY 5
@ErikDB87 ErikDB87 changed the title NUT 2.8.1-3 " Can't claim USB device [051d:0002]@0/0: Entity not found" using usbhid-ups NUT 2.8.1-3 "Can't claim USB device [051d:0002]@0/0: Entity not found" using usbhid-ups Nov 1, 2024
@ErikDB87
Copy link
Author

ErikDB87 commented Nov 2, 2024

I thought removing and installing the package again might solve the problem. I also removed /etc/nut.

But somehow, the directory /etc/nut is created again, but the config files in it are not...?

So I did this:

sudo apt remove nut nut-client nut-server
sudo reboot
sudo apt autoremove
sudo reboot
sudo rm -r /etc/nut
sudo apt install nut nut-client nut-server

And now:

erik@MinipcLG2:/etc/nut$ ls -pal
totaal 16
drwxr-xr-x   2 root root  4096 nov  2 16:29 ./
drwxr-xr-x 182 root root 12288 nov  2 16:29 ../

Somehow, I made it worse... But I don't understand how installing the packages again fails to install these files...?

EDIT
Some googling almost fixed this: https://ubuntuforums.org/showthread.php?t=2487834

But hosts.conf is still missing...

@jimklimov
Copy link
Member

I believe some answers around this general issue are in the mailing list.

As for packaging, NUT team does not impact it directly, so it is technically a distro matter. That said, probably different packages defined for NUT there which deliver files which might need configuration files, all deliver the /etc/nut directory. There may be some package which also delivers *.conf.sample files which are just that - well-commented samples (to copy into *.conf and adapt to your setup). Packaging can not divine your device details, IP addresses, etc. to recreate your customized config files.

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 2, 2024

Of course I didn't expect my amended config files to appear. :) But the standard ones - which were installed when I first installed NUT, didn't reappear... I manually added hosts.conf using sudo nano hosts.conf.

Anyway, I had hoped this reinstall would have reset all the permissions. But I was wrong...

But it looks like I'm where I started out; so maybe no harm no foul?

@jimklimov
Copy link
Member

Probably no foul. As you edited ups.conf, NDE could have picked up the device definition and created the [email protected] instance again, so the manually-started driver conflicts with it again.

Re-check if the unit does exist and does not complain (like on the mailing list) - if so, go on to upsd (nut-server) and upsc client (to check it works) and finally upsmon for notifications and safe shutdown.

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 2, 2024

I'm not sure I fully understand what you mean... I'm not really a Linux master :)

But here are some outputs:

erik@MinipcLG2:/etc/nut$ systemctl status [email protected][email protected] - Network UPS Tools - device driver for NUT device 'apcupskelder'
     Loaded: loaded (/usr/lib/systemd/system/[email protected]; enabled; preset: enabled)
    Drop-In: /etc/systemd/system/[email protected]
             └─nut-driver-enumerator-generated-checksum.conf, nut-driver-enumerator-generated.conf
     Active: active (running) since Sat 2024-11-02 20:27:55 CET; 48s ago
    Process: 11894 ExecStartPre=/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-common-tmpfiles.conf (code=exited, status=0/SUCCESS)
    Process: 11896 ExecStart=/bin/sh -c NUTDEV="`/usr/libexec/nut-driver-enumerator.sh --get-device-for-service apcupskelder`" && [ -n "$NUTDEV" ] || { echo "FATAL: Could not find a NUT device section for service unit apcupskelder" >&2 ; exit 1 ; } ; exec /sbin/upsdrvctl  start "$NUTDEV" (code=exited, status=0/SUCCESS)
   Main PID: 11934 (usbhid-ups)
      Tasks: 1 (limit: 9284)
     Memory: 608.0K (peak: 2.6M)
        CPU: 99ms
     CGroup: /system.slice/system-nut\x2ddriver.slice/[email protected]
             └─11934 /lib/nut/usbhid-ups -a apcupskelder

nov 02 20:27:55 MinipcLG2 nut-driver@apcupskelder[11923]: HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be incorrect; interpreting LogMax -1 as 255 in ReportID: 0x22
nov 02 20:27:55 MinipcLG2 nut-driver@apcupskelder[11923]: HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be incorrect; interpreting LogMax -1 as 255 in ReportID: 0x40
nov 02 20:27:55 MinipcLG2 nut-driver@apcupskelder[11923]: Using subdriver: APC HID 0.100
nov 02 20:27:55 MinipcLG2 nut-driver@apcupskelder[11923]: Network UPS Tools - Generic HID driver 0.52 (2.8.1)
nov 02 20:27:55 MinipcLG2 nut-driver@apcupskelder[11923]: USB communication driver (libusb 1.0) 0.46
nov 02 20:27:55 MinipcLG2 usbhid-ups[11934]: Startup successful
nov 02 20:27:55 MinipcLG2 usbhid-ups[11934]: upsnotify: failed to notify about state 2: no notification tech defined, will not spam more about it
nov 02 20:27:55 MinipcLG2 nut-driver@apcupskelder[11896]: Network UPS Tools - UPS driver controller 2.8.1
nov 02 20:27:55 MinipcLG2 systemd[1]: Started [email protected] - Network UPS Tools - device driver for NUT device 'apcupskelder'.
nov 02 20:27:56 MinipcLG2 usbhid-ups[11934]: sock_connect: enabling asynchronous mode (auto)
erik@MinipcLG2:/etc/nut$ systemctl status nut-server.service
● nut-server.service - Network UPS Tools - power devices information server
     Loaded: loaded (/usr/lib/systemd/system/nut-server.service; enabled; preset: enabled)
     Active: active (running) since Sat 2024-11-02 20:27:35 CET; 3min 24s ago
    Process: 11815 ExecStartPre=/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-common-tmpfiles.conf (code=exited, status=0/SUCCESS)
   Main PID: 11818 (upsd)
      Tasks: 1 (limit: 9284)
     Memory: 464.0K (peak: 1.5M)
        CPU: 65ms
     CGroup: /system.slice/nut-server.service
             └─11818 /lib/nut/upsd -F

nov 02 20:27:35 MinipcLG2 nut-server[11818]: Running as foreground process, not saving a PID file
nov 02 20:27:35 MinipcLG2 nut-server[11818]: upsnotify: failed to notify about state 2: no notification tech defined, will not spam more about it
nov 02 20:27:35 MinipcLG2 upsd[11818]: Running as foreground process, not saving a PID file
nov 02 20:27:35 MinipcLG2 upsd[11818]: upsnotify: failed to notify about state 2: no notification tech defined, will not spam more about it
nov 02 20:27:35 MinipcLG2 nut-server[11818]: Can't connect to UPS [apcupskelder] (usbhid-ups-apcupskelder): No such file or directory
nov 02 20:27:35 MinipcLG2 upsd[11818]: Can't connect to UPS [apcupskelder] (usbhid-ups-apcupskelder): No such file or directory
nov 02 20:27:37 MinipcLG2 nut-server[11818]: Connected to UPS [apcupskelder]: usbhid-ups-apcupskelder
nov 02 20:27:37 MinipcLG2 upsd[11818]: Connected to UPS [apcupskelder]: usbhid-ups-apcupskelder
nov 02 20:27:56 MinipcLG2 nut-server[11818]: Connected to UPS [apcupskelder]: usbhid-ups-apcupskelder
nov 02 20:27:56 MinipcLG2 upsd[11818]: Connected to UPS [apcupskelder]: usbhid-ups-apcupskelder
erik@MinipcLG2:/etc/nut$ systemctl status upsd
● nut-server.service - Network UPS Tools - power devices information server
     Loaded: loaded (/usr/lib/systemd/system/nut-server.service; enabled; preset: enabled)
     Active: active (running) since Sat 2024-11-02 20:27:35 CET; 3min 49s ago
    Process: 11815 ExecStartPre=/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-common-tmpfiles.conf (code=exited, status=0/SUCCESS)
   Main PID: 11818 (upsd)
      Tasks: 1 (limit: 9284)
     Memory: 464.0K (peak: 1.5M)
        CPU: 71ms
     CGroup: /system.slice/nut-server.service
             └─11818 /lib/nut/upsd -F

nov 02 20:27:35 MinipcLG2 nut-server[11818]: Running as foreground process, not saving a PID file
nov 02 20:27:35 MinipcLG2 nut-server[11818]: upsnotify: failed to notify about state 2: no notification tech defined, will not spam more about it
nov 02 20:27:35 MinipcLG2 upsd[11818]: Running as foreground process, not saving a PID file
nov 02 20:27:35 MinipcLG2 upsd[11818]: upsnotify: failed to notify about state 2: no notification tech defined, will not spam more about it
nov 02 20:27:35 MinipcLG2 nut-server[11818]: Can't connect to UPS [apcupskelder] (usbhid-ups-apcupskelder): No such file or directory
nov 02 20:27:35 MinipcLG2 upsd[11818]: Can't connect to UPS [apcupskelder] (usbhid-ups-apcupskelder): No such file or directory
nov 02 20:27:37 MinipcLG2 nut-server[11818]: Connected to UPS [apcupskelder]: usbhid-ups-apcupskelder
nov 02 20:27:37 MinipcLG2 upsd[11818]: Connected to UPS [apcupskelder]: usbhid-ups-apcupskelder
nov 02 20:27:56 MinipcLG2 nut-server[11818]: Connected to UPS [apcupskelder]: usbhid-ups-apcupskelder
nov 02 20:27:56 MinipcLG2 upsd[11818]: Connected to UPS [apcupskelder]: usbhid-ups-apcupskelder
erik@MinipcLG2:~$ systemctl status upsc
Unit upsc.service could not be found.
erik@MinipcLG2:/etc/nut$ systemctl status upsmon
● nut-monitor.service - Network UPS Tools - power device monitor and shutdown controller
     Loaded: loaded (/usr/lib/systemd/system/nut-monitor.service; enabled; preset: enabled)
     Active: active (running) since Sat 2024-11-02 20:27:35 CET; 4min 10s ago
    Process: 11836 ExecStartPre=/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-common-tmpfiles.conf (code=exited, status=0/SUCCESS)
   Main PID: 11839 (upsmon)
      Tasks: 2 (limit: 9284)
     Memory: 888.0K (peak: 2.0M)
        CPU: 86ms
     CGroup: /system.slice/nut-monitor.service
             ├─11839 /lib/nut/upsmon -F
             └─11842 /lib/nut/upsmon -F

nov 02 20:27:35 MinipcLG2 nut-monitor[11839]: Using power down flag file /etc/nut/killpower
nov 02 20:27:35 MinipcLG2 nut-monitor[11842]: Init SSL without certificate database
nov 02 20:27:35 MinipcLG2 nut-monitor[11842]: upsnotify: failed to notify about state 2: no notification tech defined, will not spam more about it
nov 02 20:27:35 MinipcLG2 nut-monitor[11842]: Login on UPS [apcupskelder@localhost] failed - got [ERR ACCESS-DENIED]
nov 02 20:27:52 MinipcLG2 nut-monitor[11842]: Poll UPS [apcupskelder@localhost] failed - Driver not connected
nov 02 20:27:52 MinipcLG2 nut-monitor[11842]: Communications with UPS apcupskelder@localhost lost
nov 02 20:27:52 MinipcLG2 nut-monitor[11925]: Network UPS Tools upsmon 2.8.1
nov 02 20:27:54 MinipcLG2 nut-monitor[11842]: Poll UPS [apcupskelder@localhost] failed - Driver not connected
nov 02 20:27:56 MinipcLG2 nut-monitor[11842]: Communications with UPS apcupskelder@localhost established
nov 02 20:27:56 MinipcLG2 nut-monitor[11936]: Network UPS Tools upsmon 2.8.1

There seem to be some problems with usbhid-ups-apcupskelder...

@jimklimov
Copy link
Member

Looks great actually: [email protected] initialized around 20:27:55, and at 20:27:56 accepted a socket connection. That's the same moment logged by nut-server.service (aliased as upsd to match the program name):

nov 02 20:27:56 MinipcLG2 upsd[11818]: Connected to UPS [apcupskelder]: usbhid-ups-apcupskelder

upsc is not a service, it is a command-line client. You should just run

:; upsc apcupskelder

(if on the same machine as upsd) and it should report a number of key: value pairs for some driver settings and all device readings it found.

WARNING: The nut-monitor.service (aliased as upsmon) did have a hiccup:

Login on UPS ***@***.*** failed - got [ERR ACCESS-DENIED]

This usually means either mismatch between /etc/nut/upsd.users and the credentials in MONITOR line of upsmon.conf, or bad permissions so one of the daemons can not read its config (or too open permissions so it can refuse to trust that file, whose passwords anyone can know).

I am a bit puzzled about upsnotify: failed to notify about state 2: no notification tech defined, will not spam more about it lines (daemon should have noticed it run under systemd, but that is not too consequential).

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 6, 2024

upsc is not a service, it is a command-line client. You should just run\n\n:; upsc apcupskelder\n(if on the same machine as upsd) and it should report a number of key: value pairs for some driver settings and all device readings it found.

Indeed:

erik@MinipcLG2:~$ upsc apcupskelder
Init SSL without certificate database
battery.charge: 100
battery.charge.low: 10
battery.mfr.date: 2001/01/01
battery.runtime: 3920
battery.runtime.low: 120
battery.type: PbAc
battery.voltage: 13.6
battery.voltage.nominal: 12.0
device.mfr: American Power Conversion
device.model: Back-UPS BX750MI
device.serial: 9B2416A22014
device.type: ups
driver.debug: 0
driver.flag.allow_killpower: 0
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 1
driver.parameter.port: auto
driver.parameter.productid: 0002
driver.parameter.serial: 9B2416A22014
driver.parameter.synchronous: auto
driver.parameter.vendorid: 051d
driver.state: quiet
driver.version: 2.8.1
driver.version.data: APC HID 0.100
driver.version.internal: 0.52
driver.version.usb: libusb-1.0.27 (API: 0x100010a)
input.sensitivity: low
input.transfer.high: 295
input.transfer.low: 145
input.voltage: 230.0
input.voltage.nominal: 230
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.firmware: 295202G -302202G
ups.load: 0
ups.mfr: American Power Conversion
ups.mfr.date: 2024/04/23
ups.model: Back-UPS BX750MI
ups.productid: 0002
ups.realpower.nominal: 410
ups.serial: 9B2416A22014
ups.status: OL
ups.test.result: Done and passed
ups.timer.reboot: 0
ups.timer.shutdown: -1
ups.vendorid: 051d 

WARNING: The nut-monitor.service (aliased as upsmon) did have a hiccup:\n\nLogin on UPS @.*** failed - got [ERR ACCESS-DENIED]\nThis usually means either mismatch between /etc/nut/upsd.users and the credentials in MONITOR line of upsmon.conf, or bad permissions so one of the daemons can not read its config (or too open permissions so it can refuse to trust that file, whose passwords anyone can know).

I had hoped a fresh install would have reset all the permissions... Do you have any idea which commands might fix the permissions issues?

@jimklimov jimklimov added DDL APC USB impacts-release-2.8.1 Issues reported against NUT release 2.8.1 (maybe vanilla or with minor packaging tweaks) labels Nov 6, 2024
@jimklimov
Copy link
Member

Looking at your earlier post, the upsd.users you've posted seems very wrong. Please check the sample at https://github.com/networkupstools/nut/blob/master/conf/upsd.users.sample about syntax and expected contents. Also maybe change the passwords in the final configuration, just in case ;)

Also note, with an APC BX###MI device, #2565 and related issues and PRs may be relevant. That fix is not part of a released version yet though, so if you'd end up needing it before a release is cut and gets through distro packaging queues - a custom build would be required, e.g. per https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests

@jimklimov
Copy link
Member

As for file permissions, can you post ls -la /etc/nut output?

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 6, 2024

Looking at your earlier post, the upsd.users you've posted seems very wrong. Please check the sample at https://github.com/networkupstools/nut/blob/master/conf/upsd.users.sample about syntax and expected contents. Also maybe change the passwords in the final configuration, just in case ;)

I see... Shame on me for following the guide, and not reading the readme. I did that eventually for a few other conf files, but not this one...

I assume this would be better?

[admin]
  password  = indUStr*a
  actions = FSD
  instcmds = ALL

?

(I'll have access to the Linux server later today; I'll run ls -la /etc/nut then as well.)

@jimklimov
Copy link
Member

jimklimov commented Nov 6, 2024

Well, coming from legacy long ago, before my time, that upsd.users lists two separate user concepts. I don't remember if I've ever tried mixing both into one user entry:

  • User that can subscribe to the data server for monitoring and stay with a persistent session, with an upsmon <ROLE> line - that's the one you need to define and use in a MONITOR line of upsmon.conf
  • User who can set variables or send commands, "all" or a selection of some - optional, for NUT clients like upsrw, upscmd or CGI upsset, etc.

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 6, 2024

Well, coming from legacy long ago, before my time, that upsd.users lists two separate user concepts. I don't remember if I mixed both into one user entry:

  • User that can subscribe to the data server for monitoring and stay with a persistent session, with an upsmon <ROLE> line - that's the one you need to define and use in a MONITOR line of upsmon.conf
  • User who can set variables or send commands, "all" or a selection of some - optional, for NUT clients like upsrw, upscmd or CGI upsset, etc.

So it should be:

[admin]
  password  = indUStr*a
  actions = FSD
  instcmds = ALL
  upsmon primary

?

@jimklimov
Copy link
Member

Maybe, if it does work to mix it like that. If something still complains, separate this into two users for two use-cases, e.g.:

[admin]
  password  = indUStr*a
  actions = FSD
  instcmds = ALL

[upsmon]
  password  = indUStr*a
  upsmon primary

(and then use MONITOR apcupskelder@localhost 1 upsmon indUStr*a primary in upsmon.conf).

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 6, 2024

Thanks for all your time and effort, @jimklimov! Although we're not out of the woods yet, I'm afraid...

Now /etc/nut/upsd.users reads as follows:

[admin]
  password  = indUStr*a
  actions = FSD
  instcmds = ALL

[upsmon]
  password  = indUStr*a
  upsmon primary

(Although I don't understand where this admin user is used...? Since he's not mentioned anywhere?)

/etc/nut/upsmon.conf now reads:

RUN_AS_USER nut
MONITOR apcupskelder@localhost 1 admin indUStr*a primary
MONITOR apcupskelder@localhost 1 upsmon indUStr*a primary


MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
NOTIFYCMD /usr/sbin/upssched
POLLFREQ 2
POLLFREQALERT 1
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/nut/killpower

NOTIFYMSG ONLINE    "UPS %s on line power"
NOTIFYMSG ONBATT    "UPS %s on battery"
NOTIFYMSG LOWBATT   "UPS %s battery is low"
NOTIFYMSG FSD       "UPS %s: forced shutdown in progress"
NOTIFYMSG COMMOK    "Communications with UPS %s established"
NOTIFYMSG COMMBAD   "Communications with UPS %s lost"
NOTIFYMSG SHUTDOWN  "Auto logout and shutdown proceeding"
NOTIFYMSG REPLBATT  "UPS %s battery needs to be replaced"
NOTIFYMSG NOCOMM    "UPS %s is unavailable"
NOTIFYMSG NOPARENT  "upsmon parent process died - shutdown impossible"

NOTIFYFLAG ONLINE   SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT   SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT  SYSLOG+WALL
NOTIFYFLAG FSD      SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK   SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD  SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL
NOTIFYFLAG NOCOMM   SYSLOG+WALL+EXEC
NOTIFYFLAG NOPARENT SYSLOG+WALL

RBWARNTIME 43200

NOCOMMWARNTIME 600

FINALDELAY 5

Now:

erik@MinipcLG2:~$ systemctl status upsmon
● nut-monitor.service - Network UPS Tools - power device monitor and shutdown controller
     Loaded: loaded (/usr/lib/systemd/system/nut-monitor.service; enabled; preset: enabled)
     Active: active (running) since Wed 2024-11-06 14:40:27 CET; 11min ago
    Process: 1387 ExecStartPre=/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-common-tmpfiles.conf (code=exited, status=0/SUCCESS)
   Main PID: 1391 (upsmon)
      Tasks: 2 (limit: 9284)
     Memory: 2.5M (peak: 2.8M)
        CPU: 74ms
     CGroup: /system.slice/nut-monitor.service
             ├─1391 /lib/nut/upsmon -F
             └─1395 /lib/nut/upsmon -F

nov 06 14:40:27 MinipcLG2 systemd[1]: Starting nut-monitor.service - Network UPS Tools - power device monitor and shutdown controller...
nov 06 14:40:27 MinipcLG2 systemd[1]: Started nut-monitor.service - Network UPS Tools - power device monitor and shutdown controller.
nov 06 14:40:27 MinipcLG2 nut-monitor[1391]: fopen /run/nut/upsmon.pid: No such file or directory
nov 06 14:40:27 MinipcLG2 nut-monitor[1391]: Could not find PID file to see if previous upsmon instance is already running!
nov 06 14:40:27 MinipcLG2 nut-monitor[1391]: UPS: apcupskelder@localhost (primary) (power value 1)
nov 06 14:40:27 MinipcLG2 nut-monitor[1391]: Using power down flag file /etc/nut/killpower
nov 06 14:40:27 MinipcLG2 nut-monitor[1395]: Init SSL without certificate database
nov 06 14:40:27 MinipcLG2 nut-monitor[1395]: upsnotify: failed to notify about state 2: no notification tech defined, will not spam more about it

Unfortunately, even after a Linux reboot, still:

erik@MinipcLG2:~$ sudo upsdrvctl shutdown
Network UPS Tools - UPS driver controller 2.8.1
Network UPS Tools - Generic HID driver 0.52 (2.8.1)
USB communication driver (libusb 1.0) 0.46
select with socket: Invalid argument
Can't claim USB device [051d:0002]@0/0: Entity not found
upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it
Driver failed to start (exit status=1)

As requested:

erik@MinipcLG2:~$ ls -la /etc/nut
totaal 112
drwxr-xr-x   2 root nut   4096 nov  6 14:48 .
drwxr-xr-x 182 root root 12288 nov  6 03:30 ..
-rw-r--r--   1 root root    48 nov  2 18:01 hosts.conf
-rw-r-----   1 root nut     15 nov  2 16:42 nut.conf
-rw-r-----   1 root root  4156 nov  2 16:41 nut.example.conf
-rw-r-----   1 root root  4201 nov  2 16:41 upsched.example.conf
-rw-r-----   1 root nut    385 nov  2 18:01 ups.conf
-rw-r-----   1 root nut     20 nov  2 18:02 upsd.conf
-rw-r-----   1 root root  8247 nov  2 16:41 upsd.example.conf
-rw-r-----   1 root nut    116 nov  6 14:35 upsd.users
-rw-r-----   1 root root  9845 nov  2 16:41 ups.example.conf
-rw-r-----   1 root nut   1381 nov  6 14:35 upsmon.conf
-rw-r-----   1 root root 24344 nov  2 16:41 upsmon.example.conf
-rw-r--r--   1 root root  1120 nov  2 18:03 upssched-cmd.sh
-rw-r-----   1 root nut    745 nov  2 18:03 upssched.conf

EDIT
I don't understand how, but once, I got this:

erik@MinipcLG2:/etc/nut$ sudo upsdrvctl shutdown
Network UPS Tools - UPS driver controller 2.8.1
Network UPS Tools - Generic HID driver 0.52 (2.8.1)
USB communication driver (libusb 1.0) 0.46
Can't open /run/nut/usbhid-ups-apcupskelder: No such file or directory
HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be incorrect; interpreting LogMax -1 as 255 in ReportID: 0x0c
HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be incorrect; interpreting LogMax -1 as 255 in ReportID: 0x22
HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be incorrect; interpreting LogMax -1 as 255 in ReportID: 0x40
Using subdriver: APC HID 0.100
Initiating UPS shutdown
upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it

But trying it again, resulted in failure again:

erik@MinipcLG2:/etc/nut$ sudo upsdrvctl shutdown
Network UPS Tools - UPS driver controller 2.8.1
Network UPS Tools - Generic HID driver 0.52 (2.8.1)
USB communication driver (libusb 1.0) 0.46
select with socket: Invalid argument
Can't claim USB device [051d:0002]@0/0: Entity not found
upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it
Driver failed to start (exit status=1)

Puzzling...

@jimklimov
Copy link
Member

Looks cool about getting the driver and upsmon to play together, finally.

I think sudo upsdrvctl shutdown suffers from a similar conflict with a running driver. Would it show more clues if you try passing debug verbosity to this copy of the driver - sudo upsdrvctl -DDDDDD -d shutdown ?

I think with #1917 in NUT v2.8.1 the driver program should have tried to communicate with the previous instance over its local socket (same as communications with upsd), so the originally running program would remain connected to the UPS and pass it the shutdown command(s). Maybe select with socket: Invalid argument is about inability to find or use that local socket, so it tries from scratch (and for some reason does not try to kill off the earlier copy of the driver program - e.g. if it did not leave PID files)?

@jimklimov
Copy link
Member

Also note, that if you get sudo upsdrvctl shutdown to work, it would immediately (or close to that) power off the UPS, without telling the OS to shut down.

You may be after upsmon -c fsd instead, so it would initiate the shutdown, and if the OS integration works well, that would call sudo upsdrvctl shutdown in the endgame (when NUT daemons are all down, along with other services), with no conflict for a running driver.

@jimklimov
Copy link
Member

jimklimov commented Nov 6, 2024

Alternately, you can try sending commands to the UPS (using the admin account created earlier and upscmd client) directly.

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 6, 2024

Would it show more clues if you try passing debug verbosity to this copy of the driver - sudo upsdrvctl -DDDDDD -d shutdown ?

erik@MinipcLG2:~$ sudo upsdrvctl -DDDDDD -d shutdown
Network UPS Tools - UPS driver controller 2.8.1
   0.000000     [D1] upsdrvctl commanding all drivers (1 found): (null)
   0.000009     [D1] Shutdown UPS: apcupskelder
   0.000015     [D2] exec:  /lib/nut/usbhid-ups -a apcupskelder -k
   0.000106     [D2] Starting driver with debug but without explicit backgrounding: will not wait for it to fork and detach, continuing...
   0.000127     [D1] upsdrvctl: successfully finished
   0.000131     [D1] Completed the job of upsdrvctl tool, cleaning up and exiting now
   0.000136     [D1] Completed the job of upsdrvctl tool, clean-up finished, exiting now

The UPS didn't power cylce.

You may be after upsmon -c fsd instead, so it would initiate the shutdown, and if the OS integration works well, that would call sudo upsdrvctl shutdown in the endgame (when NUT daemons are all down, along with other services), with no conflict for a running driver.

erik@MinipcLG2:~$ sudo upsmon -DDDDD -c fsd
Network UPS Tools upsmon 2.8.1
   0.000000     [D1] Signaled old daemon OK

The Linux box shut down, but the UPS didn't power cycle...

Alternately, you can try sending commands to the UPS (using the admin account created earlier and upscmd client) directly.

You mean like so:

erik@MinipcLG2:/etc/nut$ upscmd -u admin -p indUStr*a apcupskelder shutdown.reboot
OK

?

Unfortunately, again no power cycle.

(I've got a table lamp lit, so a power loss should be visible.)

@jimklimov
Copy link
Member

Looking at current code for the driver, the command sequence in

nut/drivers/usbhid-ups.c

Lines 969 to 993 in d244d73

void upsdrv_shutdown(void)
{
upsdebugx(1, "upsdrv_shutdown...");
/* Try to shutdown with delay */
if (instcmd("shutdown.return", NULL) == STAT_INSTCMD_HANDLED) {
/* Shutdown successful */
return;
}
/* If the above doesn't work, try shutdown.reboot */
if (instcmd("shutdown.reboot", NULL) == STAT_INSTCMD_HANDLED) {
/* Shutdown successful */
return;
}
/* If the above doesn't work, try load.off.delay */
if (instcmd("load.off.delay", NULL) == STAT_INSTCMD_HANDLED) {
/* Shutdown successful */
return;
}
upslogx(LOG_ERR, "Shutdown failed!");
set_exit_flag(-1);
}
is hard-coded to try several options (whichever works). Can you see if your UPS picks up the others?

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 6, 2024

Can you see if your UPS picks up the others?

I assume you mean the other options mentioned in that Java code?

erik@MinipcLG2:/etc/nut$ sudo upscmd -u admin -p indUStr*a apcupskelder shutdown.return
Unexpected response from upsd: ERR CMD-NOT-SUPPORTED
erik@MinipcLG2:/etc/nut$ sudo upscmd -u admin -p indUStr*a apcupskelder shutdown.reboot
OK
erik@MinipcLG2:/etc/nut$ sudo upscmd -u admin -p indUStr*a apcupskelder load.off.delay
OK

No power cycle...

I also tried:

erik@MinipcLG2:/etc/nut$ sudo upscmd -u admin -p indUStr*a apcupskelder load.off
OK

But no effect on the lamp.

FYI:

erik@MinipcLG2:/etc/nut$ upscmd -l apcupskelder
Instant commands supported on UPS [apcupskelder]:

beeper.disable - Disable the UPS beeper
beeper.enable - Enable the UPS beeper
beeper.mute - Temporarily mute the UPS beeper
beeper.off - Obsolete (use beeper.disable or beeper.mute)
beeper.on - Obsolete (use beeper.enable)
driver.killpower - Tell the driver daemon to initiate UPS shutdown; should be unlocked with driver.flag.allow_killpower option or variable setting
driver.reload - Reload running driver configuration from the file system (only works for changes in some options)
driver.reload-or-error - Reload running driver configuration from the file system (only works for changes in some options); return an error if something changed and could not be applied live (so the caller can restart it with new options)
driver.reload-or-exit - Reload running driver configuration from the file system (only works for changes in some options); exit the running driver if something changed and could not be applied live (so service management framework can restart it with new options)
load.off - Turn off the load immediately
load.off.delay - Turn off the load with a delay (seconds)
shutdown.reboot - Shut down the load briefly while rebooting the UPS
shutdown.stop - Stop a shutdown in progress
test.battery.start.deep - Start a deep battery test
test.battery.start.quick - Start a quick battery test
test.battery.stop - Stop the battery test

@jimklimov
Copy link
Member

"OK" there means the command was accepted by the driver. Please try upscmd -w ... to wait for the result, maybe it would report more details.

It may also be that the device model/firmware does not actually support that command, or we poke a wrong USB endpoint for that (e.g. worked for other related devices but not this one).

@jimklimov
Copy link
Member

And that's plain old C code ;)

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 6, 2024

"OK" there means the command was accepted by the driver. Please try upscmd -w ... to wait for the result, maybe it would report more details.

erik@MinipcLG2:/etc/nut$ sudo upscmd -u admin -p indUStr*a -w apcupskelder shutdown.reboot
SUCCESS
erik@MinipcLG2:/etc/nut$ sudo upscmd -u admin -p indUStr*a -w apcupskelder shutdown.return
Unexpected response from upsd: ERR CMD-NOT-SUPPORTED
erik@MinipcLG2:/etc/nut$ sudo upscmd -u admin -p indUStr*a -w apcupskelder load.off.delay
SUCCESS
erik@MinipcLG2:/etc/nut$ sudo upscmd -u admin -p indUStr*a -w apcupskelder load.off
SUCCESS

But no effect on the lamp...

It may also be that the device model/firmware does not actually support that command, or we poke a wrong USB endpoint for that (e.g. worked for other related devices but not this one).

What would that mean for my setup? End of the line? Or are there more avenues to be walked? :)

@jimklimov
Copy link
Member

What would that mean for my setup? End of the line? Or are there more avenues to be walked? :)

Haven't got many ideas at the moment...

Is the lamp a heavy power-drawer (LED or incandescent)? Maybe the UPS does not notice it has any load, so decides to do nothing?

@desertwitch : You seem to have some recent experience with APC, any more ideas about why shutdown commands might not work?

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 6, 2024

Is the lamp a heavy power-drawer?

No, less than 6 W... But if all devices are shutdown before the UPS reboots, it wouldn't have any load at that moment either, right?

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 6, 2024

Also note, with an APC BX###MI device, #2565 and related issues and PRs may be relevant. That fix is not part of a released version yet though, so if you'd end up needing it before a release is cut and gets through distro packaging queues - a custom build would be required, e.g. per https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests

Could this have anything to do with it? That's too high level for me to understand. :)

@jimklimov
Copy link
Member

But if all devices are shutdown before the UPS reboots, it wouldn't have any load at that moment either, right?

That bit is up to UPS maker. More likely, this is one of devices where APC minimized support for USB HID in favor of Modbus. A chance remains that they moved the needed USB command to a different endpoint, though. You can find several ways of spelling same commands on different models at https://github.com/networkupstools/nut/blob/master/drivers/apc-hid.c#L424-L461 so another one would not be too surprising...

Could this have anything to do with it?

With the lack of shutdown - probably no.

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 6, 2024

More likely, this is one of devices where APC minimized support for USB HID in favor of Modbus.

Are you suggesting using the apc-modbus driver is a possible solution? Although... I read that I then should do something with the front panel of the UPS. But mine doesn't have a front panel...

A chance remains that they moved the needed USB command to a different endpoint, though. You can find several ways of spelling same commands on different models at https://github.com/networkupstools/nut/blob/master/drivers/apc-hid.c#L424-L461 so another one would not be too surprising...

How did these spellings got found? Not by just trying stuff, I hope? 😅 Maybe the "APC PowerShute" software can be read or something like that? I haven't tried that program yet, though...

@jimklimov
Copy link
Member

To a large extent, by increasing driver verbosity and/or using an -x explore subdriver option, so usbhid-ups program dumps all "USB HID reports" it sees, interspersed with how it understood (some of) them. You can see a currently open pull request about Eaton ECO mode for a glimpse of the approach.

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 7, 2024

To a large extent, by increasing driver verbosity and/or using an -x explore subdriver option, so usbhid-ups program dumps all "USB HID reports" it sees, interspersed with how it understood (some of) them.

I'm willing to dive into this, but I'd need a bit more guidance, I'm afraid. :)

You can see a currently open pull request about Eaton ECO mode for a glimpse of the approach.

I read the discussion, but I only see the content being discussed, not the way to discover 'driver commands' (or how it's called). However, I didn't click on any links, so maybe the answer lays there. I'll try to do that tomorrow (or 'later today', technically :)).

@jimklimov
Copy link
Member

jimklimov commented Nov 7, 2024

Well, at least trying apc_modbus might be worthwhile. One caveat is that it requires a custom build of both NUT and libmodbus (to add USB RTU support), see https://github.com/networkupstools/nut/wiki/APC-UPS-with-Modbus-protocol and https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests for links to pre-requisites and in-place build configuration.

Note you can run a driver program straight from the build workspace (via sudo probably, for actual device access) to test how it works, without changing the files installed by packaging until you are sure you like the new build better. The "in-place" configuration should have the new build use same paths and user accounts as whatever is installed, as much as feasible.

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 7, 2024

Well, at least trying apc_modbus might be worthwhile. One caveat is that it requires a custom build of both NUT and libmodbus (to add USB RTU support), see https://github.com/networkupstools/nut/wiki/APC-UPS-with-Modbus-protocol and https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests for links to pre-requisites and in-place build configuration.\n\nNote you can run a driver program straight from the build workspace (via sudo probably, for actual device access) to test how it works, without changing the files installed by packaging until you are sure you like the new build better. The "in-place" configuration should have the new build use same paths and user accounts as whatever is installed, as much as feasible.

I'll try to read up ASAP, in order to wrap my head around this. It's a bit our of my comfort zone :)

Are all those suggested commands run in the root directory? Or is it better practice to create a directory first? I assume the latter, but maybe that just breaks things... Is creating a virtual machine an idea? Although that maybe complicates things even more? Questions, questions! :)

@desertwitch
Copy link
Contributor

I'm not sure if the BX series, being rather entry-level, supports shutdown commands at all.
My Back-UPS Pro takes almost 2 minutes to shutdown after the command - how long did you wait?

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 7, 2024

how long did you wait?

A few seconds... :) I'll try waiting a few minutes!

I'm not sure if the BX series, being rather entry-level, supports shutdown commands at all.

That would make the endeavor pointless, of course... Maybe I can test it with APC's PowerChute software?

@ErikDB87
Copy link
Author

ErikDB87 commented Nov 7, 2024

Maybe I can test it with APC's PowerChute software?

@desertwitch, I tested this, and the UPS actually shut down (as also documented here). So there must be some command that the UPS understands to shut down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APC DDL impacts-release-2.8.1 Issues reported against NUT release 2.8.1 (maybe vanilla or with minor packaging tweaks) USB
Projects
Status: Todo
Development

No branches or pull requests

3 participants