hello,
i just installed a new vmware esxi 4 server with the free standalone server license.
i have an apc ups and i need to buy a smart slot ethernet card to be able to monitor ups status in an vm.
after searching around i found out that the ghettoShutDown.pl script does not work because of the restrictions of perl in the free licensed version.
but we are able to enable ssh. it is unsupported but not illegal. i rather have a legal esxi version with no support on it than a supported illegal version.
after looking around in the forums i found out that the available scripts were not that good.
so i made my own....
save it on a vmfs volume. create ssh password less login and let apc daemon on a linux virtual machine fire up this script.
what is basically does: get list of all vm's on machine.
loop through that list to shutdown all vm's. loop will be run at least 1 time. it waits a specified interval to check if all machines are down. of not... power it down the hard way....
have fun using it.....
Thanks Mate,
This is such a good way to try autoshutdown when the power is going through UPS.
Kind Regards,
AWT
thanks for the credit,
hmmm perhaps it is a good way to build in a max loop count.... the chance it will go into an infinite loop is almost 0, but i will put it in and post it again.
Hi Helux:
Are you invoking the script from a VM that's going to be shutdown as part of the script? lamw created one for me for the 3.5 free version that works similarly to the one that you wrote, but since I was invoking it from a VM that was going to be shutdown I had to do it this way (via putty from a Windows VM):
"C:\program files\putty\plink" ESXi -l root "nohup ./usr/script/upsshutdown.sh &"
I had to use the nohup and the & at the end in order to keep it going when the invoking VM (and consequently the SSH session) was terminated. Are you running it from the management VM, or from some other one, perhaps running on a different ESXi host? I just got a box with ESXi 4.0 on it, so I'm going to have to figure out how to port my script, which is why I asked. I also read something about a change in ESXi 4.0 that required changes to the scripts from 3.5 in order to make them work, and since your script is working on 4.0 I thought I'd just replace mine with yours. It looks like your script is starting the shutdown on all the active VMs at the same time rather than doing them serially, which was something that I needed in mine too so that the shutdown didn't take so long.
mudtoe
I solved this problem using the web SOAP interface, full details here:
And subsequent discussion here:
http://communities.vmware.com/thread/244790?start=50&tstart=0
Please award points to any useful answer.
Many thanks for your script! I've tested it (by directly running it on my ESXi server) and it works a treat.
I have a Ubuntu VM that monitors the UPS status. How do I go about getting this to run the script on the ESXi server when the UPS signals? I have the script saved on the ESXi server to /sbin/apcShutdown.sh
Many thanks,
HT
Hello kerry,
You can create a shell script that connects to the esxi server and runs the /sbin/apcShutdown.sh script.
I monitor the ups from a win2k3 server and have a batch file that connects to the esxi server and runs the shutdown script:
C:\plink.exe root@esxi.local -pw ****** /vmfs/volumes/swap/scripts/custom.sh
I use plink since win2k3 doesn't have a native ssh client like linux. But you get the idea, I'm sure you can whip up a shell script for your ubuntu vm ups monitor.
Also you should put your scripts in your datastores, I tried putting a script within the /sbin/ directory and on restart it would disappear. Maybe just me..
Good luck!
Hi All,
These two scripts are very useful.So I am trying to use one of them. I have Windows and Linux guest installed on ESXi4.0. So when I am executing esxi-off.sh script.it is performing the shutdown for guest and host also but shutting down only those guest on which VMware Tool is installed.
So I am trying to execute the other poweroff-esxi4.sh script. When I am executing it from ESXi itself, it is working fine but when I am trying to execute it remotly, It is throwing the following error and unable to connect--
C:\Demo>putty.exe root@ESXi_IP_Address -pw ESXI_Password -m c:\Demo\powerdown-esxi4.sh
Error: Server unexpectedly closed network connection.
but In the case of esxi-off.sh,it is working fine and shutting down guest and host.
C:\Demo>putty.exe root@ESXi_IP_Address -pw ESXI_Password -m c:\Demo\esx-off.sh
So Please provide me your suggesations...
Hi Helux,
I improved a little bit your script and I wrote an How-To in vm-help.com forum
http://www.vm-help.com/forum/viewtopic.php?f=16&t=2950
If you have improved something in USB UPSes management too, tell us!
Thanks for your work
Massimo
On my ESXi5.0 server i have some virtual appliances that are running oracle that cannot be shut down hard. You need to SSH to them, login, shutdown the application and the shutdown the server. Also these appliances are not running vmtools. Do you think it would be possibly to script this type of action?