VMware Cloud Community
derRalf
Contributor
Contributor
Jump to solution

Poor API Performance

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

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

Reply
0 Kudos
11 Replies
mcowger
Immortal
Immortal
Jump to solution

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.

--Matt VCDX #52 blog.cowger.us
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
derRalf
Contributor
Contributor
Jump to solution

THX!

much faster

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
derRalf
Contributor
Contributor
Jump to solution

10 minutes to 24 secs 😉

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Thanks, and approximately how many clusters and hosts are we talking about ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
derRalf
Contributor
Contributor
Jump to solution

about 43 Custers with 503 ESX-Hosts

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Thanks again.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
derRalf
Contributor
Contributor
Jump to solution

an additional question:

how do I know what for view and what for parameter are available?

in https://virtualcenter/mob I've nothing found...

Reply
0 Kudos
RvdNieuwendijk
Leadership
Leadership
Jump to solution

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

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos