One of the biggest challenges I run into working with ESXi hosts is the lack of a real usable CLI. The remote CLI provided by VMware is clunky at best and makes administration a bit of a pain. I did some poking around and managed to find some interesting CLI commands that work for ESXi.Most of these have no manual page but will output a help message if run by themselves. I would recommend using extreme caution and using a test host to determine the usefulness in your environment before using them on an important system. Also keep in mind that the examples that I give are not the "only" way the commands can be used.
vim-cmd vmsvc/getallvms
Lists all vm's running on hypervisor and provides vmid
vim-cmd vmsvc/power.off vmid
Powers off vmid referenced from getallvms command
vim-cmd vmsvc/power.on vmid
Powers off vmid referenced from getallvms command
vim-cmd vmsvc/power.reboot vmid
Reboots vmid referenced from getallvms command
vim-cmd vmsvc/destroy vmid
Deletes the vmdk and vmx files from disk
vim-cmd hostsvc/maintenance_mode_enter
Puts hypervisor into maintenance mode
vim-cmd hostsvc/maintenance_mode_exit
Takes hypervisor out of maintenance mode
vim-cmd solo/registervm /vmfs/vol/datastore/dir/vm.vmx
Registers vm in hypervisor inventory
vim-cmd vmsvc/unregister vmid
Unregisters vm with hypervisor
vim-cmd vmsvc/tools.install vmid
Starts vmware tools installation for VM
vim-cmd hostsvc/net/info
Provides information about hypervisor networking
chkconfig -l
Shows daemons running on hypervisor. Can also be used for configuration.
esxtop
Same as linux top for vmware
vmkerrcode -l
List of vmkernel errors
esxcfg-info
Lists a LOT of information about the esx host
esxcfg-nics -l
Lists information about NIC's. Can also be used for configuration.
esxcfg-vswitch -l
Lists information about virtual switching. Can also be used for configuration.
dcui
Provides console screen to ssh session
vsish
Vmware interactive shell
decodeSel /var/log/ipmi_sel.raw
Read System Event Log of server
16 comments:
Hi Robert,
Thank you for this great blog post. Do you know if there is any official documentation from VMware about the CLI commands?
Thanks,
Danny
Danny,
Thanks for the comment. There is a VMware doc for the remote CLI but it's not the same as the commands on the local system. According to VMware there is no local command line on these systems. It appears they pulled out all the wrapper scripts to break the CLI but left behind the binaries for internal functionality.
Just so you know this local CLI is not supported by VMware and is a hack of sorts. Be cautious using these commands with production hosts as with no documentation odd things can happen.
Hell, thanks!
These commands help me a LOT!
Keep up the very good work!!!
Nico
Thanks for the comment. The CLI is quite useful especially for bulk import of VM's into inventory and other tasks that are repetitive. I'm glad you found this useful.
Great posting. This will really help me integrate my UPS into my ESXi box. My plan is to have the UPS tell my day to day computer (OS X) that it is on battery (via USB cable) and then OS X will trigger a .sh file that connects to ESXi via ssh, suspends all the machines, and then powers down the host. Then the OS X machine can power down too.
Your post provided the final pieces to this puzzle !
Thank you!
Great post! I've been digging around on the ESXi console and this was a great resource to get me started with vim-cmd.
Thanks for the comment. These commands with an ssh trust from a "control" machine are quite powerful. Check out some of the more recent articles on ssh trusts.
Supported or not, this appears to be the only way to administer ESXi from a non-windows box. Thanks for the blog post.
Thanks ,Amazing command.
--Syed
Very informative.Thanks a lot.Is there anyway to view IP addresses of NIC's just like ipconfig command windows
Thanks,
SA
This is a great info. please keep sharing.
Hello Robert,
thanks a lot for this post. I have a remark regarding esxtop: logging on to my esxi4.1 and running esxtop does not show the nicely formatted table of a *nix top command, but instead it spits out an awfully long textstream. To get what you'd expect from top, you need to install vma and issue resxtop from there:
http://virtualfuture.info/2009/01/run-esxtop-on-esxi-from-vima/
Jerry. Regarding ESXtop. Rather than install the VMware provided crapware on your system take a look at the local settings of your terminal and your terminal type environment variable.
Thanks Robert for the great info.
Someone was asking to see ip info in Esxi 4.1
command:
esxcfg-vmknic -l
esxcfg-route -l (for defaultgateway:)
esxcfg-vswitch -l (for switch)
You can find all the commands in /sbin
Thanks you grate blog ...
Is there any other commands ??
Post a Comment