ESXi

 View Only
Expand all | Collapse all

Polling VM to see if powered off and powering on if so

  • 1.  Polling VM to see if powered off and powering on if so

    Posted Mar 03, 2014 12:04 PM

    We have a solution running ESXi 5.5 standalone with 2 virtual machines connected to a HP UPS.  When the UPS loses mains power it shuts down one of the VM's using the agent however sometimes the mains power is not off long enough for the battery to drain.  Therefore the VM stays powered off until we manually power it on.  Is there any way of automating it so that ESXi polls the VM state every 1 hour to check if it is on and if not power it on?



  • 2.  RE: Polling VM to see if powered off and powering on if so

    Posted Mar 03, 2014 12:10 PM


  • 3.  RE: Polling VM to see if powered off and powering on if so

    Posted Mar 03, 2014 12:27 PM

    Hi, we have this in place however the physical server is still on as the power isnt off long enough to drain the ups



  • 4.  RE: Polling VM to see if powered off and powering on if so
    Best Answer

    Posted Mar 03, 2014 05:21 PM

    Try the solution described in this article. Hope it will help you.

    http://pingforinfo.com/cronjob-poweron-vm/



  • 5.  RE: Polling VM to see if powered off and powering on if so

    Posted Mar 03, 2014 08:12 PM

    Thanks I will take a look



  • 6.  RE: Polling VM to see if powered off and powering on if so

    Posted Mar 04, 2014 03:44 PM

    did you get chance to test it?



  • 7.  RE: Polling VM to see if powered off and powering on if so

    Posted Mar 11, 2014 10:04 AM

    Yes worked brilliantly many thanks for all your help

    Going to see if I can get it to work on some of the older 4.1 installs



  • 8.  RE: Polling VM to see if powered off and powering on if so

    Posted Mar 11, 2014 01:53 PM

    Unfortunately running the auto-poweron.sh script returns an error on 4.1 indicating that vmid=352: not found.  Even though the vm does have that id and manually running the get power state and power on commands works fine.  Any thoughts would be most welcome



  • 9.  RE: Polling VM to see if powered off and powering on if so

    Posted Mar 11, 2014 05:15 PM

    whats the output of following command? please replace vm name.

    vim-cmd vmsvc/getallvms | grep "vmname" | awk '{print $1}'



  • 10.  RE: Polling VM to see if powered off and powering on if so

    Posted Mar 12, 2014 04:32 PM

    After re-editing the script in vi and adding an extra line to the end of the file it now seems to work.

    Many thanks everyone for all your help



  • 11.  RE: Polling VM to see if powered off and powering on if so

    Posted Mar 12, 2014 05:15 PM

    thank you, whats the extra line  added?



  • 12.  RE: Polling VM to see if powered off and powering on if so

    Posted Mar 12, 2014 07:07 PM

    Just a carriage return / blank line



  • 13.  RE: Polling VM to see if powered off and powering on if so

    Posted Mar 13, 2014 10:16 AM

    cool.. thanks for sharing the info.