[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.
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