Avatar of Gilberto Sanches
Gilberto SanchesFlag for Suriname

asked on 

UPS Guides for (Linux) Servers

Hi experts,

I have been using UPSs for a while now but just realized that I am not using it properly.

We have the power cables of 2 entrée level tower servers, both running Linux,
connected on a 1000 VA APC Ups.
It keeps the server online on power outages, but when the outage is too long it doesn't turn of the servers. Led to 1 entrée server not powering on (power supply damaged).

What tips, guides or resources can I use to put UPSs in a server environment to better use?
Think about the UPS software/configuration, the types of connection the UPS needs, the type of UPS suited for this environment etc etc.
LinuxNetworking

Avatar of undefined
Last Comment
Gilberto Sanches
Avatar of Scott Silva
Scott Silva
Flag of United States of America image

There is a software for Linux called NUT https://networkupstools.org/https://networkupstools.org/. It works with quite a few UPS brands and models... Maybe you can get it going for your needs.
Avatar of arnold
arnold
Flag of United States of America image

Look at ApC support download for powerchute which is their app..
1000VA USB cable is through .....

Check the server settings for behavior on restore of power.

If the power supply fails, the ups was not the cause.
ASKER CERTIFIED SOLUTION
Avatar of noci
noci

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of MURUGESAN N
MURUGESAN N
Flag of India image

@Scott Silva

Proceed as per the given comments from Scott/...

After reading your query I was thinking one more way (how ever it requires 3 systems => 1 windows an 2 Linux)

@ 1 windows system using batch file or cygwin:
obtain the value of BATTERY_PERCENTAGE_AVAILABLE using
C:\Windows\System32\wbem\wmic.exe Path Win32_Battery Get EstimatedChargeRemaining
Assume that the usage is:
EstimatedChargeRemaining
20


When this value is 20 send a signal to running application (example signal/sigaction using C/C++) which is waiting for signal at Linux system
Once receiving that signal make required action at Linux.


Just thought of sharing information which I am following from 2012
my personal HP laptop power battery has gone.
It made me to spend 4500.00 to buy new power battery.
Due to that started following using cygwin at windows:

%USERPROFILE%\AppData\Roaming\Microsoft\Windows\STARTM~1\Programs\Startup\LaptopBattery.vbs
LaptopBattery.vbs
invoking LaptopBattery.sh
LaptopBattery.sh using
/cygdrive/c/Windows/System32/wbem/WMIC.exe Path Win32_Battery Get EstimatedChargeRemaining
Assign that output to a variable
if the value of that variable is letss than or equal to 20 open
/cygdrive/c/Windows/system32/taskmgr.exe
OR
/cygdrive/c/PROGRA~2/Intern~1/iexplore.exe

Use taskmgr.exe if opening taskmgr.exe not having administration privileges.

After 2012 I never faced this issue yet.
Also started following this vbs .sh file in 2 personal laptops.

you can following same way and replace taskmgr.exe => otherapp.exe or script / batch at windows to send related signal to Linux.
Either signal to Linux
or
logon to Linux using ssh.exe (automation login ) at windows => to Linux and create a file at Linux system required directory.
At Linux system execute a script in a loop.
If a file being created, handle required action at Linux related to power/server/...

Let me know your comment if any ?
Avatar of MURUGESAN N
MURUGESAN N
Flag of India image

@Scott Silva

a)
Content of LaptopBattery.sh => We can change .sh to required .bat or .cmd also
#!/bin/bash
while [ 1 ]
do
        BATTERY_PERCENTAGE_AVAILABLE=$(/cygdrive/c/Windows/System32/wbem/WMIC.exe Path Win32_Battery Get EstimatedChargeRemaining |\
        /bin/grep -E "[0-9]" |\
        /usr/bin/tr -d "\r")
        if [ $BATTERY_PERCENTAGE_AVAILABLE -le 20 ]
        then
                /cygdrive/c/Windows/system32/taskmgr.exe >/dev/null 2>&1 &
        elif [ $BATTERY_PERCENTAGE_AVAILABLE -ge 98 ]
        then
                /cygdrive/c/Windows/system32/taskmgr.exe >/dev/null 2>&1 &
        fi
        /bin/sleep.exe 300
done

Open in new window

b)
Content of LaptopBattery.vbs
Set WshShell = CreateObject("WScript.Shell" )
WshShell.Run chr(34) & "FullPath\LaptopBattery.CMD" & Chr(34), 0
Set WshShell = Nothing

Open in new window

c)
content of LaptopBattery.CMD
either using .sh file
or .CMD file (contents of batch file)
@ECHO OFF
START /B Drive:\cygwin\bin\bash.exe "FULLPATH\LaptopBattery.sh"

Open in new window

Avatar of noci
noci

@MURUGESAN: laptop? laptopbattery? Windows? (you are the one that mentions it...?).....
This is about a linux server connected to a UPS... (which is quite a different setup).

Querying UPS's is quite something different. (if possible) some only indicate through the "modem control" lines in a serial cable:
on-line (aka power available) / off-line (no power available)   using fe. Carrier Detect signal
Battery sufficient / insufficient f.e. using CTS/RTS signals.
Those lines can be used to trigger interrupts to cause faster response in systems.  And could be used to trigger at a preset level so the system knew before the fatal point when to start shutdown.   On some models the actual power/ battery levels / read/write triggerpoint could be done using send/rcve wires.
Avatar of Gilberto Sanches

ASKER

Hey Scot, thanks for the recommendation. Seems good, I was only familiar with Apcupsd.

I will test the app.

@Arnold - I found the PowerChute software only works in a windows environment.

@Noci - turn off other server via SSH is a great idea. And even the PDU.

@ MURUGESAN, thanks for the scripts. Made me aware of another possibility.
Avatar of MURUGESAN N
MURUGESAN N
Flag of India image

@Gilberto Sanches

>> thanks for the scripts.
Most welcome.
I can understand your/noci comments.
I am not writing following comment to get points?

Need to know comments on any assisted solution or knowledge transfer ?
Avatar of Gilberto Sanches

ASKER

Hi experts, how would the script look like for the master server to turn off the slave(s) computers via SSH ?

A script that only shuts down it's slaved based on the UPS trigger.
So manually turning off the master server shouldn't automatically turn of the slave(s) servers.
Avatar of noci
noci

Like below:
#!/bin/bash
ssh shutdownuser@remotehost shutdown -h now

Open in new window

This assumes:
* there is anetwork path between the master & slaves
* you setup certificate logon from the UPS account to the remote shutdownuser account.
* On the remote host you make sure the shutdownuser account is allowed to start the shutdown command.

The above script needs to be setup in the ups shutdown actions.  so mention it in the upsmon config as part of the SHUTDOWNCMD setting.

With the NUT upsd you can also listen for another system to issue a signal.
Avatar of Gilberto Sanches

ASKER

Thank you very much Noci
Networking
Networking

Networking is the process of connecting computing devices, peripherals and terminals together through a system that uses wiring, cabling or radio waves that enable their users to communicate, share information and interact over distances. Often associated are issues regarding operating systems, hardware and equipment, cloud and virtual networking, protocols, architecture, storage and management.

102K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo