[vi-admin@vima-ups-dev ~]$ ./ghettoShutdown.pl
Required command option 'ups_vm' not specified.
Synopsis: ./ghettoShutdown.pl OPTIONS
Command-specific options:
--sleep
The amount of time (secs) to wait after a guestOS shutdown (default 15 secs)
--ups_vm (required)
The name of VM that is monitoring your UPS
Common VI options:
--config (variable VI_CONFIG)
Location of the VI Perl configuration file
--encoding (variable VI_ENCODING, default 'utf8')
Encoding: utf8, cp936 (Simplified Chinese), iso-8859-1 (German), shiftjis (Japanese)
--help
Display usage information for the script
--passthroughauth (variable VI_PASSTHROUGHAUTH)
Attempt to use pass-through authentication
--passthroughauthpackage (variable VI_PASSTHROUGHAUTHPACKAGE, default 'Negotiate')
Pass-through authentication negotiation package
--password (variable VI_PASSWORD)
Password
--portnumber (variable VI_PORTNUMBER)
Port used to connect to server
--protocol (variable VI_PROTOCOL, default 'https')
Protocol used to connect to server
--savesessionfile (variable VI_SAVESESSIONFILE)
File to save session ID/cookie to utilize
--server (variable VI_SERVER, default 'localhost')
VI server to connect to. Required if url is not present
--servicepath (variable VI_SERVICEPATH, default '/sdk/webService')
Service path used to connect to server
--sessionfile (variable VI_SESSIONFILE)
File containing session ID/cookie to utilize
--url (variable VI_URL)
VI SDK URL to connect to. Required if server is not present
--username (variable VI_USERNAME)
Username
--verbose (variable VI_VERBOSE)
Display additional debugging information
--version
Display version information for the script
| superion.primp-industries.com | |
|---|---|
| SQL-PROD-01 | Powered On |
| Quentin | Powered Off |
| air_raid | Powered On |
| skydive | Suspended |
| fireflight | Powered Off |
| slingshot | Powered On |
| devastator.primp-industries.com | |
|---|---|
| VIMA-UPS-DEV | Powered On |
| bonecrusher | Powered Off |
| master_mix | Suspended |
| quickMigrate-X | Powered Off |
| scavenger | Suspended |
| hook | Powered On |
| long_haul | Powered On |
sudo rpm -ivh apcupsd-3.14.5-1.el5.x86_64.rpm
doshutdown)
echo "UPS ${2} initiated Shutdown Sequence" | ${WALL}
/home/vi-admin/upsVIShutdown.pl
${SHUTDOWN} -h now "apcupsd UPS ${2} initiated shutdown"
;;
[vi-admin@vima-ups-dev ~]$ ./upsVIShutdown.pl
[vi-admin@vima-ups-dev ~]$ cat /tmp/upsShutdown.log
04-25-2008 11:17:52 -- Found ESX/ESXi host: superion.primp-industries.com!
04-25-2008 11:17:52 -- Begin shutdown process ...
04-25-2008 11:18:07 -- VM: slingshot shutdown succssfully.
04-25-2008 11:18:22 -- VM: air_raid shutdown succssfully.
04-25-2008 11:18:37 -- VM: silverbolt shutdown succssfully.
04-25-2008 11:18:37 -- VM: skydive is already suspended.
04-25-2008 11:18:37 -- VM: fireflight is already off.
04-25-2008 11:18:44 -- VM: SQL-PROD-01 hard poweroff succssful (No VMware Tools, bad admin).
04-25-2008 11:18:44 -- VM: Quentin is already off.
04-25-2008 11:18:44 -- HOST: superion.primp-industries.com is shutting down!
04-25-2008 11:18:49 -- Found ESX/ESXi host: devastator.primp-industries.com!
04-25-2008 11:18:49 -- Begin shutdown process ...
04-25-2008 11:18:49 -- VM: scavenger is already suspended.
04-25-2008 11:18:49 -- VM: bonecrusher is already off.
04-25-2008 11:18:49 -- VM: master_mix is already suspended.
04-25-2008 11:18:56 -- VM: scrapper hard poweroff succssful (No VMware Tools, bad admin).
04-25-2008 11:19:04 -- VM: long_haul hard poweroff succssful (No VMware Tools, bad admin).
04-25-2008 11:19:11 -- VM: hook hard poweroff succssful (No VMware Tools, bad admin).
04-25-2008 11:19:11 -- VM: quickMigrate-X is already off.
04-25-2008 11:19:12 -- Shutting down final host: devastator.primp-industries.com and UPS VM: VIMA-UPS-DEV!
==============================================================================================
What's the proper "document" link for setting up the apcupsd.conf file? The current link points to an rpm file. Thanks.
It should be: http://viops.vmware.com/home/docs/DOC-1341
I've updated the document, this document primarily covers the setup of vMA and the shutdown scripts. The apcupsd conf is covered in Joesph's VIOPS documentation, it utilizes this script.
This looks like a useful script.
Is there a reason why you do each guest individually (issue shutdown, sleep, power off)?
If you have a lot of VMs then this could take a while, especially if you need to extend the timeout because of (say) an Exchange Server.
Can you shutdown more than one machine at a time - I was thinking along the lines of:
foreach (vm)
issue shutdown
done
sleep (some time to allow all machines to shutdown)
foreach (vm)
power off
done
shutdown host
hi all...i don't know why but it seems to work on vima 1.0 but not on vma 4.0...
In vma 4.0 i have comunications lost problem..
Any help?
thk
Alessandro
This was written when ESX(i) 3.5 and VIMA 1.0 was available (also described in the requirements). I've not had the cycles to verify against ESX(i) 4.0 and vMA, it should work but I've not tested and have not advertised this script to support vMA 4.0
Hey,
So I've got a simple test setup going:
As mentioned, vMA 4.0 has not been tested and it probably won't work due to the updated paths to some of the vCLI scripts.
VIMA 1.0 is definitely hidden, since vMA 4.0 is what VMware wants everyone to use. Through some digging, I found the download page: http://www.vmware.com/support/developer/vima/vima10/vima10relnotes.html The download link is in the middle of the page
Awesome, downloading now.
If I could figure out how to award points for "correct" or "helpful" (as per your sig) I most definitely would!
I'll let you guys know how it works out.
Jon
As promised, I have returned with results.
OK, so I can confirm that this works in both vMA 1.0 -AND- vMA 4.0
The difference is in the version of ESXi that you're trying to do the remote shutdown command on.
ESXi 3.5u3 (build 123629) will respond to the shutdown command with no issues
ESXi 3.5u4 (build 153875) will completely ignore the command
From the vMA console, the output of the perl script is identical. The only difference is the result.
I suspect that this is a licensing thing. I'm using the "Free" license for both u3 and u4, and I figure they probably took away the ability to do that in the "Free" version of u4.
So now you folks have a confirmed case of it working with vMA 4.0 + ESXi 3.5u3, and a confirmed case of it not working with 3.5u4 no matter which vMA you're using!
I hope this helps someone out... And I hope we can find a way to get this working on the later versions or I'm going to have to start hunting for "old" hardware when we want to build new ESXi servers!
Jon
Hello everyone,
I tried the same under esxi 4.0 single server (i.e. the free version) and
scripts work, the problem is power chute signal from UPS.
I tried to test my apc 8000 and it doesn't work.
It is a communication problem from vmware-guest and UPS.
I check firewall but it seems ok.
With vime-1.0, all ok.
thk
ciao
Alessandro
Hi,
just to produce no cliffhanger:
I decided to swap from ESXi 4.0 to ESX 4.0, because I some other reasons to do so.
PowerChute Network Shutdown 2.2.1 works fine with ESX 4.0.
Michael
Hello
I have followed all of the instruction to the letter but I am not having any luck. From what I have been reading ESXi 3.5.0, 123629 will respond to the two scripts upsVIShutdown.pl and ghettoShutdown.pl. Unfortunatly when I run the command ./upsVIShutdown.pl nothing happens. I do not get anything logged into the log either /tmp/upsShutdown.log.
The first doc that I found was a file called ESXi and APC UPS VIOPS (with lamw scripts).pdf which is different than the second file I found called DOC-9531.pdf which states under the Setup Section " 1. Ensure your ESX/ESXi host(s) are being managed by VMware VIMA " which maybe where my problem lyes. Excuse my ignorance here but I am unsure what this means. I am using the free version of ESXi. Is this simply something that I have to purchase and setup on my ESXi Server?
Thx
Jason
Is your ESXi hosts being managed by VIMA 1.0? If not, then this will not work and make sure its VIMA 1.0 and not vMA 4.0
Regarding documentation, the setup of your environment should following this document, anything related to the UPS utilities, take a look at Joesph's comprehensive doc at: http://viops.vmware.com/home/docs/DOC-1341
Thank you William. I found my error and as it turns out the command sudo vifp addserver <servername> is all I was missing. However as stated above by vipernicus42 ESXi 3.5u3 (build 123629) will respond to the shutdown command with no issues and ESXi 3.5u4 (build 153875) will completely ignore the command and I ave two ESXi Servers with build 153875 and one with build 123629 I only have partial success. That will teach me for loosing my original downloaded ESXi 3.5u3 (build 123629)CD and downloading a new ESXi 3.5u4 (build 153875)CD.
Other than backing up my VMs on the ESXi 3.5u4 (build 153875)ESXi Servers and redoing the ESXi 3.5u4 (build 153875)Servers to the older Build of 123629 is there a way to make this work on the ESXi 3.5u4 (build 153875) Servers?
Thx Again
Jason
Take a look at my first comment on this document, u4 is not supported.
Hello, has anyone had time/opportunity to test this with ESX 4 or 4i and vMA 4.0??
Or should one set up VIMA 1.0 to use this with ESX 4/4i??
Thank you, Tom
It 'should' work on ESX(i) 4.0 and you'll need to use vMA 4.0 as VIMA 1.0 does not support ESX(i) 4.0
The code does not use any special API calls that isn't available in the vSphere SDK for Perl, though you will need to have a properly licensed ESXi 4.0, you will not be able to use the free licensed version due to the API lock down from ESXi 3.5u4+ and going forward which includes 4.0
I've not had the time to test but let us know if it does work.
Lamw
Have you found if the shutdown script steps you have outlined work with vMA 4.0 and ESXi 4.0 full lic.
I am having issue when installing this line into my vMA server: sudo rpm -ivh apcupsd-3.14.5-1.el5.x86_64.rpm
It saying: No such file or Directory command: sudo rpm -ivh apcupsd-3.14.5-1.el5.x86_64.rpm.
I started from scratch and got this error:
error: rpm -ivh apcupsd-3.14.5-1.el5.x86_64.rpm: rpmReadSignature failed: region trailer Bad, tag 15872 type 2047 offset 28672 count 4238
Help Thanks in advance
Robert
I've just tested the installation of apcupsd-3.14.5-1.el5.x86_64.rpm on my test vMA 4.0 and it works perfectly fine.
Ensure you're logged in as vi-admin, here is an example of the run:
[vi-admin@vMA-2 ~]$ id
uid=500(vi-admin) gid=0(root) groups=0(root)
[vi-admin@vMA-2 ~]$ sudo rpm -ivh apcupsd-3.14.5-1.el5.x86_64.rpm
warning: apcupsd-3.14.5-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID a57b2d90
Preparing... ########################################### [100%]
1:apcupsd ########################################### [100%]
Thanks lamw, it was a bad file.
I am at the point where I am testing the communcation and all I get when I run apcaccess is COMMLOST in the status field. Do you why it keeps dropping the connection.
The IP is right and I get into the UPS web portal. the firewall is down. Any Ideals
Thanks
Robert
I'm having the COMMLOST problem implementing this under VMA as well, and I've double and triple checked all the configuration settings (copied straight off a working VIMA configuration) and made sure the APC UPS is configured to permit connections from the VM in question and the firewall on VMA is turned off. I see other posts documenting this same problem... what am I missing?
Ooops... figured it out just after I posted it. Changed the admin user in the APC control interface from "apc" to something else... as soon as I changed the DEVICE line to reflect this, the problem was fixed.
Did you change the username to something else, I am still having that issue
To clarify... the admin username was originally "apc" on the card attached to my 2200 XL. I changed the username on the APC card to "bobadmin", but forgot to change it on the DEVICE line in apcupsd.conf (was still "apc"). When I updated the admin username on the device line to "bobadmin", then that fixed the COMMLOST problem... would have been nice if the error message was more specific, but oh well.
When you log into your APC UPS via the web interface, what do you use as the admin username? It should be the same one as is listed in the apcupsd.conf file - and then you also need to follow the rest of the directions - make sure the APC UPS authorizes the SCPLVMA host to as a client for "PowerChute", and make sure the passphrase is properly configured.
I can confirm that, so far, everything works under SCPLVMA - going to test everything next week, during our standard maintenance window.
tvleavitt
Are you using apcupsd-3.14.7-1.el5.x86_64 or apcupsd-3.14.5-1.el5.x86_64, I using apcupsd-3.14.7-1.el5.x86_64.?
I think I got it, but I have one more question where do I change the IP address in the apccontrol file on the doshutdown section
edit the doshutdown section like so, change the IP address to the ESXi host:
doshutdown)
echo "UPS ${2} initiated Shutdown Sequence" | ${WALL}
/home/vi-admin/upsVIShutdown.pl
${SHUTDOWN} -h now "apcupsd UPS ${2} initiated shutdown"
;;
Hi,
I have a question : The VMWare VIMA is powered down properly or not ? (the ups_vm)
Because, I see in ESXi tasks only the shutdown of all other VMs et the Host, not the ups_vm
I test to execute it on Windows : it works but the windows in not shutting down properly
I test to execute it on RHEL : it works but is the RHEL is powered down properly ?
Thanks
Seb@stien
I think I got it, but I have one more question where do I change the IP address in the apccontrol file on the doshutdown section
edit the doshutdown section like so, change the IP address to the ESXi host:
doshutdown)
echo "UPS ${2} initiated Shutdown Sequence" | ${WALL}
/home/vi-admin/upsVIShutdown.pl
${SHUTDOWN} -h now "apcupsd UPS ${2} initiated shutdown"
No, the vMA/VIMA host will not be powered down as that is the VM initiating the shutdown process, unless its hosted in another cluster or ESX(i) host that is not being shutdown. This is expected and noted in the documentation.
Ok, So :
If I have one esxi (ESX1) with 4 VM : VM1,VM2,VM3 and VIMA_UPS (all powered on)
If I lauch the script in VIMA_UPS it :
=> Power off (shutdown guest) VM1
=> Power off (shutdown guest) VM2
=> Power off (shutdown guest) VM3
=> Shutdown ESX1 (and the VIMA_UPS is powered off because it's hosted in ESX1)
Am I right ?
Seb@stien
Yes
Hi,
I have one ESX1 3.5 u2 with one Windows Server 2003 R2 64 bit guess VM.
I have followed the steps, installed VIMA and configured apc daemons. It works fine except the script failed to shutdown the Windows guess machine.
I set the sleep delay time to 30 and 45 minutes but it didn't make any help
This is the upslogs:
12-22-2009 17:38:44 -- Found ESX/ESXi host: vmesx35i.localdomain!
12-22-2009 17:38:44 -- Begin shutdown process ...
12-22-2009 17:38:45 -- WARNING VM: Server01 failed to hard power down, please verify this system later!
12-22-2009 17:38:46 -- Shutting down final host: vmesx35i.localdomain and UPS VM: vima-ovf-124830!
If I looked at the windows system log, it said Windows was shutdown unexpectedly.
So far I didn't see anything usefull in the esxi server and Vima message logs.
Is there anything to do with the Auto startup order in ESX configuration or should I increaese the sleep time?
Any idea?
Thanks in advance ... Happy Holidays!
Regards,
Vmarpole
Yea per the output, it looks like it was unable to power down the VM either soft/hard (do you have VMware Tools installed?). You might want to try to manually issue a shutdown command on the VM just to see exactly how long it takes to shutdown, I would hope it would not take more than 30min ....
That is probably why the logs said the system was shutdown unexpectedly, it most likely was just hard power off as the host was going down since it was not able to shut it down.
It might also be worthwhile to look into suspending the VM, during a power outage, it may take longer to power down a VM and so suspending it might be faster and you can resume once the power is back online.
No there's nothing you need to do on the auto startup, this has nothing to do with the order in which it starts up or powers down. As each VM is getting a shutdown/hardpower call.
Hi Lamw,
I have VMware Tool bar installed on the Windows VM guest.
You mentioned about manually shutdown the VM through command line. Could you please let me know what command it is and should I run it on the ESX itself or through VIMA?
I tried to shutdown the guest through the VI Client (Right click on the guest host and Shutdown guest) and the guest VM was shutdown gracefully.
If I change the shutdown action from Guest Shutdown to Suspended, will it corrupt the Windows guest host?
Thanks for your assistance and prompt reply.
regards,
Vmarpole
If it gracefully shuts down via the client, then I would suggest re-running the test if you can to see if you're running into the issue again. Basically something caused the VM to not shutdown within the specified period and once the timer has gone off, it'll issue the remainder VMs to shutdown or the host.
Suspending will not corrupt the OS, but if you have any active data being transfered to the system ... it may or may not make it through. Again, this is going to vary based on the applications running on the system. You either run the risk of not powering down a system in time where a hard power off takes place (how would you handle it if it was a physical system w/its powered pulled) or you try to suspend the VM which is probably going to be quicker especially if you're running on power reserves.
I'm trying to execute the ESX/ESXi APC/APCUPSD Host Shutdown script that I download from http://communities.vmware.com/docs/DOC-9531
Let me tell you my scenario....
1/ I have a ESXi server then I created 2 guesses OS on it (both guesses OS are W2008).
2/ Following step by step in your docs.
3/ When I run the command:
vi-admin@vima-ups-dev ~$ ./upsVIShutdown.pl
then open the /tmp/upsShutdown.log I got:
....Begin shutdown process...
....-- WARNING VM: first_OS failed to hard power down, please verify this system later!
....-- WARNING VM: Second_OS failed to hard power down, please verify this system later!
....-- WARNING VM: VSphere Management Assistant failed to hard power down, please verify this system later!
Hi,
Did you happen to see any errors/message on the VMs' Screen through the console when you ran the script? Something which might cause the shutdown process failed.
No...There is nothing on the VM's screen.
Something is causing the PowerOff() task not to kick off properly. I'm actually considering creating a more up-to-date version of this script, when I wrote this script awhile back it required the use of two separate scripts .... knowing what I know now, that is not the case and I probably can improve the script logic and provide additional functionality such as offering the ability to shutdown|suspend a VM or powerdownhost|standbyhost.
The possibility are endless when you're working with a licensed version of ESX(i) ... where as the free version you're going to be quite limited and will not be supported in the upcoming version of the script. If you continue to have issues, you may want to also take a look at this alternative: shutdownHostViaSOAPAPICall.pl for ESX(i) licensed and free version , this relies on the auto startup/shutdown configuration which on a per ESX(i) host.
Hi Lamw,
Thank you for your continuous help.
If I modify the ghettoShutdown.pl script (disable the sub shutdownVMs part and just use the sub shutdownHost part), theoretically the script should send shutdown request to the host and the host will shutdown the guess Vms in the autostartup/shutdown list before it shutdown itself.
Do you think it will work?
Thanks.
That is correct, if you have auto start/shutdown enabled and you've configured the shutdown aspect for each VM, then yes it should in theory process the VMs prior to shutting down the host. This is generally the best option without having to worry about shutting down each VM manually, you can use what's built in, though it gets more complicated when you have vCenter Cluster, in which the rules are only kept on a per host basis the order of the startup/shutdown which some users worry about.
There is a new release of this script supporting both ESX(i) 3.5 and 4.0: ghettoUPSHostShutdown.pl
This script will no longer be supported and is in a deprecated state. Please use the other release if you're on a licensed (non-free) version of ESXi
Thanks
Note, VMware ESXi 3.5u4 was just released and the internal API seems to have been fixed and exposed VI API will have only read-only access when using the free licensed version of ESXi. This script will most likely not work on U4, please be advised if you're going to upgrade. I have not had a chance to verify but I believe this will be the case: http://tinyurl.com/cxayy6 U3 will continue to have this hole in the API to provide both read/write access to the VI API.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
http://twitter.com/lamw