Planning an upgrade to Mac mini

Yeah, it’s kinda dumb to go from DC to AC to DC :-)

Just to followup to my own article…

For those unaware, power bank devices like the Jackery and EcoFlow are not actually UPSs. Connected devices are always powered by the battery and its power input (whether AC, solar or something else) only charges the battery.

There is no pass-through operation, so if your connected devices draw power faster than the battery can charge, the batteries will drain, even if it is charging from an AC outlet that can power your devices directly.

This isn’t necessarily a bad thing, but it’s very different from a UPS which should always be able to pass full power from the line to your devices (up to its capacity limit) without drawing from its batteries.

Different designs for different requirements.

1 Like

Just a followup.

Ethernet-based monitoring/management is typically done via the SNMP protocol. This is a common protocol used for remote management of all kinds of network equipment. Most servers (especially Unix/Linux-based, but also Windows) include support for the protocol, and UPS management software is usually available for these platforms.

Unfortunately, macOS does not have built-in SNMP and UPS manufacturers do not seem to provide Mac software at all - relying on Apple’s built-in capabilities, which are USB-only. Howard Oakley wrote about this recently as a part of a larger article about UPSs.

After a reply/response exchange on the article’s comments thread, I went to look at what APC (my favorite UPS vendor) offers, and was surprised to find that their Mac port of PowerChute (their monitoring software) is old, no longer supported, and incompatible with modern Macs. So you’re stuck using Apple’s built-in UPS monitoring. It’s functional, but minimal.

It should be possible to write an app that implements the SNMP support needed to communicate with a UPS, and it should be possible to use this to configure a UPS and get its status, but according to Oakley (see my comment and response in the above-cited article), even if you can do this, Apple does not make public the APIs necessary to properly initiate a system shutdown the way the built-in UPS software does. I suppose you could launch a shell and run a sudo shutdown -h now, but I don’t know if you could authorize the app for the root access needed to let this run. And you still wouldn’t be able to integrate it with Apple’s UPS system setting, which would be ideal.

It would be nice if Apple would make the necessary services available, but it would appear that they were deleted quite some time ago, so I wouldn’t expect them to come back any time soon.

2 Likes

As Howard mentions, CyberPower has the Powerpanel application, which they maintain regularly. It works great for me via a USB cable.

Yes, but that’s the USB interface, which Apple supports very well out of the box.

Ethernet-based monitoring is necessary if there are several computers connected to the UPS, which all need to shut themselves down during an outage. The USB interface simply can’t support that without some kind of application capable of distributing the data across the LAN. Either way, the client computers need the ability to initiate a shutdown in response to a power event from the UPS, and (according to Howard), macOS doesn’t provide the necessary APIs for a third-party app to do this.

I think it would be possible to have a script run by root crontab to check a status file delivered by the “SNMP-app” every minute and do a shutdown -h now.

I would think that would work, but I haven’t actually tried it. If you have an app trigger the shutdown, it would have to run as root. I assume you could play some games with /etc/sudoers to grant that app the ability to call shutdown.

For all I know, you may need to disable SIP in order to modify the system crontab or add a launch agent that can run as root. Stuff you could do when hacking a solution on your own system, but which wouldn’t work for a commercial product.

For the SNMP part, that should be easy. I’d just build Net-SNMP and use a script to run it against APC’s MIB, and have it start monitoring the UPS accordingly, either subscribing to a trap or poll for status.

Unfortunately, I don’t have free time, nor do I have a UPS with Ethernet/SNMP connectivity, so I can’t be the one to develop a solution, but my gut tells me that there has to be a way, even if the implementation is a bit ugly.

1 Like

Little known secret: even Mac desktops (iMac, Mac mini, etc.) can hibernate. They’re just not set to hibernate by default.

Use pmset -g | grep hibernatemode to view the current setting. Values are:

0: Normal sleep (no hibernation)
3: Write hibernation file before sleep, but don’t hibernate until power runs down
25: True hibernation: write hibernation file, then shut down.

0 is default for desktops, 3 for laptops. You can set via pmset -a hibernatemode 3

(Mode 25 didn’t work for my iMac in Mojave.)

You can even create a script that does a “safe sleep” one time. Have the script:

  1. pmset -a hibernatemode 3
  2. (sleep 60 && pmset -a hibernatemode 0) & pmset sleepnow

The way this works is:

  1. Turn on hibernation mode
  2. Pause for 60 seconds and then turn hibernation off, while…
  3. …simultaneously with #2, issue command to sleep now

When it powers back on, it resumes execution of the script, which is what resets the hibernation mode.

1 Like