VMware Cloud Community
djshaunvt
Contributor
Contributor
Jump to solution

Vmware Esx 5.1 Shut down Script

Hi Guys.

I wonder if anyone could assist me.

We are having many power outages here in South Africa and I am faced with having to shut down our servers regularly.

I have got all our windows servers shutting down automatically via our UPS software (Riellio)

I have tried to download the Vmware software from our UPS support page but they say it wont work on the free version of Esx 5.1.

In turn what I have done is to create a script which runs through Plink and I am hoping to use this on another windows box as a shuhtdown script.

So when the windows box shuts down it will run the script and in turn shut down the ESX i host.

I have enabled the SSH server on the Esxi and when I run the shutdown script it shuts down the server just fine but I have been reading that the server should be in Maintenance mode when powering off.

I just want to make sure it is shutting down the Esx server gracefully.

The script is below:

Any help would be appreciated.

Script text as follows:

plink -ssh root@10.1.6.11 -pw mypassword poweroff -d 10

Vmware.pngplink -ssh root@10.1.6.11 -pw mypassword poweroff -d 10

Reply
0 Kudos
1 Solution

Accepted Solutions
Alistar
Expert
Expert
Jump to solution

Hi there,

while investigating the option of doing it via appliance, you can tweak your command to do the following:

plink -ssh root@10.1.6.11 -pw mypassword "esxcli system maintenanceMode set -e true;poweroff -d 10"


this way the host will first enter maintenance mode and the next command via ; will be shutdown.

Stop by my blog if you'd like :slightly_smiling_face: I dabble in vSphere troubleshooting, PowerCLI scripting and NetApp storage - and I share my journeys at http://vmxp.wordpress.com/

View solution in original post

Reply
0 Kudos
5 Replies
JarryG
Expert
Expert
Jump to solution

Why do not you try "NUT" (network ups tools) software? It has client for ESXi too, and it supports many Riello-UPS models...

In my configuration, I have one linux-VM running as "NUT-master" (talking to ups). If power-outage is detected and battery is in "cirtical/low" state, it issues command to all "NUT-slaves" (other VMs, ESXi and other physical servers) to shut down. It works very well for me, and I think is more secure (does not need root-password for some script)...

_____________________________________________ 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! :winking_face:
Reply
0 Kudos
djshaunvt
Contributor
Contributor
Jump to solution

Hi,

Thanks for the reply.

Does this come in the form of an OVF template which you need to install then on the ESX through VM ware Sphere. ?

Just trying to understand how it work.

If so I will check it out.

Thanks.

Alistar
Expert
Expert
Jump to solution

Hi there,

while investigating the option of doing it via appliance, you can tweak your command to do the following:

plink -ssh root@10.1.6.11 -pw mypassword "esxcli system maintenanceMode set -e true;poweroff -d 10"


this way the host will first enter maintenance mode and the next command via ; will be shutdown.

Stop by my blog if you'd like :slightly_smiling_face: I dabble in vSphere troubleshooting, PowerCLI scripting and NetApp storage - and I share my journeys at http://vmxp.wordpress.com/
Reply
0 Kudos
djshaunvt
Contributor
Contributor
Jump to solution

Hi Alistar...

Perfect...

Just what I am looking for in the meantime while I get the proper UPS option figured out Smiley Happy

Much appreciated..

Shaun


Reply
0 Kudos
JarryG
Expert
Expert
Jump to solution

NUT comes as any other installation file: source-code in "tar.gz" archive-file, "vib" as binnary installation package for ESXi, and there are also native binary formats for any common linux/bsd/windows. No special template is needed, it can be installed on any VM.

_____________________________________________ 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! :winking_face:
Reply
0 Kudos