1826496 Members
3201 Online
109692 Solutions
New Discussion

Shutdown script

 
SOLVED
Go to solution
Leoanrdo Bowens
Advisor

Shutdown script

How do I create a script to shutdown more than 100 HP servers for a Power Outage?
Excuses are tools of the incompetent.
10 REPLIES 10
Victor BERRIDGE
Honored Contributor

Re: Shutdown script

I tried (you know Y2K ...)
Its not a good idea, at least the way I did it, I used rdist thinking it would do the job in parallel but it didnt and it took ages, great fun though! when you realize it will take to much time and its fatster by connecting yourself on all machines to reboot.
It will wait for the system to come up again and shut it down again...
Rick Garland
Honored Contributor

Re: Shutdown script

If you have a UPS, ie, Liebert, They have a package that will detect the loss of power and begin the orderly shutdown of the systems.

There must be some UPS in use because if not and power is lost, the systems would not have power and the script would not run.
Antoanetta Naghiu
Esteemed Contributor

Re: Shutdown script

I would agree with Victor. Shutdown, I think is a command that should be issued manually.

If you still want to automate it, schedule a cron job in each machine that is doing the shutdown at... condition.
Mark Mitchell
Trusted Contributor

Re: Shutdown script

You should be able to do it by setting up a terminal with HP UPS MANAGER II. The product can communicate with many servers to shutdown power in case of an emergency or even if the server isn't being used. There are a ton of features with the product.
Leoanrdo Bowens
Advisor

Re: Shutdown script

I do not have the time to purchase new s/w products to shutdown the servers. The systems have to be halted with a script and then manually powered off before the power outage occurs.
Excuses are tools of the incompetent.
Antoanetta Naghiu
Esteemed Contributor

Re: Shutdown script

Beside cron (or at) schedule, sam offer you the possibility to shutdown the system. (under Routine task->system shutdwon. Also, sam had an option (I never used it) Run SAM on Remote System.... You might try to schedule it like that....
I'm not sure about exactly topic, but for sure, here in forum they were discutions about shutdown. Do a search in forum for shatdown as a search key... It might give you a better idea....
Good luck.
Mark Mitchell
Trusted Contributor

Re: Shutdown script

The software I was talking about came with each of my UPS units. I don't know if you have to pay for it. Sam will also do this, keep in mind that if you have seperate disk arrays that the shutdown order will coincide with the software shutting down. Before, I put our ERP shutdown command in the HP shutdown script and made sure that the server went down first.
Tim Malnati
Honored Contributor

Re: Shutdown script

I can't say that I agree with the philosophy that I've read so far in this thread. To my way of thinking you are better off automatically trying to shutdown these machines. The alternative would be 100 machines with potentially corrupt data if all of them suddenly lost power. I doubt you want to live at the office 24 x 7 and I doubt you could get the shutdown commands issued manually before the UPS dies.

First, you need a machine setup to monitor the UPS and invoke another script to command a shutdown on the effected machines. How this is scripted is largely dependent on the communication requirements of the UPS. The monitoring script should be running as root. The command shutdown script should read a list of configured hosts and remsh a remote command on all the hosts. Be sure to spawn these off as background tasks so that they all process in parallel (make sure your kernel configuration can handle 100 spawned processes too). I prefer to have a script invoked on the remote machine which does the actual shutdown command instead of trying to pass arguments through with remsh. This allows you to tailor the script on the remote system for the needs of the particular machine and will work in an environment of different machine flavors (HPUX, Linux, etc). This script should be owned by root and not visible to other users. You are probably better off setting up trusts for remsh instead of trying to maintain an ever changing list of passwords.

Shannon Petry
Honored Contributor
Solution

Re: Shutdown script

I can sympathize with your needs. Here is what can be done. NOTE that this does NOT handle monitoring the UPS to see when there is a power outage. My UPS software came with my UPS, and from a Master server, each machine can be downed. I would not recommend this on machines with direct connects to the Inet for security reasons.
1. Setup /var/adm/inetd.sec and CLOSE everything to unknown hosts. Most things can be closed for local hosts too, but....(It is better to use TCP Wrappers, but inetd.sec is already there!)
2. Setup a /.rhosts on each machine, with a single entry for the master server which will issue the shutdown command.
3. Make a list by OS of hosts which need to be rebooted.
4. Make the script, which knows each OS shutdown command. Like
down.hp=`/etc/shutdown -hy now`
down.sun=`/sbin/init 0'
Then loop the commands by OS.
for HOST in `cat down.hp` ;do
remsh $HOST "$down.hp"
done
for HOST in `cat down.sun` ; do
remsh $HOST "$down.sun"
done
Of course this very rough, and could be cleaned up as well. Also, root must allowed to enter without console on SunOS as well.
ANyway, the idea works, but is not very secure. As someone else mentioned, make sure root is the only one who can see, and excecute the script, and lists. Also, log the script like crazy! "I'd hate to be the test site for this one! :)

Best regards,
Shannon
Microsoft. When do you want a virus today?
Stefan Schulz
Honored Contributor

Re: Shutdown script

I have a script which does pretty much what you are looking for. It can be triggerd by hand or by the UPS Software.

You have to replace the getws script which is a selfmade script to get the desired hostnames.

Also the script isdead just tests if the Workstation is alive (this saves some time).

What the script does is pretty simple.

- get a list of workstations to shutdown
- test if the workstation is alive
- kill any process you wish
- shutdown the workstation except myself
- at least shutdown the workstation this script is running on.

Keep in mind what the others said about security.
No Mouse found. System halted. Press Mousebutton to continue.