Hello Folks.
We run several vSphere cluster. Each with it's own vCenter Server. I asked myself if there is a possibility to get those information I could see in vSphere Client via a scripting API.
For example I like to gather information about how many VMs running on each Host in a cluster, how many datastores are attatched and which VM is running on which Host. I like to use a script to gather this information and export them in a TXT-, XML-, HTML-File or whatsoever.
Could someone give me a hint how to start? Where could I found information to solve such a task by using the PowerCLI or any Script in Perl, Python or so on? Do you know any good tutorials on this topic?
Thanks in advance.
There are a few options here:
1. Use something like RVTools to do the export - if you haven't seen this tool, check it out.
2. Use PowerCLI - I'd suggest posting in the PowerCLI Community, but I'll get you started with a few bits below
So, firstly install and launch PowerCLI.
Connect to your vCenter using the Connect-VIServer cmdlet.
You can then use Get-VM to get VM information. Similarly, you can use Get-VMHost to get host information, and Get-Cluster to get cluster information.
You can then select what information you are interested in.
e.g. To return a list of all VMs, and the host they are on: Get-VM | Select Name, Host
You can then do things like grouping object based on an attribute.
e.g. To return a count of VMs per host: Get-VM | Group-Object Host | Select Name, Count
If you want to sort anything, use the Sort-Object cmdlet.
e.g. Get-VM | Group-Object Host | Select Name, Count | Sort-Object Count -Desc
You can export various formats by piping to the appropriate cmdlet.
e.g.
Export to CSV: Get-VM | Group-Object Host | Select Name, Count | Sort-Object Count -Desc | Export-CSV -NoTypeInformation C:\temp\VMsPerHost.csv
Export to HTML: Get-VM | Group-Object Host | Select Name, Count | Sort-Object Count -Desc | ConvertTo-HTML | Out-File C:\temp\VMsPerHost.html
You can use the Get-Help cmdlet to get help on any cmdlet, or return a list of cmdlets.
e.g.
Get a list of conversion cmdlets: get-help ConvertTo-*
Get more help for a cmdlet: get-help Get-VM -Full
Hope that helps!
Have a look at William Lam's Healthcheck scripts;
VMware vSphere Health Check Report v5.1.0
I've used them recently on a v5.5 infrastructure and while a few fields weren't quite right it cover 90% of what I needed. It exports in HTML but i'm sure it wouldn't be too hard to modify.
Regards,
Ed
Try this one:
http://www.vmwareguruz.com/free_tools/vcheck-vmware-daily-health-check-report/
Hello.
I decided to install the VMware SDK for Perl on an Ubuntu Scripting VM and give it a try.
Further I checked out RVTools. This ist my Tool of choice. It is possible to run RVTools in Batch-Mode to export all collected information to CSV or XLS. Now it is pretty easy to run some scheduled tasks to get a full inventory of our vCenter Servers.
Thanks a lot for your hints.