VMware Cloud Community
Quadrimium
Contributor
Contributor
Jump to solution

How to automatically suspend VMs during power outage? (ESXi 6.7 / HPE ProLiant / APC Smart UPS)

The setup is a HPE ProLiant DL380 Gen10 server running ESXi 6.7 Hypervisor. There is no vCenter server. The server has dual power supplies. There is an APC Smart UPS (SMT1000RMI2UC) available.

Upon a power outage in the building, I'd like to have the ESXi host server automatically suspend all its VMs and shut itself down after the power has been gone for 5 minutes.

Can this be achieved without using a third-party server?

For example, maybe I could connect one of the server's power supplies to the UPS and the other to a power outlet. That way, the server should be able to detect if there's a power outage. Combining that with some scripting to suspend its VMs and power itself off  ... ?

1 Solution

Accepted Solutions
daphnissov
Immortal
Immortal
Jump to solution

Firstly, that UPS is only 1000VA which is probably not going to give you enough runtime at 5 min plus time to suspend all VMs. The best thing to do would not be to suspend (which writes all memory contents to backend disk, and since this is a single host I'm guessing you only have local storage, right?) but to gracefully shutdown VMs. Using the PowerChute software that comes with this, you can have it do just that. Do some searches for blog posts that combine ESXi with PowerChute as there are lots. Keep in mind vMA does not work past 6.5 and has been deprecated.

View solution in original post

Reply
0 Kudos
6 Replies
daphnissov
Immortal
Immortal
Jump to solution

Firstly, that UPS is only 1000VA which is probably not going to give you enough runtime at 5 min plus time to suspend all VMs. The best thing to do would not be to suspend (which writes all memory contents to backend disk, and since this is a single host I'm guessing you only have local storage, right?) but to gracefully shutdown VMs. Using the PowerChute software that comes with this, you can have it do just that. Do some searches for blog posts that combine ESXi with PowerChute as there are lots. Keep in mind vMA does not work past 6.5 and has been deprecated.

Reply
0 Kudos
Quadrimium
Contributor
Contributor
Jump to solution

ok thanks but what if i want to suspend anyway? How is it done?

Reply
0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

You'd use PowerChute to configure all that. Keep in mind that in most cases (especially with under-performing storage), when you resume a VM it'll just have to be rebooted anyhow which is why shutdown tends to work better.

Reply
0 Kudos
StephenMoll
Expert
Expert
Jump to solution

We can't guess what configuration your DL380 has, the PSU options run from 500W modules right up to 1600W. Assuming you're using 500W PSUs, then the 1000VA (That's a power rating Chip, not an stored energy figure like 1000mAh) should be OK. 1000VA is about 700W.

If they are 500W PSUs, that UPS should give a run-time of approximately 16 minutes.

I've used APCUPSD (apcupsd | A daemon for controlling APC UPSes) in projects in the past, but on looking just now I see this hasn't been maintained or updated since 2016.

The APCUPSD ran on one of the guests. The daemon runs named script files (or BAT files in Windows) depending on the reported UPS status. In our case we just used the BAT file ran when the UPS starts supplying power from its battery (ON-BAT).

This BAT file used shutdown command to shut down the other Windows guests. Once that was done it used PLINK (from PuTTY) to SSH into the ESXi host, where it deposited a shell script which waited 5 minutes and then ran SHUTDOWN.SH and POWEROFF.SH on the host. The script was set to run in back ground then the Windows guest disconnects from the SSH session and then shuts itself down. This is the reason for the 5 minute delay in the shell script. If we had been cleverer, the shell script could have monitored the status of the guest and known when it had shut itself down.

We had investigated the use of vMA and PowerCLI but found that some of the vMA commands and equivalent commandlets in PowerCLI were not licensed on an ESXi host running with the free install license key.

Reply
0 Kudos
Gavis4569
Enthusiast
Enthusiast
Jump to solution

As mentioned, you can use PowerChute to correctly shutdown your ESXi server when there is a power outage. But remember that if you correctly shutdown the virtual machines, you might need them to start as well - either with auto start on the ESXi level or with some external script on some management station.

https://kb.vmware.com/s/article/1007036

Martin Gavanda https://martingavanda.com https://learnvmware.online
Reply
0 Kudos
nembus
Contributor
Contributor
Jump to solution

I had a similar problem and found the software OPMONis very helpful: https://opmonis.de/

You can run it on a Windows VM and it will trigger the shutdown of your VMs and host. It is really easy to use and not scripting is needed.

There is an older blog post about this software here: http://blog.thenetworknerd.com/2016/08/27/adventures-in-graceful-vm-shutdown/

Reply
0 Kudos