Our vCenter is running virtual and we cannot see any performance bottlenecks.
The vCenter (4.1.0 U1) have round about 500 ESX an 1600 VMs.
The following PS-Script takes over 10 Minutes to compete:
$ESXHosts = Get-VMHost | % {
$esxName = $_.Name
$clusterName = $_.Parent
$_ | Get-VirtualPortGroup | Select @{N="PGName";E={$_.Name}}, @{N="ESXName";E={$esxName}}, @{N="Cluster";E={$clusterName}}
} | Sort-Object -Property PGName, ESXName, Cluster | Where-Object {$_.PGName -eq $VMNetwork} | Select Cluster -Unique
Is this expected???
Is it possible to measure the API performance?
Ralf
Try it like this.
The script only uses the Get-View cmdlet and limits the number of properties returned.
$VMNetwork = "PgName"
$clusterTab = @{}
foreach($cluster in Get-View -ViewType ClusterComputeResource -Property "Name","Host"){ $cluster.Host | %{ $clusterTab[$_] = $cluster.Name } } Get-View -ViewType HostSystem -Property "Name","Config.Network.Portgroup" | % { $esxName = $_.Name $clusterName = $clusterTab[$_.MoRef] $_.Config.Network.PortGroup | `
Where-Object {$_.Spec.Name -eq $VMNetwork} | `
Select @{N="PGName";E={$_.Spec.Name}}, @{N="ESXName";E={$esxName}}, @{N="Cluster";E={$clusterName}} } | Sort-Object -Property PGName, ESXName, Cluster | Select Cluster -Unique
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I suspect whats going on here is your code. Thats a lot of ESX hosts, and when you use the Get-VMHost cmdlet you are retrieve a HUGE amount of info from each one.
Consider moving to the Get-View cmdlet.
Try it like this.
The script only uses the Get-View cmdlet and limits the number of properties returned.
$VMNetwork = "PgName"
$clusterTab = @{}
foreach($cluster in Get-View -ViewType ClusterComputeResource -Property "Name","Host"){ $cluster.Host | %{ $clusterTab[$_] = $cluster.Name } } Get-View -ViewType HostSystem -Property "Name","Config.Network.Portgroup" | % { $esxName = $_.Name $clusterName = $clusterTab[$_.MoRef] $_.Config.Network.PortGroup | `
Where-Object {$_.Spec.Name -eq $VMNetwork} | `
Select @{N="PGName";E={$_.Spec.Name}}, @{N="ESXName";E={$esxName}}, @{N="Cluster";E={$clusterName}} } | Sort-Object -Property PGName, ESXName, Cluster | Select Cluster -Unique
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
THX!
much faster
Would you mind telling us how much faster ?
Alan and myself will do a Best Practices session during VMworld and this looks like a good example for large environments and the Get-View cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
10 minutes to 24 secs 😉
Thanks, and approximately how many clusters and hosts are we talking about ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
about 43 Custers with 503 ESX-Hosts
Thanks again.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
an additional question:
how do I know what for view and what for parameter are available?
in https://virtualcenter/mob I've nothing found...
The PowerCLI Get-View -ViewType parameter accepts the following values:
ComputeResource, ClusterComputeResource, Datacenter, Datastore, Network,
DistributedVirtualPortgroup, DistributedVirtualSwitch, Folder, HostSystem,
ResourcePool, VirtualApp, VirtualMachine, VmwareDistributedVirtualSwitch
You will get this information in the error message if you enter a Managed Object Type that is not valid.
E.g. "Get-View -ViewType Alarm".
Regards, Robert
With the Get-View cmdlet we access the vSphere .Net objects.
These vSphere .Net objects are read-only copies of the actual objects that live in vSphere.
The properties and methods available on these objects are documented in the VMware vSphere API Reference Documentation.
For the objects that Get-View with ViewType returns look in the Managed Objects Types section.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference