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 PowerChut...
See more...
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