VMware Cloud Community
generaluser9789
Contributor
Contributor

Turn off all vm's safely and then power off ESXi via command

How can i turn off all vm's in ESXi and then shutdown ESXi automatically with a remote command?

I have the free version of ESXi and use the web configuration client for management. It runs on a Dell R420 host and is connected to a APC UPS (but doesn't properly detect power related events from USB to APC).

I already have other equipment on the network (FreeNAS and Synology) that successfully detect and notify when a power issue happens based on APC UPS. Those events go to a syslog server where i can trigger actions based on notifications.

What command can i use to SAFELY shutdown all virtual machines and then shutdown ESXi via terminal?

  • +1 if hook/command targeted all VM's instead of having to specify each VM individually (since vm's are subject to change after i implement this)
  • +1 if force-shutdown activated on any VM's that took more than x seconds to poweroff. This is rarely an issue but sometimes when shutting down a vm that has latest vmware-tools installed the system (for reasons that don't appear to be related to vmware) stalls and needs a "remove-power" type shutdown
  • +1 if ESXi would automatically shutdown after all the VM's were powered off.

This post has manual steps but they don't include the above points. I imagine this has to be a common problem and there has to already exist a way to do this that keeps the above points in mind. If not, i'd be nice to know what you all do (assuming you aren't already running paid tools that do this for you).

My plan is to listen for a specific log event that happens when system is powered by UPS and has reached low battery state. When the event is triggered, run the command via ssh.

Tags (1)
0 Kudos
0 Replies