VMware Cloud Community
ipatelvmware
Contributor
Contributor

shutdownesxi.pl multiplehosts

I am wanting to shutdown mulitple ESX hosts with on script from VMA.

/bin/shutdown.pl --server    -username  --password,  (this is for a single host)

How do i do this for multiple host from one single script ?

Imran Patel
Tags (2)
9 Replies
admin
Immortal
Immortal

Hi   ipatelvmware,

Welcome to the communities .

you need to write something like below .

#!/bin/bash

vmware-cmd /vmfs/volumes/datastore/VM1_dir/VM1.vmx stop trysoft

vmware-cmd /vmfs/volumes/datastore/VM2_dir/VM2.vmx stop trysoft

"Life is never easy for those who dream"
0 Kudos
ipatelvmware
Contributor
Contributor

I need to shut down ESX hosts

I have tried to implement ghettoUPSHostShutdown.pl, but I dont think it is compatible with VMA 5.0, as i get an error when i try to run it.

I would like to know how i could call on a master script that would esseintially do this :-

shutdownESXi.pl --server server 1 --username Server_username --password Server_Password

shutdownESXi.pl --server server 2 --username Server_username --password Server_Password

shutdownESXi.pl --server server 3 --username Server_username --password Server_Password

shutdownESXi.pl --server server 4 --username Server_username --password Server_Password

Imran Patel
0 Kudos
flash600
Contributor
Contributor

Hi ipatelvmware,

I've the same problem with HP power protection...

have you found a solution?

0 Kudos
flash600
Contributor
Contributor

I've resolved the problem by creating another script that starts the commands like:

perl [path to shutdown-script ]/shutdownESXi.pl --server [server1] --username [username] --password [password]

perl [path to shutdown-script ]/shutdownESXi.pl --server [server2] --username [username] --password [password]

perl [path to shutdown-script ]/shutdownESXi.pl --server [server3] --username [username] --password [password]

is working fine 🙂

greets

0 Kudos
xmf62
Contributor
Contributor

Hi flash600,

Since I do not know enough about Perl could you post your custom script?

Thank you very much!

0 Kudos
flash600
Contributor
Contributor

Hi,

it's very simple, because I'm not a perl, bash or linux guru 🙂

here the script:

/usr/local/HP/PowerProtector/bin/virt_tools/shutdown-hosts.sh:

#!/bin/sh

perl /usr/local/HP/PowerProtector/bin/virt_tools/shutdownESXi.pl --server [IP esx1] --username [username] --password [password]

perl /usr/local/HP/PowerProtector/bin/virt_tools/shutdownESXi.pl --server [IP esx2] --username [username] --password [password]

perl /usr/local/HP/PowerProtector/bin/virt_tools/shutdownESXi.pl --server [IP esx3] --username [username] --password [password]

...

you must change IP esx1, username and password with your config, example:

perl /usr/local/HP/PowerProtector/bin/virt_tools/shutdownESXi.pl --server 192.168.0.1 --username upsuser --password password

xmf62
Contributor
Contributor

Hi flash600,

you're right ... it's very simple.

thank you very much. 🙂

0 Kudos
flash600
Contributor
Contributor

no problem 🙂

0 Kudos
bartdewulf
Contributor
Contributor

I'm trying to get this working on esx 5.1 but i am getting errors on

LWP::UserAgent is under 6

Server version unavailable at "https://130.0.100.45:443/sdk.vimService.wsdl" at /usr/lib/perl5/5.10.0/VMware/VICommon.pm line 545.

0 Kudos