JensCoOrga
Contributor
Contributor

Shutdown ESXi 6.0 by APC UPS

Jump to solution

Dear Community,

as per specs, APC PCNS only works up to VS 5.5. Has anyone tried it with VS 6? Or is there any other way to gracefully shutdown an ESXi 6 Host through an UPS?

Thank you an best regards,

Jens Graven

1 Solution

Accepted Solutions
icehckyplyr22
Enthusiast
Enthusiast

This is working for me using the PCNS 4.0 appliance and ESXi 6.0.0, 2494585

View solution in original post

0 Kudos
10 Replies
JarryG
Expert
Expert

I did not try APC PCNS, but concerning other ways of handling UPS, there is "apcupsd", and "NUT" (which even has client vib-package for ESXi)...

_____________________________________________ If you found my answer useful please do *not* mark it as "correct" or "helpful". It is hard to pretend being noob with all those points! 😉
0 Kudos
JensCoOrga
Contributor
Contributor

Thank you, JarryG. However I have no idea what you are talking about. Do you possible a little more detailed information? Your help is greatly appreciated.

cheers Jens

0 Kudos
adrianych
Enthusiast
Enthusiast

An ESXi host is not like a normal Win or Linux server.

You should not power down a ESXi host without first putting it in maintenance mode (all VMs must be powered off or vMotion to another host).

UPS controlled ESXi host shutdown can be very tricky as not many people put ESXi hosts under 1 UPS each....means 6 ESXi host with 6 UPS. If you put 6 ESXi host to 1 UPS....any UPS issues...u may have some very big issues as ALL VMs may start powering down. Even if you put staggered ESXi host shut down, you may see VMs being vMotion to other ESXi hosts....and what would you think will happen when u have 1 or 2 ESXi hosts holding all the VMs and it is forced to shut down ?

**BTW I am taking that you have set up the ESXi hosts to a shared storage using fast connectors like 10G iSCSI...so only the live VM state needs to be vMotion over.

0 Kudos
JensCoOrga
Contributor
Contributor

Thank you. I am aware of that. What I am looking for is a simple solution for small environments w/o DRS or HA. In the past we you used to configure APC PCNS. This worked just fine: On certain UPS events, PCNS passed the shutdown command to the hosts. According to the stop/start VM settings, the host then first gracefully shut down the VM's and subsequently itself. Is there a solution under VS 6 for this ?

cheers Jens

0 Kudos
JarryG
Expert
Expert

FYI, "apcupsd" is software very similar to APC's "PowerChute Network Shutdown", but it is free (open-source) and much more universal. It works not only with APC, but with many other UPS-models/vendors too:

apcupsd | A daemon for controlling APC UPSes

"NUT" (aka "Network UPS Tool") is another free (open-source) tool for UPS-management, but this one has one big advantage over the previous one: there is native client for ESXi, so there is no need to have one VM to connect to ESXi using login/password to shutdown ESXi-host:

Network UPS Tools - Welcome

_____________________________________________ If you found my answer useful please do *not* mark it as "correct" or "helpful". It is hard to pretend being noob with all those points! 😉
icehckyplyr22
Enthusiast
Enthusiast

This is working for me using the PCNS 4.0 appliance and ESXi 6.0.0, 2494585

View solution in original post

0 Kudos
VijaySendhur
Enthusiast
Enthusiast

According to APC, this is not possible and you require Powerchute Network shutdown. We tried this a number of times with USB and found no solution.

VMWare has info here on using the APC approved solution.

Would also think SmartUPS would be a better choice and you can fit with network card. Naturally more money but if your servers are at all important, that cost should be worth it. Also gives you more monitoring and alerting which might be useful at a remote site. You also need to assure sufficient runtime for all VMs to cleanly shutdown and then shutdown the host

0 Kudos
JensCoOrga
Contributor
Contributor

Thank you all for your comments. We are exclusively using Smart UPS with NIC. I will try PCNS 4 then first.

Cheers Jens

0 Kudos
PigMan9080
Contributor
Contributor

Hi,

I have recent set up ESXi 6 auto shutdown using the APC PRO 1500 with the included PowerChute Personal Edition software.

Windows 10

  • Install Bash on Ubuntu for Windows
  • Install PowerChute Personal Edition
  • Test power outage by unplugging power and obtaining event number by going to Event Viewer.  In my case its "APC UPS Service:  Event ID: 174"
  • Test power restore by restoring power and obtaining event number by going to Event Viewer.  In my case its "APC UPS Service:  Event ID: 61455"
  • Using Windows' build in Task Schedule, create new Task and set so that when Event ID 174 is triggered, run execute.bat file.  This means that when APC is running on power, it will trigger these scripts.
    • cd c:\Windows\System32\

      bash -c -l '/mnt/c/<location of script>/execute.bat

  • A bash script is then created to remote into all the ESXi host servers and run a script that resides inside the hosts.  The script has a sleep timer to continue only after 1200sec (20 minutes) in event power does come on to stop this process (see below).
    • #!/bin/sh

      sleep 1200

      ssh root@<ip address of server> /shutdown.sh

  • Using Windows' build in Task Schedule, create new Task and set so that when Event ID 61455 is triggered, run stop.bat file.  This means that when power comes back on, it will trigger the following batch file.
    • This script will kill all running cmd.exe process, hence it will stop the execute.bat that is currently being on sleep timer. 
    • taskkill /im cmd.exe

ESXi Host

  • Each will need to allow the Windows 10 VM to connect via keypair to allow password-less access.
    • The SSH folder on the ESXi host is located at /etc/ssh/keys-<username>/authorized_keys
    • The public key of the Windows 10 VM will need to be added to the authorized_keys file
  • A bash script that's located on the ESXi host needs to be created to execute the shutdown (shutdown.sh)
    • Note:  change the permission the script by doing "chmod a+x shutdown.sh" 
    • #!/bin/sh

      poweroff

0 Kudos
JacobIV
Contributor
Contributor

(almost 3 years later...)

Hi Pigman, I liked the elegance of your solution and currently I am trying to get it to work. I run into a few hiccups.

First, the 2nd line in execute.bat refers to execute.bat itself. Shouldn't it refer to the name of a bash shell script?

Second, it seems cmd.exe instances that are run from Task Scheduler are sand-boxed these days. Running execute.bat and then stop.bat from command line works perfectly. But when I trigger 'run now' for both in the Task Scheduler, the stop.bat will not kill the running bash task and sub processes, so the shutdown will progress, even if power is restored.

Did anyone run into this too? How did you solve it?

0 Kudos