Return to Level1Techs.com

UPS and Linux

I have an APC line interactive UPS. Originally it was for my desktop, but then I got a NAS so that became the primary device. I just built me a new desktop to replace the one I turned in to my Plex server. The QNap Nas I have allows me to send a signal via the network to alert other devices on the UPS to shut down. The issue is I could never to get this to work in Windows. Linux is a bit more flexible from what I have seen.

Is there a Linux solution? Preferably something that works in Ubuntu and popOS. The Plex server runs Ubuntu and I might move the NAS over near that, as all my media is on the NAS any way. The desktop will be running popOS.

4 Likes

https://wiki.archlinux.org/index.php/Network_UPS_Tools

So there’s this software, I’m not super confident how it works to shut down other servers/workstations, but that should get you started. (it’s distro agnostic, but I like the archwiki for most things)

1 Like

Thanks for the Link. I did look at it a bit, I think it might work. Ill play around with that over the weekend.

It would be pretty great if you report back about what you end up doing. As i have bin quite curious about Network UPS Tools myself.

1 Like

I will. This is a project for the weekend. When I really have time to dig in to it. Im hoping it goes well. :upside_down_face:

3 Likes

I can possibly write up a guide for Network UPS Tools, (NUT). Probably in about 6hours. Especially around dealing with random hard to Identify UPS models and getting a network connected UPS with monitoring, alerting and triggers set up.

2 Likes

With some bash tomfoolery…

If they’re all Linux servers the apcupsd daemon triggers the apccontrol script on an event. Could place an ssh shutdown command for each machine there.

ssh [email protected] shutdown now

It may be easier to use your user and add shutdown perms so you won’t need root to trigger a shutdown. Also ssh keys in this instance will avoid having to use passwords.

http://www.apcupsd.com/manual/manual.html#customizing-event-handling

4 Likes

Finally had a chance to look at this. Its a bit beyond me. I got it installed I believe. But now I gotta figure out how to configure it.

@SudoSaibot The issue is my UPS is connected to the Qnap Nas. The Nas has the ability to broadcast the UPS’s state over the network.

My bet is that the QNAP is using NUT (https://networkupstools.org/) for it UPS management. It is the defacto Linux UPS management software for any networked UPS management. NUT supports multiple UPS vendors. APC is supported but it is so/so. CyberPower is my go for low cost UPS with good NUT support.

I’ve looked in to that, but I’m new to Linux and have limited command line experience. I can get POP OS to see the UPS however but I cant configure what to do. I just need to tell it to shut down on loss of AC power.

apcupsd is your friend in this situation:

http://www.apcupsd.org/wordpress/about/

edit, beginners guide:

http://www.apcupsd.org/manual/manual.html#quick-start-for-beginners

Ive been thru that documentation. I just dont understand it. The UPS is connected to my NAS via USB. I know my machine can see the UPS with an app I downloaded thru the Pop OS store. I just dont know how to configure it to turn the PC off during power outage.

Post seven on this seems to be the way to go, using NUT and APCPSU.
UPS connected to NAS, which the sends shutdown to pc over the network

https://forum.qnap.com/viewtopic.php?t=33248

So that did something. I have a graphical version of NUT monitor installed that I got from the Pop OS store. It can see the UPS and I have access to it. Though its not clear how to tell the PC to shut down.

The fact is I have communication now. I have looked at the command line version of NUT monitor. They dont make it clear at least to me on how to configure it. I just want to my machine to shut down with in 2 min of a power outage, that is all.

I did figure out where the config files are located on my machine. Thats at least one step in the right direction. I know there is communication at least when the graphical version of NUT monitor is open.

What am I missing? I figured that with NUT monitor, it would keep an eye on UPS power events and act accordingly. That in a config file I would be able to set parameters of what the machine should do.

I did figure out that going to /usr/local/ups/sbin gets me to where the config files are. Or at least what I believe are the config files? It seems I cant edit anything here. Just locks up the machine.

By default NUT master will stay on battery power until there is the estimated 15 minutes left on the battery. Then it will start shutting down the master. If you have NUT slaves, they shut down immediately at power loss.