Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 07-21-2021, 03:14 PM   #1
road hazard
Registered: Nov 2015
Posts: 199

Rep: Reputation: Disabled
Question How to shut down a server on my LAN when a power outage is detected?

I have my main server (Debian based) at the house here hooked up via USB to a UPS. When the battery level reaches critical, it's configured (via the Power Settings app) to shut down. As it's shutting down due to critical battery level, I want it to send a command to my hardware firewall (Untangle.... based on Debian) and instruct it to also shut down.

I was thinking about putting a SSH script in rc0.d to do this but realized that if I ever bring down the server to work on it, I will inadvertently trigger a shutdown of the Untangle box as well. So, I only want the Untangle box to shutdown when there is a power outage and the battery on my main server is critical. From reading around, NUT might accomplish this goal but isn't officially supported with Untangle so I'd rather look for another solution. Any ideas?

TLDR: How to fire off an SSH command from server A to server B, when server A's UPS battery level reaches critical.
Old 07-21-2021, 08:42 PM   #2
Registered: Mar 2008
Posts: 20,983

Rep: Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404
It isn't a ssh deal. Until I remember exactly I'll tell you this much.
My ups is connected usb to my nas. Nas runs linux. I set nas up as a server for telling lan computers to shutdown. As to how I'll have to study again. Something to do with ... Oh I forge.

"One UPS, multiple computers. Only one of them can actually talk to the UPS directly. That’s where the network comes in. The Master system runs the driver, upsd, and upsmon in master mode. The Slave systems only run upsmon in slave mode.

This is useful when you have a very large UPS that’s capable of running multiple systems simultaneously. There is no longer the need to buy a bunch of individual UPSes or "sharing" hardware, since this software will handle the sharing for you."

Last edited by jefro; 07-21-2021 at 08:54 PM.
Old 07-21-2021, 09:13 PM   #3
Registered: Aug 2002
Posts: 21,605

Rep: Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165
Gnome Power Manager is responsible for handling the UPS but as far as I know can not send a network message. You can switch to NUT or apcuspd whichever is supported by your UPS but as far as I know you can't have both controlling/accessing the UPS at the same time. But then again Untangle does not support either.

You can get the status of your UPS via the upower command i.e
upower -d (--dump)

Kind of clunky to use cron to status the UPS and send a command via to shutdown the firewall. I know apcupsd is capable of running a user script but not sure about NUT.

Last edited by michaelk; 07-21-2021 at 09:24 PM.
1 members found this post helpful.
Old 07-22-2021, 01:27 PM   #4
Senior Member
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora 33
Posts: 3,598

Rep: Reputation: 1027Reputation: 1027Reputation: 1027Reputation: 1027Reputation: 1027Reputation: 1027Reputation: 1027Reputation: 1027
Try running dbus-monitor and unplug power. Most Gnome notification stuff is done with dbus messages, so a simple python script monitoring messages could perform an action when it sees the power notification.
1 members found this post helpful.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to power down RP4/8GB board when it is shut down? rsamurti Slackware - ARM 2 01-27-2021 05:03 PM
shut down problem - wont shut down.. UbrInKid Linux - Newbie 4 12-10-2009 06:20 AM
Xubuntu won't shut down - black screen after trying to shut down Snickar-Lasse Ubuntu 2 11-30-2009 04:33 PM
RHEL 5 - Dell SC440 Server - shut down only displays ACPI Power Off Called wo2caisley Linux - Newbie 1 05-07-2008 09:13 PM
shut down won't shut system down taoweijia Linux - General 3 03-03-2004 06:05 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:11 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration