Script for ESXI needed that resets guests that cannot be pinged

Hi experts.

We run ESXI 5.0 Upd.1 Patch7
I would like esxi to check if a guest cannot be pinged and if it can't be pinged for more than 3 minutes, reset that guest (of course turning the guest off and right on again would also do).

Anyone did that before?
Edit: The script would only have to check specified guests, not each and every guest.
LVL 61
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Is this a standalone host or do you have vCenter? Reason I ask is because VMware already provides a function for this within a Cluster. If you have a Cluster, go into its Settings > VM Monitoring (under vSphere HA). What this feature does is, based on sensitivity settnigs, vSphere HA will restart a VM if it doesn't receive a 'heartbeat' from the VM in a specified amt of time. The heartbeat is sent from VMware Tools installed within the VM's OS. This is good, for example, if a Windows VM blue screens or hangs for some reason.

McKnifeAuthor Commented:

This is a standalone host.
McKnifeAuthor Commented:
Self solved:
ESXi 5.x
 To power on a virtual machine from the command line:
 1.List the inventory ID of the virtual machine with the command:
 vim-cmd vmsvc/getallvms |grep <vm name>
 Note: The first column of the output shows the vmid.
 2.Check the power state of the virtual machine with the command:
 vim-cmd vmsvc/power.getstate <vmid>
 3.Power-on the virtual machine with the command:
 vim-cmd vmsvc/power.on <vmid>

...same thing for powering off (substitute on).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
McKnifeAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.