• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

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.
  • 3
1 Solution
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).
McKnifeAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now