Good morning,
I've set up an alarm within Virtual Center that monitors the Vmtools status (Heartbeat Alarm)of each VM. When the tools stop, it sends me an alarm, then runs a script to restart the tools. The alarm piece works but the script doesn't. The sad thing is that I use to have this running until I upgraded our environment. I can't figure out what I am going wrong. I tried adding the On Error Resume Next statement. I didn't get any errors after adding that statement but it still didn't work. Thanks for looking at this with me. Below is the script:
Set objSWbemLocator = CreateObject("WBemScripting.SWbemLocator")
set objWMIService = objSWbemLocator.ConnectServer (Wscript.Arguments(0), "root\cimv2", "Domain\username", Wscript.Arguments(1))
Set colServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name = 'vmtools'")
For Each objService in colServices
errReturnCode = objService.StopService()
Next
Wscript.Sleep 20000
For Each objService in colServices
errReturnCode = objService.StartService()
Next
Here are the errors that I am getting;
I loaded the script on a VM directly just to test it.
When I run c:\scripts>restarttools.vbs I get the following error: Runtime error: Subscript out of range
When I use c:\scripts>restarttools.vbs {tagetname}, I get the following error: Runtime error: Subscript out of range
When I use c:\scripts>restarttools.vbs {tagetname} password, I get the following error: SWbemlocator: User Connections can't be used for local connections
Can anyone help me? Thanks
Tim
The script looks familiar:
http://www.jasemccarty.com/blog/2008/12/virtual-machine-heartbeat-state-band.html
What happens if you run the script from a cmdline?
I put the script in a folder on the C: drive of my vCenter Server. Then from a cmdline, I call it this way...
cscript.exe c:\scripts\restarttools.vbs Password
Just replace targetname with the name of the VM. Note: The VM machine name MUST match the VM's name in vCenter.
Jase McCarty
Co-Author of VMware ESX Essentials in the Virtual Data Center
(ISBN:1420070274) from Auerbach
Please consider awarding points if this post was helpful or correct
Thanks Jase! You helped me with this one last November and it worked wonderfully but since then, I have rebuilt all of our ESX machines and Virtual Center server. Now I can't get it to work.
I have loaded the the script on the Virtual Center Server but no matter what machine i use as the target, i keep getting, "The RPC server is unavailable" error message.
Previously, I was loading the script directly on the VM itself to test. Any sugestions?
Thanks,
Tim
Hey Tim,
So... When the VM's Tools status hits the tank, the guests are basically hung huh?
Jase McCarty
Co-Author of VMware ESX Essentials in the Virtual Data Center
(ISBN:1420070274) from Auerbach
Please consider awarding points if this post was helpful or correct
Correct, once we take a backup of a machine the tools stop. Subsequently, we can't take a future backup because the tools appear to be stopped in Virtual Center.
No matter what I do I keep getting that RPC server unavailable error message. Jase, do you have any ideas?
Thanks