September 13, 2016

Cleanly shutdown ESXi 6.0 / 6.5 and Synology NAS with APCUPSD and ESXCLI

I have this working now:

You will need the NAS' to be set to startup on power failure and have wakeonlan enabled.

1. Setup autologins for the root user to:
Generate Key on master - ssh-keygen -t rsa
Access the ESXi Host via SSH
Access the Synology NAS via SSH

More info here: Login-to-synology-nas-with-ssh-keys

2. Create a script on the Linux host that:
Gets a list of all "Running VM's"
Creates a script on the ESXHost containing the commands to shutdown the VM's
Execute the ESX Script via SSH
Shutdown the Synology NAS

  VM Shutdown Script

3. Setup APCUPSD to:
Run the script on the local linux host to create the ESX Script
Shutdown the ESX Host via SSH (local VM will shutdown as part of this)

First of all we need a linux host with APCUPSD

Edit /etc/apcupsd/onbattery


#Shutdown running VM's
#Shutdown NAS1
ssh -p 9999 shutdown -h
#Shutdown NAS2
ssh -p 9999 shutdown -h

Also to get things going again if it comes off battery:

Edit /etc/apcupsd/offbattery

# ssh -p 9999 shutdown -h
wakeonlan 00:11:32:39:87:25
# ssh -p 9999 shutdown -h
wakeonlan 00:11:32:38:E8:EF
# Reboot ESX Host, for me this is better than just autostarting the shutdown
# VM's as the storage doesnt always reconnect correctly.
ssh reboot



esxcli --sessionfile /root/esxhost  network ip interface list
esxcli --sessionfile /root/esxhost vm process list

esxcli vm process kill -t [soft,hard,force] -w WorldNumber

September 11, 2016

Installing VMware CLI Tools on Linux

Download the 6.0 CLI tools from:

Download Apache 1.3.0 Source for SOAP


tar -xvf apache-etch-1.3.0-src.tar.gz

Install the following via CPAN:

SOAP-Lite, Version 1.20 - install PHRED/SOAP-Lite-1.20.tar.gz
ExtUtils::MakeMaker, Version: 6.96 - install BINGOS/ExtUtils-MakeMaker-6.96.tar.gz
Module::Build, Version: 0.4205 - install LEONT/Module-Build-0.4205.tar.gz
Net::FTP, Version: 2.77 - install GBARR/libnet-1.22.tar.gz
LWP, Version: 5.837 - install GAAS/libwww-perl-5.837.tar.gz
LWP::Protocol::https 5.805 or newer - install MSCHILLI/LWP-Protocol-https-6.06.tar.gz
Socket6  0.23 or newer - install UMEMOTO/Socket6-0.28.tar.gz