Subscribe For Free Updates!

We'll not spam mate! We promise.

Sunday 24 November 2013

Howto power ON ESXi Guest machine using CLI & howto link it to the DUDE :)



I recently developed a Centralized Network Monitoring System using Mikrotik’s base THE DUDE . It is an amazing free application through which you can completely monitor your network environment and can perform various task also using single screen via web or console. I added various advance monitoring probes , You can find its demo screenshot at following link.

http://aacable.wordpress.com/2012/07/02/the-dude-show-us-your-map-series/
I decided to upgrade it from simple networking monitoring system to monitoring+management system I was already using its tool menu through which I was able to do RDP to any target windows pc, or Shutdown / Power ON any PC on the map or run any custom script to restart service on specific server, but the problem was that guest machines on VMWARE ESXI 4.0 were not responding to WOL packets (Magic Packets to power ON machine over the network), I searched over the internet but couldn’t found any solution to this, so I made my own scripts to fulfill the task.
First you need to enable SSH on your vmware ESXi box, You can enables ssh by using following guide
http://aacable.wordpress.com/2012/07/04/howto-enable-ssh-in-vmware-esxi-4-0/
Once SSH is enabled, test it by using any ssh client , for example PUTTY.
After successful logged in to ESXi host using putty, we have to find the guest machine VM ID which we want to power on, use the following command to list all machines
vim-cmd vmsvc/getallvms
You will get result something like below, Look for the VMID of the machine you want to get,
Vmid       Name                                              File
112            vmserver1 – WSUS                     WSUS/WSUS.vmx
16              vmserver2 – Symantec             symantec/symantec.vmx
96             vmserver3 – SAMETIME         vmserver3/vmserver3.vmx
For example you want to power ON the vmware1 – WSUS machine having vmid 112 , use the below command
vim-cmd vmsvc/powen.on  112
Now we can use above command and wrap it in any script or batch file or link it with the DUDE tool menu
For example if you want to execute above command using PLINK (Which is used to execute command on remote ssh server using ssh tunnel) in any batch file, use the below command
\\dudepc\share\plink.exe -ssh -l root -pw zaibpass 10.0.0.1 “vim-cmd vmsvc/power.on 112″
If you want to link it to dude Tool menu, Follow below steps
Open DUDE console, from left menu, Goto TOOLS , Click on + sign to add Tool
Type: Executable
Name: Power ON ESXi Guess OS
Command:
\\dudepc\bin\plink.exe -ssh -l root -pw zaibpass 10.0.0.1 “vim-cmd vmsvc/power.on 112″
Click on OK to save , Now open your map, right click on your desired target (vm guest) and goto tools menu, and your new tool will be appearing there, click on it and the script will execute. Its recommended to test the command before putting it on any batch file or script.
Regard’s
naveed ahmad

Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT → , ,
FOLLOW US →
SHARE IT →

0 comments:

Post a Comment

 
".