Hi. I'm working on documenting some of my VM clusters and need to dump the VM configs to a file so I can manage them in Excel.
I've searched the discussion forum but guess my keywords aren't right - surely this is a common thing?
I'd like to be able to list the Name, RAM alloc, #CPU, Network, IP and so on. I've tried the various GUI export modes but can't get what I want.
Is there a feature I'm missing or is this only achievable through the scripting API (to which I don't have access)?
Thank-you for any replies and I'll be sure to respond with points, even if it turns out I can't do this without scripting.
Tim
Doh! I've just found that right-clicking on the column headers in Virtual Machine view gives me a lot more options. I swear I tried this already!
The only parts I can't extract now are the # disks and sizes and the specific network details, other than IP.
Answers to these last few items will be much appreciated.
thanks,
tim
The VM conifguration file is a text file by its very nature -
Weintstein5: agreed, but I don't believe I can find all I need in there. For example, how do I determine the disk sizes from the VMX file?
Tim
The vmx file will point to the datastores where you can obtain file size from -
I was hoping to find it in a file without chasing links. When in VC I can see the disk sizes instantly through Edit Settings but I guess thats coming out of SQL?
You can pull out all your required data A) through SQL as you've stated, I've done this hundreds of time, good data, one source, but requires a RO account to the backend and requires some SQL knowlege. B) You can still get everything out of the .vmx file, you just need some scripts with some logic. You have the name of all your disk's in the .vmx listed by scsi#:#, just grep for .vmdk and if you're running legacy systems you can grep for .dsk. Then loop through those interfations and use "du or df" to get the size of your drives. What's nice with the ESX 3.x, you already know where all your registered vm's are "vmware-cmd -l", use that to your advantage and you can output a nicely formatted report of VM Name, Mem, Disk, Snapshots, etc, etc, etc.
It's really not a difficult task, you can even print which datastore they're in/etc. Just takes a little bit of time, I'm not sure if Veeam reporter captures all this VM info, but if you're not into scripting or writing your own tool, then you can look at that. I believe it might capture only system data but worth a shot.
From the command line try:
esxcfg-info -a
Beware that it spits out a slew of information, so you'll have to grep it in order to get the info you are after
OR use one of the command line switches, see man esxcfg-info for more info.
PS: Yes I did read your "I cannot use scripts" remark, but sometimes it is good to know you can get the info using the alternative way.
--
Wil
Thanks for all the responses! I'm trying them out as we speak. Just to clarify a point, I said that I couldn't use the scripting APIs - any of the native ESX commands are fair game, and I'm more than comfortable with bash scripting, just not the COM or Perl stuff.
Thanks!
tim
Cool, for bash scripts I would probably go after collecting the .vmx files and extract the info from there along with some small extra scripts for retrieving the vDisk size as others have mentioned.
The esxcfg-info command is very verbose and has heaps of host specific info. There's another command in that same region, the vm-support command and you can even pass it things like world-id. All very useful for debugging or trouble shooting.
If your only requirement is to store VM configurations then pretty much all you need is in the vmx file as it makes up the virtual hardware.
As you are also after disk size, IP address etc.. maybe it is best to write a small utility to be run from within the VM themselves.
If you are using only windows for example then you could get away with a few smallish scripts.
--
Wil
Agreed, probably eaiest is to pull out of the .vmx what you can and retrieve the physical size by look at the defined .vmdk files from the actual filesystem. You can also pull out a great deal from "vimsh (3.x) / vmware-vim-cmd (3.5)
So I just verified, you can actually get disk size / disk free from within the commandline, this is only on ESX 3.5 that I've verified and I think this specific command is only as of 3.5, it's not in 3.x.
If you go into "vimsh" (internal interpreter), you can also just call it from within the normal service console "vmware-vim-cmd (SOMECOMMAND)"
(vim.vm.ConfigTarget) { dynamicType = <unset>, numCpus = 8, numCpuCores = 8, numNumaNodes = 1, datastore = (vim.vm.DatastoreInfo) [ (vim.vm.DatastoreInfo) { dynamicType = <unset>, name = "Storage1", datastore = (vim.Datastore.Summary) { dynamicType = <unset>, datastore = 'vim.Datastore:4869d7b0-837aaf28-a53e-003048637555', name = "Storage1", url = "/vmfs/volumes/4869d7b0-837aaf28-a53e-003048637555", capacity = 586531471360, freeSpace = 492754173952, accessible = true, multipleHostAccess = <unset>, type = "VMFS", }, |
So what you would do is the following:
Run "vmware-vim-cmd vmsvc/getallvms" [this will list all your VMs, what you need to get is the VMID, which is the identifer for each VM and loop through that output and do a vmsvc/get.environment <VMID> and then once you get the environment for each VM, grep out the values you're interested in.
i.e.
#!/bin/sh
echo -e "DISPLAYNAME\tCAPACITY\tFREESPACE"
for vm in `vmware-vim-cmd vmsvc/getallvms | awk '{print $1}'`;
do
DISPLAYNAME=`vmware-vim-cmd vmsvc/get.summary "$" | grep name | awk '{print $3}' | sed 's/"//g' | sed 's/,//g'` CAPACITY=`vmware-vim-cmd vmsvc/get.environment "$" | grep capacity
| awk '{print $3}' | sed 's/"//g' | sed 's/,//g'`
FREESPACE=`vmware-vim-cmd vmsvc/get.environment "$" | grep
freespace | awk '{print $3}' | sed 's/"//g' | sed 's/,//g'`
echo -e "$\t$\t$"
done
Here is just a quick and dirty example on how you can pull out the VM Name, Capacity, Freespace (output looks like in bytes). Different vimsh commands will give you different output, they're all in an XML format tag, so you might want to create special XML Parser if any of the querable fields span more than 1 item to retrieve what you're looking for. Aagain, you an probably get most of this just out of the .vmx and get the .vmdk size, but if you're inclined to pull everything via commandline through built in commands, you'll want to play wth "vimsh / vmware-vim-cmd"