configure esxi shutdown in case of power loss (HP UPS)

configure esxi shutdown in case of power loss (HP UPS)

These steps are necessary to implement a graceful shutdown of an vSphere environment. For this scenario you need supportet HP UPSs for HP Power Protector.


  • First: think about timing
    • how many seconds/minutes after power loss the hosts should start to shutdown?
    • how long do a host to shut down? This question is about how long does the slowest VM needs to shutdown.
  • Download HP Power Protector Agent for Linux here. Current version: 1.02.31
  • Download VMware Management Assistant (vMA) suitable for your vSphere environment here for 5.5
  • IP addresses for UPS management module und each vMA


  • Assign IP address to HP management module installed in HP UPS
    either the module gets an DHCP address or you need to connect by use of serial connector
  • A vMA has to be deployed on every host that should do a graceful shutdown in case of power loss.
  • Install HP Power Protector Agent for Linux in vMA
    • copy agent onto vMA
    • install agent: sudo rpm -i hppp-linux-1.02.031-1.x86_64.rpm
      respectively current version number
    • login: http://IP-vMA:4679/ or https://IP-vMA:4680/ (user: admin/admin)
    • choose Client Installation
    • Default installation path: /usr/local/HP/PowerProtector
    • RPM-Package name: hppp-linux-1.02.031-1 respectively current version number


  • Automatic discovery of administrator (module) and client (linux agent) normally works fine. If not, scan for administrator in client.
  • If the UPS is discovered and show with status not managed, right-click the UPS and configure Power Sorce. The status has to be OK.
  • UPS Network Module should show the discovered devices as Notified Applications.
  • HP Power Protector Agent
    • copy script (in my case: to shut down all VMs running on that host to /usr/local/HP/PowerProtector/bin/virt-tools
      [ is s very simple script to shut down all VMs, but the vMA itself, and the host afterwards. You can’t use cluster-settings to shut down VMs on an cluster with HA enabled.
      If you don’t have an own script to do this task, leave a command and I will email the script
      [update] A working script you can find here]
    • configure Event Actions as necessary (SMTP)
    • configure Shutdown Parameters
      • time settings as considered
      • Shutdown type: script
      • Shutdown script/bin/su - vi-admin -c "/usr/local/HP/PowerProtector/bin/virt_tools/ vMA_ESXi_IP"
    • Test Shutdown

Upgrading Power Protector Agent

  • upgrade agent: sudo rpm -U hppp-linux-1.03.041-1

Uninstallation of Power Protector Agent

  • uninstall agent: sudo rpm -e hppp-linux-1.02.031-1
  • because of a known issue, uninstalling the packate does not remove the software completely. Therefore remove also all files within /usr/local/HP

98 responses to “configure esxi shutdown in case of power loss (HP UPS)”

  1. Hi, I’m from Spain.

    I have two hosts with esxi 5.5 in a HA cluster and a HP UPS R/T3000 with the ethernet module.
    I’ve installed VMA in one of the hosts and I would like to shutdown all the virtual machines and all the hosts if there is a power fail.

    I would like to power on the hosts and all the virtual machines if the energy comes again. I don’t know if this is possible or not.

    Will you please help me with this.


    • woifgaung says:


      At least it is easily possible to shut-down the VMs and the hosts in case of a power failure. If you decide to configure it like I wrote in the post, you need to install a vMA on each host. If the configuration is right, the Agent Software in each vMA receives a trap from the Management Module within the UPS, so it gets the information to do what is configured in case of a power failure. Here it runs a script that shuts down all VMs and afterwards the host itself.

      But it is more complicated to automate the power-on after a power failure. You have to take a lot of parameters into account. Just a few examples:
      – How long do the switches (Ethernet, FC) need to fully power on
      – How long do the storage system need to fully operate
      – In case of a shared SAS-Array, eventually HBAs should wait until the array is fully started up
      – Do you need a special order to start up VMs. Even if you could configure the Host Shutdown/-up feature in a HA-Cluster, you are not able to define a “global order” of VM starts. The order is just valid for the host you configured the order. When you use vMotion to move a VM, the order of this VM is lost on destination host.
      – It’s not just the order of VMs to boot, also important is the timing between the starts. Think of applications that need more time to start.
      – Do you have VMs that are shut-down during the power failure and you don’t want them to start up after the failure is gone?

      It’s a little bit like backup and restore. To do a backup of whatever is quite easy to manage. But if you need to restore data, you have to have a lot more information and knowledge of the environment. What I want to say, it could be hard work to set up an automated start-up after a power failure. But it is possible. You just have to do more planing and do more work to get it done. So it is possible to write a simple script that starts your VMs in the order you need. If you need a “global order” you need a better script. And at which situation the script should start? You can easily trigger the script to start during vMA start-up. But you should not do this at every start-up, just after a power failure occurred. If you are good in scripting it will be no big deal, if you are not, it will be harder. Another way could be using vSphere Orchestrator.

      Also because of this possible complexity, most of my customers decided to do the start-up after a power failure manually.

      I hope I could help you with that. Let me know if not.
      Regards to spain!

  2. Daniel says:


    great read.

    can you email the script please?



  3. Eugene says:

    Hello! Will your script working on free version of the ESXi?

    • woifgaung says:

      Hi Eugene!

      I did not test the script in free ESXi edition, but I don’t see any command that would not work on this edition. But I think you are not allowed to download a vMA without a paid license for a ESXi host. So when you have a least one ESXi license, you can download the appliance.


  4. Eugene says:

    Let mr try your script on free ESXi.

  5. Sam says:

    Hi Mate, Could I have your Shutdown script, please? Thanks.

  6. Vito says:

    Hello Wolfgang!
    May I ask you to send me the script?

    Many thanks

  7. Tim Bixley says:

    Hi Woifgaung, may I get a copy of your script


  8. Stephen Harris says:

    Hi Vito, I have worked through this and created a script that works fine when run from the command line, but is ignored when a test shutdown is triggered from the UPS (it shuts down the vMA only)
    I wonder if you would be so lind as to share your script with me too?

  9. Lukas says:

    Hello Vito, may i ask you to send me your shutdown script also? Thank you in advance

  10. Cheahmadhadi says:

    hi wolfgang, been configuring this but stuck at the same stage, script wont run. Would you mind share me the script pls.

  11. anilaliyan says:

    Hi Wolfgang, great post. Kindly share the script.


  12. Jan-Jaap says:

    Hi woifgaung, nice post, could you please share the shtudwon script?

  13. jfrog says:

    Hi, I’m stucked with this scripted shutdown in an ESXi v6.0.0 environment (original HP image). I use an vMA 5.5 with the latest HPPP to do this. Hopefully this works with your script ?

    • woifgaung says:


      I sent the script to you mail-address.

      Up to now I did not use the script on ESXi 6.0 hosts. But I had some trouble when trying to use the script in a vMA 5.1 on a 5.5 host. This does not work! You can try to execute the command vmware-cmd in your vMA 5.5 connected to a 6.0 host. When this command works you have a good chance to get the script to work. If it does not work, you probably have to move to vMA 6.0.

      Let me know if it works

  14. Anil Aliyan says:

    Hi Woifgaung,

    I am getting the below given error when it run the script to shut down the vms and host. I have not altered anything in the script.

    vi-admin@localhost:~> /bin/su – vi-admin -c “/usr/local/HP/PowerProtector/bin/virt_tools/ XX.XX.XX.XX”
    : command not foundProtector/bin/virt_tools/ line 1:
    : command not foundProtector/bin/virt_tools/ line 7:
    sleep: invalid time interval `s\r’
    Try `sleep –help’ for more information.
    : command not foundProtector/bin/virt_tools/ line 10:
    : command not foundProtector/bin/virt_tools/ line 15:
    : command not foundProtector/bin/virt_tools/ line 16:
    : command not foundProtector/bin/virt_tools/ line 19:
    : command not foundProtector/bin/virt_tools/ line 22:
    : command not foundProtector/bin/virt_tools/ line 25:
    /usr/local/HP/PowerProtector/bin/virt_tools/ line 27: syntax err ‘r near unexpected token `do
    /usr/local/HP/PowerProtector/bin/virt_tools/ line 27: `for i in ‘vmware-cmd -l`; do

  15. Gennady says:

    Hello Wolfgang!

    Thank you for help.
    Is it possible to have for me also )


  16. Hi Wolfgang!

    Thank You for instruction. It was very helpful for me.
    May i have script also ?


  17. Nils says:

    Hi work the script with esxi 6.0?

    • woifgaung says:

      Hi Nils!

      I still did not try the script in 6 up to now. Some time ago jfrog asks the same question. I sent the script and did not hear that it did not work. But I also did not hear that it worked. I am quite sure it will work. Please try and give me some feedback.


  18. Nils says:

    Hi, can you send me the script?
    Thank you Nils

  19. Petar says:

    hi, can you please send me a script?
    Thank you very much

  20. Jonathan says:

    Please send me the script. Thanks!

  21. Christophe says:

    Hi Wlofgaung, can you send me the script, thanks.

  22. Nicolas says:

    Hi Wolfgang, thank you for the nice description! Can you please send me the script? thx

  23. Jim says:

    Hi mate, thanks for the great post. Could I get the script sent please? Cheers.

  24. shcit says:

    Hi Wolfgang,
    is the script working on ESXi 6 too?
    Could i get the script to try it in my Environment?

  25. Andy Edwards says:

    Hi Wolfgang,

    We have a V6 environment, could you please send me a copy of your script please.



  26. Darko says:


    Can You send me a script?


  27. Daniel says:

    Thanks for the detailed instructions. Could you please send me your script?

  28. J says:

    Can you please email me the script. Also please let me know 1. Where the script originates 2. Which host gets the script (the VMA or the ESXi server) thanks.

  29. Marco Berto says:

    Dear Woifgaung, there is a script that shutdown all VM’s on a Cluster with HA enabled?
    I’ve a 4-node cluster. Do I need to install vMA on every node of my cluster or only on one of them?

    Many thanks in advance for your precious help.


    • woifgaung says:

      Hi Marco!

      Yes the script shuts down all VMs, regardless of whether HA is enabled or net. Yes, for this approach it is necessary to deploy a vMA on every host in the cluster.


      • Marco Berto says:

        Thanks you so much for your very fast reply. so how I can a copy of your script?
        Many thanks and best regards!

  30. Axel says:

    Hi, helped me very much. Would like to ask for your script. Could you sent it? Thanks a lot

  31. Matik says:

    send me a copy of your script please

  32. Peter Flion says:

    Can you send me the vsphere 6.0 version of the script as well please

  33. mbro says:

    Hi would appreciate a copy of your script please. Thank you 🙂

  34. Jens says:

    I have two hosts with esxi 6.0 in a HA cluster and a HP UPS R/T3000 with the ethernet module.
    I’ve installed VMA6 in one of the hosts and I would like to shutdown all the virtual machines and all the hosts if there is a power fail. Can you send me the script please. Thank you.

  35. Steve says:

    Hi Woifgaung. Could I have a copy of your script please. It will be used on ESXi 6 in an HA Cluster. Thank you in advance.

  36. Tyraj Daniel says:

    Hi, can you send me please the script? I need it for an ESXi 6.0 environment to shutdown den VMs and in the end the host himself.
    Thank you!

  37. JeriMind says:


    nice work!

    can you email the script please?


  38. Matthias says:

    Exactly what i was searching for! Would you send me the Shutdown Script please? Thanks!

  39. shubhradeep ghosh says:

    We have a 2 node ESXi 6.0 cluster on Vcenter 6.0 where i am trying to Automate VM & Esx graceful shutdown by deploying vMA & installed HP Power protector 1.04 & 1.02 on the vMA’s. The UPS is reachable from vMA & Vcenter. But the issue that i am facing is when trying to discover UPS from HPPP web interface with the quick scan option, the UPS is not discovered probably because it is in a different IP range. According to the HPPP Guide, i should have an option below “quick scan” to scan using IP ranges which i am not getting in the user interface in HPPP version 1.02 & 1.04.

    Could you please throw some light as to why i do not get the option of scanning/ discovering UPS through IP ranges?

    • shubhradeep ghosh says:

      solved it, its cause i was opening HPPP as administrator instead of client as Range scan option is available only with client.

  40. alexander says:

    wolfgang, very nice solution, please sent me the script. thank you a lot 🙂

  41. Cyril says:

    Hi Wolfgang,

    I’d like to receive the script as well. I find that the HP Management module is not very stable when you have a lot of remote clients (HP Power Protection Agents) running. Hopefully this will solve that problem since I only have 3 ESXi hosts.

    Thanks in advance.



  42. George says:

    Hi Wolfgang,

    this is realy good post. I’m interested in the script as well.

  43. opedro says:

    Hi Wolfgang,
    can you share the script with me too i need to do some configuration like your with 3 esx and 1 vcenter

  44. Tobias says:

    Hello Wolfgang, very good post! Can you send me the script? Thanks alot!

  45. Aragorn Sun says:

    Hi Wolfgang, excellent post! Could you please send me the script as well? Thanks so much in advance.

  46. hoselillo says:

    Great work, i have esxi 6.0, can you send me the script please??

  47. Hi everybody, I’d need that script, too 🙂 Could someone kindly send it to me? Thank’s!

  48. bogono31 says:

    HyWolfgang, its nice what you doing, very good post! Can you send me the script? Thank you!

  49. Jonas Martinsson says:

    Good post! Can you send me the script?
    Thank you!

  50. Oliver says:

    Hello Wolfgang, thanks for the good article. Could you provide the script as well? Thank you!

  51. Angelo Vtr says:

    thanks for your useful post, could you send me script please?
    could you use vicfg command or something similar?
    I note this for vMA: –server ip_address –username root –password password –operation shutdown

    but you need to sent the “enter” command before to put host in maintenance mode, it is not a useful mode because when host came up again won’t start VMs automatically because of mant. mode status.

  52. Dmitry says:

    Hi Wolfgang, very good post! Can you send me the script?

    • Angelo Vtr says:

      Hi guys,
      after several research i found a useful script into this path of vMA
      I had to go on the top of the montain to get back to level ground 🙂 🙂

      I used this script into HPP web console shutdown parameters
      perl /usr/local/HP/PowerProtector/bin/virt_tools/ –server xxxxxxxx –username root –password xxxxxxxx

      Adding “perl” at the beginning it worked perfectly for my environment (no Cluster, No HA) you have to try with HA enabled.
      here a useful link too

      Thanks again to Wolfgaung to pointing me on the right way

  53. John Barratt says:

    Woifgaung, Thanks for this very helpful post, you have saved me a load of time and no doubt pain. Could you please send me the Shutdown script. Many thanks

  54. David says:

    would really appreciate to receive the script as well! thanks in advance, great write up

  55. Victor says:

    Hi Woifgaung, I would appreciate it a lot if you could send me the script. Thank you!

  56. […] Here is a very simple linux bash script to shut down all VMs of a ESXi host and the host itself, for example when a power failure occurs, this script can be used in UPS software. Some time ago a posted how to use such script in an HPE UPS environment. You can find the post here. […]

  57. James says:

    Hi Woifgaung would you be able to send me the script, will this work with ESXi 6.7
    and HP R5000

  58. James says:

    Hey Woifgaung I would like to shut down VMs in a sequence so that the DC is last
    Is there a way we can do that ? or would you have another script that might be able
    to help out in that fashion

    • vNote42 says:

      Hi James!

      You can easily change the script to do so. You can exclude VMs you want to shutdown at last by excluding them during the loop. I did so with the VMA-VM itself ($VMA). After the loop, shut them down individually by running command “vmware-cmd path_to_vmx-file stop soft”.

      I hope this helps you!

  59. Boba ILIK says:

    Hi Wolfgang
    Can I have the script for shutting down the servers attached to the HPE UPS please?


  60. Jim Janson says:

    Hi all,

    Can this script be used without the HPE? I would like to just schedule all the VM and ESXi Host to power off and then shutdown the server hardware.

Leave a Reply

Your email address will not be published. Required fields are marked *