os-nut error: /usr/local/etc/rc.d/nut

Started by miracuru, August 27, 2025, 11:14:16 PM

Previous topic - Next topic
August 27, 2025, 11:14:16 PM Last Edit: August 27, 2025, 11:26:48 PM by miracuru
Hi

I try to setup os-nut to enable a graceful shutdown in case of power loss.
Therefore I've installed the os-nut plugin.

The USV isn't connected to my OPNsense device.
Therefore I need only the upsmon service.

I have entered all my credentials in
Services -> Nut -> Configuration -> UPS Type -> Net ClientAnd enabled the
Enable the Netclient driver
But I'm not sure if I need also to enable this?
Services -> Nut -> Configuration -> General Settings
If I leave it disabled, then I get the message: "Nut is not started. Click to configure Nut." at the dasboard main site.
When I enable it, I set the service mode to
netclientgive a name and listen to address = 0.0.0.0.

If I apply the settings, then I get this error message:
<13>1 2025-08-27T23:03:03+02:00 OPNsense.home configctl 32480 - [meta sequenceId="3"] event @ 1756328582.85 msg: Aug 27 23:03:02 OPNsense.home config[82791]: config-event: new_config /conf/backup/config-1756328582.8202.xml
<13>1 2025-08-27T23:03:03+02:00 OPNsense.home configctl 32480 - [meta sequenceId="4"] event @ 1756328582.85 exec: system event config_changed response: OK
<13>1 2025-08-27T23:03:03+02:00 OPNsense.home root 37789 - [meta sequenceId="5"] /usr/local/etc/rc.d/nut: WARNING: failed precmd routine for nut

Now I'm not sure If I should enable under
General Settings or not, and if I should enable it. What can I change to get rid of this error?
I have already found: https://forum.opnsense.org/index.php?topic=32100.15 and tested applying the mentioned patch at post #21. But I'm already post this patch.
What I get isthis, if I try so:

opnsense-patch -c plugins 16cbe99ebf
Found local copy of 16cbe99ebf, skipping fetch.
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|From 16cbe99ebf0e776afa5deee349f9e0ff73fbe8aa Mon Sep 17 00:00:00 2001
|From: Franco Fichtner <franco@opnsense.org>
|Date: Fri, 27 Jan 2023 08:43:17 +0100
|Subject: [PATCH] sysutils/nut: try to address breakage
|
|See: https://github.com/opnsense/ports/commit/d02ff345816e9
|---
| sysutils/nut/Makefile                                  | 2 +-
| sysutils/nut/src/opnsense/scripts/OPNsense/Nut/setup.sh | 6 ++++--
| 2 files changed, 5 insertions(+), 3 deletions(-)
|
|diff --git a/sysutils/nut/src/opnsense/scripts/OPNsense/Nut/setup.sh b/sysutils/nut/src/opnsense/scripts/OPNsense/Nut/setup.sh
|index 582348f059..2776cc9793 100755
|--- a/sysutils/nut/src/opnsense/scripts/OPNsense/Nut/setup.sh
|+++ b/sysutils/nut/src/opnsense/scripts/OPNsense/Nut/setup.sh
--------------------------
Patching file opnsense/scripts/OPNsense/Nut/setup.sh using Plan A...
Hunk #1 succeeded at 1.
done
All patches have been applied successfully.  Have a nice day.

Another question is:
How can I change the behaviour of nut?
I'm asking, because all files in
/usr/local/etc/nut have the warning: "Please don't modify this file as your changes might be overwritten with the next update.".





There is no error in the log you posted. It clearly says "WARNING" and is most probably harmless.

I run NUT on OPNsense as the master so I cannot help much more, but you should not dive into arbitrary actions like patching things just for a warning message. Does it work? Do you get an UPS status? If yes, great. If not, then we can try to dig deeper.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

August 29, 2025, 10:00:02 PM #2 Last Edit: August 29, 2025, 10:01:36 PM by miracuru
Dear Patrick

Thanks for your reply. I had now time to test the setup.

It worked correctly with this setup:
Under 'General settings' the option 'Enable nut' is turned off.
And under 'UPS Type' -> 'Net Client', just the credentials are entered.

Regarding the WARNING message:
Since I don't need to enable this option, I no longer see the warning.

The UPS is connected via USB to my physical Proxmox server, which acts as the master,
and OPNsense is only monitoring it using the setup described above.

I then cut the power, and everything worked perfectly. I had configured the master to shut down after one hour on battery or when the battery was low.
After one hour, it shut down correctly, and OPNsense also received the shutdown signal and powered down gracefully.

I had not previously understood that the master sends a shutdown signal via the 'upssched-cmd' script and that OPNsense would shut down as well.
I had thought I needed to configure OPNsense separately to shut down just before the master.
Therefore my prior questions.

But as the master sends the signal for powering down, I don't need to alter the configuration on the OPNsense slave device.
This makes the setup much simpler.

Best regards,
Simon

I am quite puzzled by the fact that you set your NUT service to "disabled" and things still seem to work.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

Sure I understand and please apologize. I've made a mistake. I forgot to restart the nut service.
Now on the second test the OPNsense server didn't gracefully shut down anymore. So you were completely right regarding the 'puzzeling'.

Short question. I'm not yet so familiar with FreeBSD.
I forgot the command which displayed this messages and don't find the command anymore currently.
It produced this messages:
<13>1 2025-08-27T23:03:03+02:00 OPNsense.home configctl 32480 - [meta sequenceId="3"] event @ 1756328582.85 msg: Aug 27 23:03:02 OPNsense.home config[82791]: config-event: new_config /conf/backup/config-1756328582.8202.xml
<13>1 2025-08-27T23:03:03+02:00 OPNsense.home configctl 32480 - [meta sequenceId="4"] event @ 1756328582.85 exec: system event config_changed response: OK
<13>1 2025-08-27T23:03:03+02:00 OPNsense.home root 37789 - [meta sequenceId="5"] /usr/local/etc/rc.d/nut: WARNING: failed precmd routine for nut

Another question. Since FreeBSD doesn't use systemd. What would be the equivalent for this linux command?
journalctl -f -u nut-driver -u nut-monitor -u nut-serverTo observe the messages from nut-monitor.

p.s.
I have re-enabled the NUT service again and further testing.

Alright. I've figured all out.

The Nut Service is now enabled. Since then it works fine again like described one or two posts ago.

I have also figured out the command which I searched before. It was just checking the file "/var/log/system/latest.log". Have looked previously not in the system subfolder.

Therefore only the WARNING message is left.
I guess, I just ignore it, because everything is working fine?