[CentOS] 2 questions re UPS management

Tue Mar 19 22:36:45 UTC 2013
Gordon Messmer <yinyang at eburg.com>

On 03/19/2013 07:55 AM, Fred Smith wrote:
> All this without installing ANYTHING extra.

GNOME features power management software that handles common battery 
support.  The same software manages laptops that operate on battery and 
desktop PCs with a UPS.

> When I run this script from the commandline it works just fine. but when
> I turn off input power to the UPS it starts the  XP shutdown then within
> without waiting the specified length of time, initiates the shutdown
> of Linux. Once the shutdown is done, the UPS powers off, thereby killing
> the not-yet-shutdown windoze box.

If you run the script manually, you should expect to see the Windows PC 
shut down, then the Linux machine after 5 minutes, and the UPS should 
shut down with the Linux host.  Is that what happens?

It sounds like you have the Linux host on the UPS "master" port, which 
typically has to be configured specifically to behave the way that you 
describe.  One option that you might have is to configure the UPS not to 
turn off along with the master port, particularly if you have more than 
one PC on it.  Master ports should only be used if the UPS is powering a 
single PC and its peripherals (external disks, etc).

If you're not using a master port, then it sounds like the UPS is simply 
draining too quickly.  If you have a 500Va UPS, it's probably not going 
to support two PCs for five minutes.  Without knowing more about the UPS 
capacity and its load, we can only speculate, but it may be that GNOME 
is firing off the system shutdown script on power loss, then firing 
another shutdown when the available power reaches a critically low 
threshold, and then everything shutting off when there's no longer juice 
to support it (especially if you're testing this without giving the UPS 
24 hours to fully charge up).

Try turning off the Windows host and then pulling the UPS off of line 
power.  See how everything behaves when only the Linux host is running 
on the UPS.

> The shellscript does contain "#!/bin/sh" as its first line, but it is
> currently being invoked simply by the path to the script. when I get
> back to the office I'll try changing it to "/bin/bash /etc/powerfail"
> to see if that makes a difference, but I kinda don't expect it to.

It won't.

> So, I'm wondering how the underlying mechanism works, AND if anyone knows
> how (or even IF) it's possible to hand inittab a script to run instead of
> burying the necessary commands directly into the inittab entry.

Yes, I believe you're doing it correctly.

If you want the systems to shut down whether or not you're logged in, 
you'd need to install NUT and configure it to manage the UPS, and 
configure GNOME to not do so.

> Question #2:
> On the Centos 6.4 box at home, I haven't yet tried turning off power to
> the UPS to see if it actually shuts doown, but given that a UPS icon
> appears in the panel, and there are settings for what should happen
> when power fails, I expect it will.

If you're logged in, yes.  If you're not logged in, nothing is 
monitoring the UPS.

> The question here is: how does this magic all work?

GNOME!  It "just works"!

> We no longer have
> any entries in inittab to manage this, apparently we now use upstart
> to  manage the same things, and I've spent some time digging for man
> pages and looking around for upstart file(s) to find out how such
> events are handled, and so far I've not found anything specifically
> for a "powerfail" event.

Yeah, if you want a system that you have more control over, use NUT 
rather than GNOME.  You'll gain the added benefit of UPS support when no 
user is logged in at the console.