plugins icon indicating copy to clipboard operation
plugins copied to clipboard

sysutils/nut: Diagnostics --> UPS Status is empty in service mode standalone

Open Starkstromkonsument opened this issue 3 years ago • 10 comments

Important notices Before you add a new report, we ask you kindly to acknowledge the following:

  • [x] I have read the contributing guide lines at https://github.com/opnsense/plugins/blob/master/CONTRIBUTING.md
  • [x] I have searched the existing issues, open and closed, and I'm convinced that mine is new.
  • [x] The title contains the plugin to which this issue belongs

Describe the bug I previously had the nut plugin running in service mode netclient and changed to standalone now because I connected my UPS directly via USB now. Under NUT --> UPS Type --> Netclient I only unchecked the enabled-checkbox but did not empty the other fields. This resulted in the UPS Status page being empty.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'NUT --> Configuration --> General Settings'
  2. Check 'Enable Nut'
  3. Switch 'Service Mode' to 'standalone'
  4. Set 'Name' to 'ups'
  5. Click on 'Apply'
  6. Go to 'NUT --> Configuration --> UPS Type --> Netclient'
  7. Uncheck 'enable'
  8. Enter some valid IP-Address in 'IP Address', e.g. '10.20.10.20'
  9. Click on 'Apply'
  10. Go to 'NUT --> Diagnostics --> UPS Status'
  11. See empty page

Expected behavior Show the correct UPS status for '[email protected]', although an IP-Address is configured under 'NUT --> Configuration --> UPS Type --> Netclient', when Netclient is 'disabled' and/or 'service mode' is 'standalone'.

Relevant log files 'System --> Log Files --> Backend', e.g.:

2022-02-19T17:20:05 | Error | configd.py | [57265914-fd05-4dca-863f-bb098703c008] Script action failed with  Command '/usr/local/bin/upsc '[email protected]'' returned non-zero exit  status 1. at Traceback (most recent call last):   File  "/usr/local/opnsense/service/modules/processhandler.py", line 478, in  execute     subprocess.check_call(script_command,  env=self.config_environment, shell=True,   File  "/usr/local/lib/python3.8/subprocess.py", line 364, in check_call      raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError:  Command '/usr/local/bin/upsc '[email protected]'' returned non-zero exit  status 1.
-- | -- | -- | --

Additional context https://github.com/opnsense/plugins/blob/c526550c15bf1ad8efbaef819ed1b98daf71d286/sysutils/nut/src/opnsense/mvc/app/controllers/OPNsense/Nut/Api/DiagnosticsController.php#L41-L44

Environment OPNsense 22.1.1_3-amd64 FreeBSD 13.0-STABLE OpenSSL 1.1.1m 14 Dec 2021

Starkstromkonsument avatar Feb 19 '22 16:02 Starkstromkonsument

And what happens when you remove all configs? Usually its empty If it doesnt receive data.

mimugmail avatar Feb 19 '22 17:02 mimugmail

Emptying 'IP Address' solves the problem. It took me some time to figure that out though. I recommend adding an additional check for $mdl->netclient->enabled

Starkstromkonsument avatar Feb 19 '22 18:02 Starkstromkonsument

This code is only for DiagnosticsController, it won't prevent false user handling. Maybe some constraints in the model would help here.

mimugmail avatar Feb 19 '22 18:02 mimugmail

IMHO unchecking the 'enabled' checkbox for netclient and expecting the rest of the settings on this page to be ignored is no false user handling.

image

The only other place these settings seem to be used is the template for upsmon.conf

https://github.com/opnsense/plugins/blob/c526550c15bf1ad8efbaef819ed1b98daf71d286/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/upsmon.conf#L9-L13

The value of ''OPNsense.Nut.netclient.enable' ' is checked there. Why not add a similar check to the DiagnosticsController too to fix this bug? I'll be happy to submit a PR if you agree.

Starkstromkonsument avatar Feb 20 '22 21:02 Starkstromkonsument

Sure, thx :)

mimugmail avatar Feb 21 '22 13:02 mimugmail

I can confirm that this bug exists, and I was just fighting it for a while after going through the same process. I had been using nut in netclient mode and then switched to local USB connection, but didn't delete the old config out of the netclient "driver" section (but I did uncheck "enable" for netclient).

Thanks to Starkstromkonsument for figuring this out!

ZPrimed avatar Jul 14 '22 06:07 ZPrimed

@Starkstromkonsument are you still working on a PR for it?

mimugmail avatar Jul 14 '22 08:07 mimugmail

Hi, no sorry. I startend working on it, ran into a problem and lost track.

Starkstromkonsument avatar Jul 15 '22 14:07 Starkstromkonsument

Any update on this?

I just installed nut, accidentally "enabled" USB when I really needed netclient. "Unenabled" USB and "enabled" netclient and nothing is happening. Presumably still looking for a "USB". The logs said.

netclient connect failed: Connection failure: Operation already in progress

Daniel-dev22 avatar Aug 04 '22 10:08 Daniel-dev22

@Starkstromkonsument are you still working on a PR for it?

Didn't see a pr for this so I assume it's still an unresolved issue?

Daniel-dev22 avatar Aug 12 '22 17:08 Daniel-dev22

This issue has been automatically timed-out (after 180 days of inactivity).

For more information about the policies for this repository, please read https://github.com/opnsense/plugins/blob/master/CONTRIBUTING.md for further details.

If someone wants to step up and work on this issue, just let us know, so we can reopen the issue and assign an owner to it.

OPNsense-bot avatar Aug 18 '22 15:08 OPNsense-bot

I can confirm that this bug exists, and I was just fighting it for a while after going through the same process. I had been using nut in netclient mode and then switched to local USB connection, but didn't delete the old config out of the netclient "driver" section (but I did uncheck "enable" for netclient).

Thanks to Starkstromkonsument for figuring this out!

Were you able to find a way to fix this? Not fixed for me.

Daniel-dev22 avatar Aug 22 '22 19:08 Daniel-dev22