Operating System - HP-UX
1843342 Members
3243 Online
110214 Solutions
New Discussion

Re: tapping remote UPS to shutdown

 
yc_2
Regular Advisor

tapping remote UPS to shutdown

Hi,

Currently, we have a K-class machine that comes with UPS. The UPS shutdown the server after a power failure that does not resume.

I'm thinking of making use of this feature to shutdown some HP workstations without support of UPS via remote shell. Is it possible? If so, how to achieve it.


Rgds,
YC
8 REPLIES 8
Leif Halvarsson_2
Honored Contributor

Re: tapping remote UPS to shutdown

Hi
I think this is possible. I don't know exact how your UPS works but there must be some scripts which shut down the server at powerfail. You have to find this script and add some lines before the server shutdown.


remsh workstation1 shutdown -y 0
sleep 30
remsh workstation2 shutdown -y 0
sleep 30
remsh workstation3 shutdown -y 0
sleep 30

"server shutdown"
yc_2
Regular Advisor

Re: tapping remote UPS to shutdown

Hi,

the UPS is from HP - PowerTrust. Correct me if I'm wrong, the UPS is using ups_mond daemon to monitor the power line.

Is there a way to customise the daemon to execute a remote command before it executes a shutdown to its local machine?


Rgds,
YC
Leif Halvarsson_2
Honored Contributor

Re: tapping remote UPS to shutdown

Hi
This is what I find in the man page for ups_mond. What is not clear is when ups_mond uses shutdown -h and when it uses reboot. If shutdown -h is used you only have to create a "ordinary" shutdown script in /sbin/init.d and link this to /sbin/rc1.d. Example:

In /sbin/init.d:
create a script which shutdown your workstations and call it for example "stopwork", make it executable.

In rc1.d
ln -s /etc/init.d/stopwork K150stopwork

Have a look at the scripts in /sbin/init.d to get an idea about how this scripts should be created.

####### from man ups_mond ###############
ups_mond logs messages, and when appropriate invokes
/usr/sbin/shutdown using the -h option, or /usr/sbin/reboot. For each
configured UPS, ups_mond can be instructed (in /etc/ups_conf) to log
messages only, without taking shutdown or reboot action. See MSG_ONLY
in ups_conf(4). By default ups_mond performs the shutdown and reboot
actions.
Pete Randall
Outstanding Contributor

Re: tapping remote UPS to shutdown

YC,

Normal ups_mond operation invodes "shutdown" when AC power is lost. "Reboot" is invoked if there is an error condition with the UPS, i.e. "battery low", "current overload", "temperature too high", or "cannot exec shutdown due to " (among others). So the idea of a shutdown script that would invoke the remsh command to shut down your workstations should work.

Pete

Pete
Leif Halvarsson_2
Honored Contributor

Re: tapping remote UPS to shutdown

Sorry
Of course the link should be:
ln -s /sbin/init.d/stopwork K150stopwork


Jim Walls
Trusted Contributor

Re: tapping remote UPS to shutdown

There is a problem using a kill script from /sbin/rc1.d... you may not want to shut down the workstations during a "scheduled" shutdown for maintenance! How can one discriminate between a "normal" shutdown and a "UPS" initiated shutdown?

my 2 bits worth!
Jim
Leif Halvarsson_2
Honored Contributor

Re: tapping remote UPS to shutdown

Hi

One metod could be if the script check for a temporary file (for example /tmp/dont_stopwork). If this file exists the workstations is not shutdown. If you want to shutdown the server but not the workstations you create this file first (touch /tmp/dont_stopwork). If you use this metod you should add in the /sbin/init.d/stopwork to remove the temporary file at startup and add a link in the /etc/rc2.d directory too.
Darren Prior
Honored Contributor

Re: tapping remote UPS to shutdown

To add to Jim and Leif's solutions - I'd suggest that your workstation shutdown script would need to parse syslog for the appropriate message from ups_mond to check whether the system is being shutdown normally or by ups_mond. The man page for ups_mond contains a list of these messages.

regards,

Darren.
Calm down. It's only ones and zeros...