Hi, trying to figure out how the system manages UPS connections. On both Centos 5.9 and 6.4, merely plugging in a USB UPS device causes an icon to appear in the top panel, and (at least on 5.9, haven't yet tested this in 6.4) when the UPS suffers a power failure the system notices and after a bit does a clean shutdown.
All this without installing ANYTHING extra.
one of the UPSes I'm using is a tripplite (now on 6.4 x86_64, but formerly on the same machine with 5.9 i686), the other is a CyberPower UPS on a different 5.9 machine.
question #1: in 5.9 there are two entries in /etc/inittab, one for power fail and the other for power restoration. The default setting for the powerfail entry has it doing a shutdown in 2 minutes.
So, I need to tweak it a bit: that UPS powers two computers, the Centos 5.9 box and a Windows XP box. A little googling showed me how to use Samba tools to tell XP to do a shutdown. That works fine.
but if I add the command for that into the inittab entry I get an error message (when power fails) about the line being too long. So, I created a shellscript that runs both the command to tell XP to go down, followed by the shutdown command that tells Centos to shut down. I changed the two minute time to 5 minutes to make sure Windoze is all the way down even if it's busy.
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.
#!/bin/sh # # invoked by the poweroff clause in /etc/inittab instead of the command # originally in that place. This one also shuts down the Windoze box.
net rpc SHUTDOWN -C "System shutting down NOW due to power failure" -f -I 172.19.23.120 -U <myusername>%<mypassword> /sbin/shutdown -f -h +5 "Power Failure; System Shutting Down"
and here's the entry from inittab:
pf::powerfail:/etc/powerfail
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.
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.
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.
The question here is: how does this magic all work? 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.
Clues appreciated, thanks all!
Fred
Fred Smith wrote:
Interesting.... I haven't observed this behavior; certainly not on headless servers, though most are on UPSes; nor, when I had a working UPS for my workstation, have I seen it. Are you running gnome or KDE?
All this without installing ANYTHING extra.
You mean, like apcupsd?
<snip>
message (when power fails) about the line being too long. So, I created a shellscript that runs both the command to tell XP to go down, followed
<snip>
Thinking about this as I write, I'd guess that it expects the machine *receiving* the shutdown to respect the five minute wait. What you might want to do is a sleep 300 before sending the command. <snip>
mark
On Tue, Mar 19, 2013 at 11:10:07AM -0400, m.roth@5-cent.us wrote:
Yes, nor "nut" either.
just to be sure I'm clear: the shutdown command appears to be sent to windows, as I desire. then instead of honoring the "+5" in the local shutdown command it shuts down immediately.
but if I just run the identical script from a commandline it does exactly what I think it should: (1) tells windows to shut down then (2) waits 5 mins before shutting down Linux.
On Tue, Mar 19, 2013 at 12:44:37PM -0400, Fred Smith wrote:
sorry, I forgot to say: standard Centos-5 Gnome installation.
On Mar 19, 2013, at 9:44 AM, Fred Smith wrote:
---- sounds as if there is another daemon that is processing the signal from the UPS system and initiating the power down rendering the 5 minute wait in your script moot.
On Tue, Mar 19, 2013 at 01:25:27PM -0700, Craig White wrote:
Well, factor this in, then: the original powerfail entry in inittab was the same as the shutdown command in my script EXCEPT for the lengthy command that makes windows shutdown. It uses exactly the same "shutdown..." command, and as long as that command is inside inittab, when powerfail occurs, the pause also occurs. only when I move it out to the external script does the pause fail to happen.
On Mar 19, 2013, at 1:31 PM, Fred Smith wrote:
---- having the commands in an external script would fork a new process outside of the inittab so if it were me, I would simply join the commands to run as one within the inittab i.e..
/usr/bin/net rpc SHUTDOWN -C \ "System shutting down NOW due to power failure" \ -f -I 172.19.23.120 \ -U <myusername>%<mypassword> && \ /sbin/shutdown -f -h +5 \ "Power Failure; System Shutting Down"
I can't see /bin/sh or /bin/bash making any difference in the outcome anyway.
Craig
On Tue, Mar 19, 2013 at 01:55:11PM -0700, Craig White wrote:
I originally did that (I think my original posting mentioned that) without the backslashes, but when run it got an error message about line too long or something similar, so that's why I tried making it an external script.
Ah, I see you used "&&" whereas I just used a semicolon separator. wonder if it would make any difference.... (I understand that the "&&" causes the second command to be skipped if the first one fails, while the semicolon keeps it as two independent commands.)
I don't expect to be back there til Monday, but I'll try some of these variants when I get there. (I could VPN in and try it, but if something goes haywire, then I'm scrod for remote access.)
Fred Smith wrote:
Dunno if this affects it, but I just found a piece about shutting your XP system down from the command line, and a) he says order of switch matters, and b) gives this as an example... with *no* + sign, it's just seconds. shutdown -s -t 60
From http://samanathon.com/windows-tip-shutdown-your-computer-with-the-command-prompt/
mark
On Tue, Mar 19, 2013 at 05:14:45PM -0400, m.roth@5-cent.us wrote:
the plus sign goes in the linux shutdown command. Sorry if I wasn't clear.
Fred Smith wrote: <snip> #!/bin/sh # # invoked by the poweroff clause in /etc/inittab instead of the command # originally in that place. This one also shuts down the Windoze box.
net rpc SHUTDOWN -C "System shutting down NOW due to power failure" -f -I 172.19.23.120 -U <myusername>%<mypassword> /sbin/shutdown -f -h +5 "Power Failure; System Shutting Down" <snip> Hoold on thar: I just had some thoughts, and went back to look at your script... then the man page, then shutdown --help.
What's that undocumented -f do?
mark
Hello, I was reading the book Practical Common Lisp and wanted to use the same setup to follow along. Actually that might not be necessary as there are other tutorials on Lisp, so I just need, Emacs, SLIME, which I guess this is what provides the REPL, (it also had QuickLisp library manager - not sure how that is used yet) and the Clozure Common Lisp compiler. I tried a yum on anything with lisp in the name and didn't find anything. Perhaps I need a new repo. Anyway, I downloaded the Linux version of Lisp-in-a-box from user webadmin. So, it put it in the webadmin/downloads directory. I just noticed that the errors only show up if I run it from the bash shell. It says that some directories do not exist, specifically, /tmp/lispbox-0.7/emacs-23.2/libexec/emacs/23.2/x86-64-unknown-linux-gnu So, maybe I either need a desktop, or I develop on a different system and if I want to create web apps, I need to install lisp to run on the server. Can anyone offer some advice, please? I am wanting to install WebProtege, which is a Semantic Web Ontology modeling application that runs as a web app using Java. And I want to run another Java based application that runs not as a server app but a desktop app. So, somehow I need to give shell scripts or other apps the ability to create directories, such as tmp directories that are needed. Maybe that isn't an issue if you double click on the icon. Thanks in advance for any help and advice, Bruce
_______________________________________________________ Bruce Whealton - Web Design/Development/Programming Future Wave Web Development: http://futurewaveonline.com Developing for the Desktop as well as for Mobile Devices - Smartphones/Tablets Call 919-636-5809 _______________________________________________________
On Tue, Mar 19, 2013 at 05:25:11PM -0400, m.roth@5-cent.us wrote:
This is a Centos-5 system. here's an excerpt from its man page:
SYNOPSIS /sbin/shutdown [-t sec] [-arkhncfFHP] time [warning-message]
DESCRIPTION <snip>
OPTIONS <snip> -f Skip fsck on reboot. <snip> The -f flag means \u2018reboot fast\u2019. This only creates an advisory file /fastboot which can be tested by the system when it comes up again. The boot rc file can test if this file is present, and decide not to run fsck(1) since the system has been shut down in the proper way. After that, the boot process should remove /fastboot.
On Tue, Mar 19, 2013 at 12:44 PM, Fred Smith fredex@fcshome.stoneham.ma.uswrote:
http://www.networkupstools.org/
[ I had to look it up ... so hopefully this will help those other curious people out there. ]
19.3.2013 16:55, Fred Smith kirjoitti:
If you are using the default GNOME desktop, then that's the GNOME Power Manager: http://projects.gnome.org/gnome-power-manager/
The question here is: how does this magic all work?
It uses DBus and the UPower service. See: http://upower.freedesktop.org/
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.
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.
It won't.
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.
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"!
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.
On Tue, Mar 19, 2013 at 03:36:45PM -0700, Gordon Messmer wrote:
Yes. exactly that.
And, if I use the original inittab entry (which is just the shutdown command for linux, with a "+3" in it) it waits 3 minutes then shuts down.
I dunno what a "master port" is,... there's only one place to connect the USB cable to the UPS.
No, it's a 1500VA (900 W) ups. it powers two PCs, one monitor and one teeny little network switch. normal load is between 190-200 watts. It's got plenty of oomph to power both systems for at least 15 minutes.
so my puzzle remains: why does shutdown not honor the "+5" when it's part of a separate script, but does when it's not?
You think this mechanism only works when logged in? (I have no idea, I'm not doubting you, it's simply a thought I hadn't had--yet).
but that's probably not a problem, I'm logged in there pretty much 24 hours a day.
the C6 system is a personal desktop, at home, and it too is logged in most of the time. Last time I looked at nut, I found too many things I had to know in order to configure it that I didn't know, like it wasn't clear which nut device driver was correct for the tripplite UPS I had at the time, and some of the configurations (as far as I recall,... it's been several years) depended on which device it was. So after messing with it a while, and it not working, I just gave it up.
Thanks for the info, though.
Fred
On 03/19/2013 09:09 PM, Fred Smith wrote:
OK.
I dunno what a "master port" is,... there's only one place to connect the USB cable to the UPS.
The master port is a power port on the UPS. If configured to do so, the UPS will shut off all power ports when the device on the master port shuts off.
If you're actually using a master port, the Windows host and all other devices would be immediately turned off every time you power down the Linux host. That's one way to determine whether or not you are.
However, if you're not, then I'm not sure why the UPS would ever turn off. I'm almost completely certain that GNOME's power management cannot power off the UPS when the system halts. That feature is common to business class UPS management software, but not GNOME.
That's still a useful test, as is just shutting down the Linux host to see if the other equipment is turned off when the Linux host shuts off.
so my puzzle remains: why does shutdown not honor the "+5" when it's part of a separate script, but does when it's not?
My first guess would be that either the powerfail script is being executed as part of a shutdown, or that the powerfail script is being executed in addition to a shutdown.
I don't use GNOME power management, so I can't say that I've tested it. However, everything that I've read indicates that it only functions in the user shell. gdm's session may not run the power management code, or may not be configured to do anything on a low power state.
For USB attached UPSs, it's pretty straightforward.
nut.conf: MODE=standalone
ups.conf: [apc] driver = usbhid-ups port = auto
upsd.users: ... follow the examples to create an admin user, set passwords. I frequently use "uuidgen" to create passwords for these.
[admin] password = @PASSWORD@ allowfrom = localhost actions = SET instcmds = ALL upsmon master
upsmon.conf: MONITOR apc@localhost 1 admin @PSAASWORD@ master
On Wed, Mar 20, 2013 at 01:59:48AM -0700, Gordon Messmer wrote:
Gordon, thanks for the additional info. I'll experiment with these things as time permits, and if I learn anything interesting I'll generate a reply at that time.
Fred
<leaving the rest here for "historical record" purposes.>
On 03/20/2013 06:21 AM, Fred Smith wrote:
I hope to see it. :)
<leaving the rest here for "historical record" purposes.>
That's not really necessary. It's all in the archives already, and those have linked messages and threaded indexes for easy navigation. It's better to trim.
Thanks, Fred.
On 2013-03-20, Gordon Messmer yinyang@eburg.com wrote:
Do you have a specific example of a UPS that is explicitly documented to be configurable in this fashion? A quick DDG search didn't turn up anything for me (though I admit I didn't put huge effort in).
--keith
On 03/20/2013 11:19 AM, Keith Keller wrote:
Do you have a specific example of a UPS that is explicitly documented to be configurable in this fashion?
All of the non-rackmount APC UPSs I've seen in the last few years have a master outlet.
http://www.apcmedia.com/salestools/EALN-7SEGRP/EALN-7SEGRP_R6_EN.pdf
Search for "master", and read the section Operation/power-saving feature for information on configuring the UPS.
On Wed, Mar 20, 2013 at 12:37:54PM -0700, Gordon Messmer wrote:
the one in question (on the C5 box in my office) has no such labeling on its battery-backed-up outlets, so if it has a master outlet, it's undocumented.
I recall, from reading docs in either nut, or the apc package for linux (don't recall which) that many USB UPSes do have signalling between the UPS and the computer to tell the UPS to shut itself off when the system has gone offline. So, I've been assuming that's what is happening in my case.
On 03/20/2013 12:41 PM, Fred Smith wrote:
That's handled by /etc/init.d/halt. It only happens if you have nut or APC's software installed and configured. Take a look at the script, it's the last thing that happens if UPS management software is present. If not, then the system will try kexec or halt.
On 2013-03-20, Gordon Messmer yinyang@eburg.com wrote:
Great, thanks! I wouldn't see me using that feature myself, but I can see where a lot of people who really just want a desktop connected to a UPS might find it helpful.
The referenced manual seems to imply that the default setting for the master outlet is disabled, so it may not be the issue the OP is having.
--keith
On 03/20/2013 04:11 PM, Keith Keller wrote:
The referenced manual seems to imply that the default setting for the master outlet is disabled, so it may not be the issue the OP is having.
Yeah, but I'm not sure why else the UPS would shut off. CentOS won't do that unless nut or apcupsd is installed and configured.