Skip to content

Using APCUPSD to monitor a locally connected UPS and a shut down event is triggered, OPNsense halts instead of powering off #5383

@lmoorez

Description

@lmoorez

Important notices

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

Describe the bug

When an appropriate event is seen by apcupsd and a shut down is initiated, the system shuts down and halts but remains powered on - see screen shot.

Unfortunately, pressing any key on the keyboard will not initiate a reboot. It appears the keyboard on the system is disabled when the system is halted, including PS2. To recover from this situation a hard-reset must be performed.

To Reproduce

Steps to reproduce the behavior:

  1. Ensure a monitor or serial port is connected to view Console output
  2. Attach a PS2 keyboard to the computer - reboot if necessary
  3. Go to 'System'
  4. Click on 'Firmware'
  5. Click on 'Plugins'
  6. Select 'os-apcupsd' and install
  7. Attach an APC Smart-UPS using a USB cable
  8. Go to 'Services'
  9. Click on 'Apcupsd'
  10. Click on 'Settings'
  11. Configure settings as per screen shot - UPS Name is not important.
  12. For testing purposes, ensure 'Battery Timeout Shutdown' is changed from the default of '0' to a low number such as '60'. Revert it to '0' after testing is complete.
  13. Click on 'Status'
  14. Verify UPS information is complete - see screen shot.
  15. Remove mains power to the UPS
  16. Observe OPNsense commences shutting down about a minute later and simply halt.
  17. Restore mains power to the UPS

Depending on the UPS device configuration, it may go to sleep after 'DHSUTD' period - see Services: Apcupsd: Status.
If the UPS does not get commanded to go to sleep during shut down and power is restored, OPNsense will remain at the screen awaiting some form of action before it can reboot - a PS2 keyboard is useless at this point.

Expected behavior

When apcupsd initiates a shut down, it should do so using '-p now'.

Reviewing the Makefile for the FreeBSD port of apcupsd (https://cgit.freebsd.org/ports/tree/sysutils/apcupsd/Makefile), the section beginning on line 84 appears to make a post-patch change to apccontrol.in by replacing;

'-h now'

with

'-p now'

Reviewing the installed /usr/local/etc/apcupsd/apccontrol, it appears the replacement did not occur:

Line 96 reads as;
	${SHUTDOWN} -h now "apcupsd initiated shutdown"

Manually replacing '-h now' with '-p now' at line 96 of /usr/local/etc/apcupsd/apccontrol, and with the same test scenario as above, the computer shuts down and powers off - the computer must support ACPI and it must enabled for this to work, as APM was removed from FreeBSD somewhere along the version 13 lineage.

Describe alternatives you considered

Don't use apcupsd.

Screenshots

Image Image Image Image

Relevant log files

N/A

Additional context

N/A

Environment

Software version used and hardware type if relevant, e.g.:

OPNsense 26.1.5 (amd64).
Intel® Core(TM) i7-7700 CPU @ 3.60GHz (3600.00-MHz K8-class CPU)
Network Intel® I350

OPNsense installed packages for apcupsd.
apcupsd-3.14.14_6 Set of programs for controlling APC UPS
os-apcupsd-1.2_3 APCUPSD - APC UPS daemon

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions