public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] Suggestions for Gentoo-compatable UPS; stores around Toronto??
@ 2024-08-18  3:48 Walter Dnes
  2024-08-18 12:00 ` Dale
  0 siblings, 1 reply; 7+ messages in thread
From: Walter Dnes @ 2024-08-18  3:48 UTC (permalink / raw
  To: Gentoo Users List

  My current manual hibernation script is...

#!/bin/bash
sync
sudo /usr/sbin/hibernate

  I have a Dell desktop PC and a DPMS-enabled monitor (turns off after
10 minutes).  I want a UPS that'll back them up and power down after
approximately 30 seconds or a minute without external power, i.e. send
the neccesary commands.  Linux driver obviously required.  Any
reccomendations?

-- 
There are 2 types of people
1) Those who can extrapolate from incomplete data


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] Suggestions for Gentoo-compatable UPS; stores around Toronto??
  2024-08-18  3:48 [gentoo-user] Suggestions for Gentoo-compatable UPS; stores around Toronto?? Walter Dnes
@ 2024-08-18 12:00 ` Dale
  2024-08-18 15:52   ` Walter Dnes
  0 siblings, 1 reply; 7+ messages in thread
From: Dale @ 2024-08-18 12:00 UTC (permalink / raw
  To: gentoo-user

Walter Dnes wrote:
>   My current manual hibernation script is...
>
> #!/bin/bash
> sync
> sudo /usr/sbin/hibernate
>
>   I have a Dell desktop PC and a DPMS-enabled monitor (turns off after
> 10 minutes).  I want a UPS that'll back them up and power down after
> approximately 30 seconds or a minute without external power, i.e. send
> the neccesary commands.  Linux driver obviously required.  Any
> reccomendations?
>


I've used CyberPower UPSs for a long time.  I have three of them, first
one dates back to around 2003, and all work great.  I've read APC is
another brand with good Linux support.  I think all of these use Nut for
the software. 

The one thing I wish I could figure out how to set up, once power is
lost, wait 2 minutes, maybe 5 minutes, then power off even if the
battery still has lots of power left.  The way the power works here, if
it is out for more than 10 seconds, it's going to be a hour or so until
whatever broke is fixed.  May has well shutdown if I'm not here.  I
don't think the UPS brand matters on this, I think it is Nut that needs
this feature.  So, I'd like to set things up the same as you.  Maybe
there is a way to do this and not drain the batteries down each time. 

I don't think you could go wrong with APC based on what I've read.  I
think you will find CyberPower to work well from my personal
experience.  I could share my config files if needed.  I think you would
have to change your hostname info or something but rest might work fine. 

Hope that helps. 

Dale

:-)  :-) 

P. S.  Your little script looks like something I'd come up with.  Simple
but works.  ;-)  LOL 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] Suggestions for Gentoo-compatable UPS; stores around Toronto??
  2024-08-18 12:00 ` Dale
@ 2024-08-18 15:52   ` Walter Dnes
  2024-08-18 19:11     ` Daniel Frey
  2024-08-18 21:06     ` Dale
  0 siblings, 2 replies; 7+ messages in thread
From: Walter Dnes @ 2024-08-18 15:52 UTC (permalink / raw
  To: gentoo-user

On Sun, Aug 18, 2024 at 07:00:52AM -0500, Dale wrote
> Walter Dnes wrote:
> >   My current manual hibernation script is...
> >
> > #!/bin/bash
> > sync
> > sudo /usr/sbin/hibernate

> The one thing I wish I could figure out how to set up, once power
> is lost, wait 2 minutes, maybe 5 minutes, then power off even if
> the battery still has lots of power left.

  I asked Mr. Google.  APCUPSD has an ONBATTERDELAY command that does
something only if the battery is in use (i.e. AC power is off) for at
least a certain specified length of time..

> P. S.  Your little script looks like something I'd come up with.  Simple
> but works.  ;-)  LOL 

  The solution for NUT appears to be to launch a countdown script rather
than do an immediate kill.  The examples I saw were exceedingly complex,
designed to handle all sorts of outlier cases.  Here's the barebones
simplest I think you can get away with.  It launches as soon as
ONBATTERY is detected.  It has a main loop that runs up to 60 seconds
(i.e. "sleep 1" x 60).  If it falls through the bottom of the loop
(counter = 0), it executes a "hibernate" (or "shutdown" if you prefer).
If if detects battery not in use (i.e. AC power back on) before
60 seconds, it'll exit entirely.  ***WARNING*** I HAVE NOT TESTED THIS
CODE.  I don't have a machine with a UPS running NUT

###################################################

in /etc/nut/upsmon.conf on client change to this

NOTIFYCMD "/etc/nut/countdown"
NOTIFYFLAG ONBATT EXEC

/etc/nut/countdown looks like so (counter = 60 ==> 60 seconds)

###################################################

#!/bin/bash
counter=60

while [ ${counter} -gt 0 ]
do
   output=$(upsc qnapups@192.168.222.252 ups.status)
   if echo "$output" | grep -q "OB"
   then
      sleep 1
      counter--
   else
      exit
   fi
done
/usr/sbin/hibernate

###################################################

NOTES:
* status output may change between versions
* adjust IP address as appropriate for your system
* make sure to mark the script executable
* you may have to set up and invoke sudo for "hibernate"
  or "shutdown" if the NUT daemon is not root

-- 
There are 2 types of people
1) Those who can extrapolate from incomplete data


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] Suggestions for Gentoo-compatable UPS; stores around Toronto??
  2024-08-18 15:52   ` Walter Dnes
@ 2024-08-18 19:11     ` Daniel Frey
  2024-08-18 21:06     ` Dale
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Frey @ 2024-08-18 19:11 UTC (permalink / raw
  To: gentoo-user

On 8/18/24 08:52, Walter Dnes wrote:
> On Sun, Aug 18, 2024 at 07:00:52AM -0500, Dale wrote
>> Walter Dnes wrote:
>>>    My current manual hibernation script is...
>>>
>>> #!/bin/bash
>>> sync
>>> sudo /usr/sbin/hibernate
> 
>> The one thing I wish I could figure out how to set up, once power
>> is lost, wait 2 minutes, maybe 5 minutes, then power off even if
>> the battery still has lots of power left.
> 
>    I asked Mr. Google.  APCUPSD has an ONBATTERDELAY command that does
> something only if the battery is in use (i.e. AC power is off) for at
> least a certain specified length of time..
> 

I've been using apcupsd with Gentoo for ages, more than 20 years. 
apcupsd is able to do what you want but as far as I know, there's no 
apc.shutdown unit for systemd - this will also shutdown the UPS itself.

Another thing to be aware of is that APC has a new protocol for their 
newer UPSes and I've not tried a newer one with apcupsd to see if it is 
supported. This may be a concern and will likely need more investigation.

Dan



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] Suggestions for Gentoo-compatable UPS; stores around Toronto??
  2024-08-18 15:52   ` Walter Dnes
  2024-08-18 19:11     ` Daniel Frey
@ 2024-08-18 21:06     ` Dale
  2024-08-19  0:27       ` Walter Dnes
  1 sibling, 1 reply; 7+ messages in thread
From: Dale @ 2024-08-18 21:06 UTC (permalink / raw
  To: gentoo-user

Walter Dnes wrote:
> On Sun, Aug 18, 2024 at 07:00:52AM -0500, Dale wrote
>> Walter Dnes wrote:
>>>   My current manual hibernation script is...
>>>
>>> #!/bin/bash
>>> sync
>>> sudo /usr/sbin/hibernate
>> The one thing I wish I could figure out how to set up, once power
>> is lost, wait 2 minutes, maybe 5 minutes, then power off even if
>> the battery still has lots of power left.
>   I asked Mr. Google.  APCUPSD has an ONBATTERDELAY command that does
> something only if the battery is in use (i.e. AC power is off) for at
> least a certain specified length of time..
>
>> P. S.  Your little script looks like something I'd come up with.  Simple
>> but works.  ;-)  LOL 
>   The solution for NUT appears to be to launch a countdown script rather
> than do an immediate kill.  The examples I saw were exceedingly complex,
> designed to handle all sorts of outlier cases.  Here's the barebones
> simplest I think you can get away with.  It launches as soon as
> ONBATTERY is detected.  It has a main loop that runs up to 60 seconds
> (i.e. "sleep 1" x 60).  If it falls through the bottom of the loop
> (counter = 0), it executes a "hibernate" (or "shutdown" if you prefer).
> If if detects battery not in use (i.e. AC power back on) before
> 60 seconds, it'll exit entirely.  ***WARNING*** I HAVE NOT TESTED THIS
> CODE.  I don't have a machine with a UPS running NUT
>
> ###################################################
>
> in /etc/nut/upsmon.conf on client change to this
>
> NOTIFYCMD "/etc/nut/countdown"
> NOTIFYFLAG ONBATT EXEC
>
> /etc/nut/countdown looks like so (counter = 60 ==> 60 seconds)
>
> ###################################################
>
> #!/bin/bash
> counter=60
>
> while [ ${counter} -gt 0 ]
> do
>    output=$(upsc qnapups@192.168.222.252 ups.status)
>    if echo "$output" | grep -q "OB"
>    then
>       sleep 1
>       counter--
>    else
>       exit
>    fi
> done
> /usr/sbin/hibernate
>
> ###################################################
>
> NOTES:
> * status output may change between versions
> * adjust IP address as appropriate for your system
> * make sure to mark the script executable
> * you may have to set up and invoke sudo for "hibernate"
>   or "shutdown" if the NUT daemon is not root
>


