`usbhid-ups` sucks CPU in a tight `select` loop (2.8.2+ later branch build)
USB UPS not supported by usbhid-ups, even explore subdriver reads it wrong. I've manually decoded input and feature reports and they fit.
usbhid-ups high cpu usage
Reverse engineering UPS battery status USB HID protocol with Linux
I had some fun this week with the UPS I installed to keep my Internet running in case of a power outage. I wanted to somehow monitor its status, without getting into third party tools, software, etc.
In the end, I managed to extract the data of interest with an ancient Raspberry Pi 2B and latest mainline Linux. With a tiny bit of userspace coding on top, that's all I needed!
I hope in general that the whole experience above of reverse engineering the USB HID-based protocols is useful to you.
Hello everyone, I’ve recently restored an old STD60S UPS from Control Systems to working condition. It’s a rather unknown brand, but they make good UPS units. I bought a Serial to USB adapter on Amazon to control my UPS, as it’s currently powering a Proxmox server. I discovered NUT (Network UPS Tools), which seems to be a great solution for managing my UPS in case of a power outage; specifically, I want to set it up so that if the batteries drop below 20%, the NUT system sends a shutdown signal to my Proxmox server.
I downloaded the “proprietary” software for this UPS on a Windows VM, and it works correctly after installing the software and the drivers for the Serial to USB converter. The issue is that I need to install the UPS monitor with NUT on the entire Proxmox node, but unfortunately, I’m not sure how to do it or which driver to use.
I’ve installed NUT on my Proxmox server, but when I run nut-scanner -U, no device is detected. I can’t find my UPS on the NUT compatibility list, although from what I understand, NUT works with most UPS units, even those that aren’t listed.
What driver would you recommend using with NUT for my UPS, which has serial port control, when using a Serial to USB cable?
I had a small fight with nixos to get my ups working so i thought i might share it. This configuration works on 23.05
configuration.nix
power.ups = {
enable = true;
mode = "netserver";
ups = {
usbups = {
driver = "usbhid-ups";
port = "auto";
description = "USB UPS";
summary = ''
override.battery.charge.low = 33
'';
};
};
};
environment.etc = {
"nut/upsd.conf".source = pkgs.writeText "upsd.conf"
''
LISTEN 127.0.0.1 3493
'';
"nut/upsd.users".source = pkgs.writeText "upsd.users"
''
[upsmon]
password = pass
upsmon primary
actions = set
actions = fsd
actions = test.panel.start
instcmds = ALL
'';
"nut/upsmon.conf".source = pkgs.writeText "upsmon.conf"
''
MONITOR usbups@localhost 1 upsmon pass primary
MINSUPPLIES 1
SHUTDOWNCMD "${pkgs.systemd}/bin/systemctl poweroff"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5
'';
};if you want to graph the details with grafana here is a working example with prometheus-nut-exporter:
services.grafana.enable = true;
services.grafana.settings.server = {
domain = "FQDN";
http_port = 2342;
http_addr = "127.0.0.1";
};
services.prometheus = {
enable = true;
port = 9001;
exporters = {
nut = {
enable = true;
port = 9006;
listenAddress = "127.0.0.1";
nutServer = "127.0.0.1";
};
node = {
enable = true;
enabledCollectors = [ "zfs" "systemd" "processes" ];
port = 9002;
};
};
scrapeConfigs = [
{
job_name = "nut";
metrics_path = "/ups_metrics";
params = {
ups = [ "usbups" ];
};
static_configs = [{
targets = [
"127.0.0.1:${toString config.services.prometheus.exporters.nut.port}"
];
labels = {
ups = "usbups";
};
}];
}
{
job_name = "node";
static_configs = [{
targets = [
"127.0.0.1:${toString config.services.prometheus.exporters.node.port}"
];
}];
}
];
};