OPNsense Forum

English Forums => 25.1, 25.4 Production Series => Topic started by: paul_ on March 31, 2025, 06:32:38 PM

Title: [SOLVED] NUT-Plugin (Network UPS Tools) not working
Post by: paul_ on March 31, 2025, 06:32:38 PM
Hi everyone,

I have a new APC BR900G-GR UPS, and I want to set up my OPNsense as the NUT server to manage shutdowns for my two servers and the firewall in the event of a power outage. I've tried configuring it with both the USBHID-Driver and APCSMART-Driver, but neither seems to provide any data, and the Diagnostics page remains empty.
What I can see is that nut_daemon isn´t starting(see attached picture) - is there any log I could check?

If anyone has any suggestions or insights, it would be greatly appreciated.

Thanks & best regards,
Paul
Title: Re: NUT-Plugin (Network UPS Tools) not working
Post by: sja1440 on March 31, 2025, 07:16:54 PM
I am not using version 25.1 (I use 24-19-2) but I believe that the OPNsense NUT plugin can only take one of two roles: standalone or netclient. On my version I see this as the help text of 'Service Mode' on Services->Nut->Configuration->General Settings.

I believe that this means that nut on OPNsense can only be the Secondary and not the Primary (using the definitions from RFC 9271 (https://www.rfc-editor.org/rfc/rfc9271.html)). Though of course it can be used in Standalone mode.

I don't believe that you can do what you ask.

Title: Re: NUT-Plugin (Network UPS Tools) not working
Post by: Patrick M. Hausen on March 31, 2025, 07:46:14 PM
If you configure it as standalone you can use it as a server for other clients.

Use a NAT port forwarding rule for port 3493 on the interface where you have clients, forward to 127.0.0.1. Works great.
Title: Re: NUT-Plugin (Network UPS Tools) not working
Post by: paul_ on March 31, 2025, 07:58:19 PM
Quote from: Patrick M. Hausen on March 31, 2025, 07:46:14 PMIf you configure it as standalone you can use it as a server for other clients.

Use a NAT port forwarding rule for port 3493 on the interface where you have clients, forward to 127.0.0.1. Works great.

I configured it like this, but still I can´t see anything in Diagnostics...Port Forwarding is also configured
Title: Re: NUT-Plugin (Network UPS Tools) not working
Post by: iRobot on March 31, 2025, 08:33:44 PM
Check the usb-type, only one entry must be ticked.

Best regards
Stefan
Title: Re: NUT-Plugin (Network UPS Tools) not working
Post by: paul_ on March 31, 2025, 08:45:57 PM
Quote from: iRobot on March 31, 2025, 08:33:44 PMCheck the usb-type, only one entry must be ticked.

Best regards
Stefan
These are my settings, and I only ticked one, but it still doesn´t work. LAso with port auto it didn´t work.


Best regards
Paul
Title: Re: NUT-Plugin (Network UPS Tools) not working
Post by: Patrick M. Hausen on March 31, 2025, 10:33:59 PM
Two different things. First you need to get your communication with the UPS up and running, then you can connect other clients.

Can't help with the former, sorry. I use Cyberpower SNMP based communication throughout. Too many problems with USB.
Title: Re: NUT-Plugin (Network UPS Tools) not working
Post by: OPNenthu on April 01, 2025, 12:17:47 AM
Try adding "pollonly=enabled" in USBHID-Driver settings as a first tweak.  I remember reading somewhere that it helps with certain models, and this option can be set directly from the NUT plugin UI.

Some other suggestions I came across might require you to go into config files:

ups.conf: Add the global driver options to the top of the file: "pollinterval = 2" and "maxretry = 3".  The former might be default but the latter defaults to 1 (at least in the Debian nut package).  Might have to play with these.

upsmon.conf: Add "DEADTIME 25" (again might have to play with this, it should be a multiple of POLLFREQ) and try toggling "RUN_AS_USER root" by commenting/uncommenting it. The latter is mentioned in https://forum.netgate.com/topic/149032/must-the-ups-nut-daemon-be-run-as-root/3.

Sorry if these waste your time. I had initial instability connecting my CyberPower to a Raspberry Pi with usbhid (connection kept flapping), but a combination of these fixed it.  I haven't taken the time to isolate.
Title: Re: NUT-Plugin (Network UPS Tools) not working
Post by: EricPerl on April 01, 2025, 01:10:31 AM
Side note: most Cyberpower models have 2 flaws that I consider critical for a UPS.
1. they usually fail to report that the batteries are no longer up to their task. A self-test or power outage in that state will end up with the unit powering off.
2. they won't start if they are not connected to a functioning power outlet. IOW, forget about turning the unit off at night in case of long outage. You won't be able to turn it back on until power is restored.

Since connecting my APC UPS to OPN was on my to-do list, I took the opportunity to look at the docs.
The NUT site seems to recommend auto for the port, possibly filtering on other criteria in cases where multiple UPS are used.
Title: Re: NUT-Plugin (Network UPS Tools) not working
Post by: OPNenthu on April 01, 2025, 07:18:59 AM
Quote from: EricPerl on April 01, 2025, 01:10:31 AMSide note: most Cyberpower models have 2 flaws that I consider critical for a UPS.
1. they usually fail to report that the batteries are no longer up to their task. A self-test or power outage in that state will end up with the unit powering off.

Can confirm this one from recent experience. Battery tests were passing and runtime under load was reporting 20+ minutes, but in practice during a couple recent power cuts I barely got 4-5 minutes (not enough when VMs are running).  Replaced the batteries but no longer trust the metrics and thinking I should set the clients to shutdown early rather than on a battery charge threshold.
Title: Re: NUT-Plugin (Network UPS Tools) not working
Post by: Patrick M. Hausen on April 01, 2025, 12:08:25 PM
Quote from: EricPerl on April 01, 2025, 01:10:31 AM1. they usually fail to report that the batteries are no longer up to their task. A self-test or power outage in that state will end up with the unit powering off.

I run weekly battery tests and switch the batteries every couple of years. Usually after twice the recommend interval the very latest. Haven't experienced that problem, yet.

Quote from: EricPerl on April 01, 2025, 01:10:31 AM2. they won't start if they are not connected to a functioning power outlet. IOW, forget about turning the unit off at night in case of long outage. You won't be able to turn it back on until power is restored.

That's bad. Definitely going to test - thanks.

But it wasn't my intention to discuss the merits or lack thereof of Cyberpower vs. APC. ;-)
In fact in the history of our company we have had more outages due to failing APC units than due to a real loss of power.

Pick your poison - it's always a mess as soon as "real hardware" gets involved.
Title: Re: NUT-Plugin (Network UPS Tools) not working
Post by: paul_ on April 01, 2025, 07:32:13 PM
Quote from: OPNenthu on April 01, 2025, 12:17:47 AMTry adding "pollonly=enabled" in USBHID-Driver settings as a first tweak.  I remember reading somewhere that it helps with certain models, and this option can be set directly from the NUT plugin UI.

Some other suggestions I came across might require you to go into config files:

ups.conf: Add the global driver options to the top of the file: "pollinterval = 2" and "maxretry = 3".  The former might be default but the latter defaults to 1 (at least in the Debian nut package).  Might have to play with these.

upsmon.conf: Add "DEADTIME 25" (again might have to play with this, it should be a multiple of POLLFREQ) and try toggling "RUN_AS_USER root" by commenting/uncommenting it. The latter is mentioned in https://forum.netgate.com/topic/149032/must-the-ups-nut-daemon-be-run-as-root/3.

Sorry if these waste your time. I had initial instability connecting my CyberPower to a Raspberry Pi with usbhid (connection kept flapping), but a combination of these fixed it.  I haven't taken the time to isolate.


With this in ups.conf it´s running now :-) - Thanks for your help!

[USV-Keller]
driver=usbhid-ups
pollonly=enabled
port=auto

Just one more thing where can I setup the user I can access NUT? I want to add it to Homeassistant now, but it asks for a user.

Thanks!
Title: Re: NUT-Plugin (Network UPS Tools) not working
Post by: paul_ on April 01, 2025, 07:55:59 PM
Quote from: paul_ on April 01, 2025, 07:32:13 PM
Quote from: OPNenthu on April 01, 2025, 12:17:47 AMTry adding "pollonly=enabled" in USBHID-Driver settings as a first tweak.  I remember reading somewhere that it helps with certain models, and this option can be set directly from the NUT plugin UI.

Some other suggestions I came across might require you to go into config files:

ups.conf: Add the global driver options to the top of the file: "pollinterval = 2" and "maxretry = 3".  The former might be default but the latter defaults to 1 (at least in the Debian nut package).  Might have to play with these.

upsmon.conf: Add "DEADTIME 25" (again might have to play with this, it should be a multiple of POLLFREQ) and try toggling "RUN_AS_USER root" by commenting/uncommenting it. The latter is mentioned in https://forum.netgate.com/topic/149032/must-the-ups-nut-daemon-be-run-as-root/3.

Sorry if these waste your time. I had initial instability connecting my CyberPower to a Raspberry Pi with usbhid (connection kept flapping), but a combination of these fixed it.  I haven't taken the time to isolate.


With this in ups.conf it´s running now :-) - Thanks for your help!

[USV-Keller]
driver=usbhid-ups
pollonly=enabled
port=auto

Just one more thing where can I setup the user I can access NUT? I want to add it to Homeassistant now, but it asks for a user.

Thanks!


Nvm found it under: /usr/local/etc/nut/upsd.users

Thanks for the help to all of you :-)