I think I get what your script does.  When Nut sees onbatt then it
executes your script because of the NOTIFYCMD option.  The script then
waits 60 seconds then executes what is under 'done'.  Could one change
the 60 seconds to say 300 seconds?  If I'm not here, it will have to
shut itself down.  If I'm here tho, I'd like to be able to stop it from
shutting down and shutdown manually.  I assume I could just kill the
script to stop it if I'm here. 

I've looked into this too in the past and it does seem more complicated
than it should be.  It should be as simple as a option that onbatt,
shutdown in 5 minutes unless power is returned or user stops it.  There
used to be a app called powstatd I think.  I used it on Mandrake
waaaaaaay back.  It would do that with a simple setting.  I don't know
why Nut has so much trouble with this.  Found its web page.

https://manpages.ubuntu.com/manpages/xenial/man8/powstatd.8.html

If only.  ;-) 

Dale

:-)  :-) 




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] Suggestions for Gentoo-compatable UPS; stores around Toronto??
  2024-08-18 21:06     ` Dale
@ 2024-08-19  0:27       ` Walter Dnes
  2024-08-19  1:10         ` Dale
  0 siblings, 1 reply; 7+ messages in thread
From: Walter Dnes @ 2024-08-19  0:27 UTC (permalink / raw
  To: gentoo-user

On Sun, Aug 18, 2024 at 04:06:41PM -0500, Dale wrote
> 
> I think I get what your script does.  When Nut sees onbatt then it
> executes your script because of the NOTIFYCMD option.  The script then
> waits 60 seconds then executes what is under 'done'.

> Could one change the 60 seconds to say 300 seconds?

  At the top of the script is the line "counter=60".  Change that to
"counter=300".  The script does a "sleep 1" (1 second delay) each pass
through the "while" loop.  Note that it also checks...

if echo "$output" | grep -q "OB"

...on each pass through the loop.  ***IF AC POWER IS RESTORED BEFORE THE
COUNTDOWN FINISHES*** the battery is no longer in use and the "if"
returns false.  It then executes the "else" portion of the loop on that
pass and exits the script without taking any action.  I don't want to
hibernate or shutdown for a short 5-second power blip.

-- 
There are 2 types of people
1) Those who can extrapolate from incomplete data


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] Suggestions for Gentoo-compatable UPS; stores around Toronto??
  2024-08-19  0:27       ` Walter Dnes
@ 2024-08-19  1:10         ` Dale
  0 siblings, 0 replies; 7+ messages in thread
From: Dale @ 2024-08-19  1:10 UTC (permalink / raw
  To: gentoo-user

Walter Dnes wrote:
> On Sun, Aug 18, 2024 at 04:06:41PM -0500, Dale wrote
>> I think I get what your script does.  When Nut sees onbatt then it
>> executes your script because of the NOTIFYCMD option.  The script then
>> waits 60 seconds then executes what is under 'done'.
>> Could one change the 60 seconds to say 300 seconds?
>   At the top of the script is the line "counter=60".  Change that to
> "counter=300".  The script does a "sleep 1" (1 second delay) each pass
> through the "while" loop.  Note that it also checks...
>
> if echo "$output" | grep -q "OB"
>
> ...on each pass through the loop.  ***IF AC POWER IS RESTORED BEFORE THE
> COUNTDOWN FINISHES*** the battery is no longer in use and the "if"
> returns false.  It then executes the "else" portion of the loop on that
> pass and exits the script without taking any action.  I don't want to
> hibernate or shutdown for a short 5-second power blip.
>

That's what I was thinking.  I just wish Nut had a easy way to do this. 
It would make things a lot simpler. 

Thanks.  Time to update backups. 

Dale

:-)  :-) 


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-08-19  1:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-18  3:48 [gentoo-user] Suggestions for Gentoo-compatable UPS; stores around Toronto?? Walter Dnes
2024-08-18 12:00 ` Dale
2024-08-18 15:52   ` Walter Dnes
2024-08-18 19:11     ` Daniel Frey
2024-08-18 21:06     ` Dale
2024-08-19  0:27       ` Walter Dnes
2024-08-19  1:10         ` Dale

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox