VMware {code} Community
dmitrif
Enthusiast
Enthusiast
Jump to solution

what managed entities are performance providers?

Hi folks,

What managed entities are performance providers?

Obviously HostSystem and VirtualMachine. They work just fine to me.

What's about Network? Datastore? ResourcePool? ComputeResource? ClusterComputeResource?

To me they fail to provide performance statistics ...

Maybe they need to be addressed by MOR from a specific node on the object instances tree?

The VI API reference instead of listing, gives them a brilliant description 8-/:

"Those managed entities that are capable of returning performance statistics are Performance Providers."

As useful as it gets...

Thanks in advance.

D.
0 Kudos
1 Solution

Accepted Solutions
DougBaer
Commander
Commander
Jump to solution

Bottom line is that you appear to be able to get Realtime performance stats from HostSystem and VirtualMachine objects, but summary performance only for ComputeResource, ClusterComputeResource and ResourcePool objects.

Doug Baer, Solution Architect, Advanced Services, Broadcom | VCDX #019, vExpert 2012-23

View solution in original post

0 Kudos
15 Replies
DougBaer
Commander
Commander
Jump to solution

I'll use Powershell since that's what I'm working with at the moment...

  1. get the moref of the PerfManager

PS> $perfMoRef = (get-view ServiceInstance).Content.PerfManager

#get the moref for a VM

PS> $vmMoRef = (get-vm MYVM01 | get-view).Moref

#grab the counters for the last hour

PS> $counters = (get-view $perfMoRef).QueryAvailablePerfMetric($vmMoRef,(Get-Date).AddHours(-1),(Get-Date),20)

As you mentioned, this works for the VM

When I try the same for a cluster:

PS> $counters_for_cluster = (get-view $perfMoRef).QueryAvailablePerfMetric($clMoRef,(Get-Date).AddHours(-1),(Get-Date),20)

I get

Exception calling "QueryAvailablePerfMetric" with "4" argument(s): "A specified parameter was not correct.

interval"

At line:1 char:65

+ $counters_for_cluster = (get-view $perfMoRef).QueryAvailablePerfMetric( <<<< $clMoRef,(Get-Date).AddHours(-1),(Get-Date),20)

(Note... I revisited the above after getting to the bottom... setting the interval (4th parm) to -1 returned an array of perfMetric IDs)... maybe that's the key ???

So, I tried another approach (using powershell cmdlets rather than trying to navigate the objects):

PS> get-cluster | get-stat -common

PS> get-resourcepool | get-stat -common

... both return data for "cpu.usagemhz.average" and "mem.usage.average" metrics.

As expected,

PS> get-vmhost | get-stat -common

returns a boatload of data and

PS> get-datastore | get-stat -common

returns a bunch of errors.

Something else interesting is this... the VM supports realtimne stats while the cluster only supports summary stats

#cluster

PS> (get-view $perfMoRef).QueryPerfProviderSummary($clMoRef)

Entity : VMware.Vim.ManagedObjectReference

CurrentSupported : False

SummarySupported : True

RefreshRate : -1

#vm

PS> (get-view $perfMoRef).QueryPerfProviderSummary($vmMoRef)

Entity : VMware.Vim.ManagedObjectReference

CurrentSupported : True

SummarySupported : True

RefreshRate : 20

If this doesn't help, I'll look at it in Perl, but it may take a few days for me to get back to it.

Doug

Doug Baer, Solution Architect, Advanced Services, Broadcom | VCDX #019, vExpert 2012-23
DougBaer
Commander
Commander
Jump to solution

... Oh, and I found a list as soon as I posted before :smileygrin:

Go to page 108-110 of this doc

http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/visdk25programmingguide.pdf

Sorry, formatting the table so it would look nice in the forum post wasn't going to happen!

Doug Baer, Solution Architect, Advanced Services, Broadcom | VCDX #019, vExpert 2012-23
dmitrif
Enthusiast
Enthusiast
Jump to solution

Thanks Doug,

I have a C# code that can tell whether a managed object is a performance provider, it is not a problem.

Yes, the guide has kind of list of the objects.

I was hoping for more Smiley Happy.

D.
0 Kudos
dmitrif
Enthusiast
Enthusiast
Jump to solution

Thanks Doug, I appreciate you answering my post

D.
0 Kudos
DougBaer
Commander
Commander
Jump to solution

I was hoping for more Smiley Happy.

I've noticed that I spend a bit of time digging for information -- and messing around with the code to see why I get odd errors when I think I should have it right.

I had chalked it up to me learning the API, but I find myself in the same situation, although,for common tasks, the Powershell toolkit hides a lot of the complexity.

Doug Baer, Solution Architect, Advanced Services, Broadcom | VCDX #019, vExpert 2012-23
0 Kudos
dmitrif
Enthusiast
Enthusiast
Jump to solution

I still cannot get QueryPerfProviderSummary from a ComputeResource.

Are you saying I can QueryAvailablePerfMetric on it anyway using -1 the interval ID?

D.
0 Kudos
dsubram
Enthusiast
Enthusiast
Jump to solution

You need to first get MOR of Compute Resource and then use the same with QueryPerf. -1 is not a valid value for interval ID. First you need to query AvailablePerfIntervals for ComputeResource and then use the same for querying performance data.

0 Kudos
DougBaer
Commander
Commander
Jump to solution

When I called

$counters_for_cluster = (get-view $perfMoRef).QueryAvailablePerfMetric($clMoRef,(Get-Date).AddHours(-1),(Get-Date),-1)

on a ClusterResource, it worked. I'll try a ComputeResource in my lab -- but my internet access is a little weak, so I'll have to work fast.

Message was edited by: DougBaer (weird asterisks in code... meant to be bold)

Doug Baer, Solution Architect, Advanced Services, Broadcom | VCDX #019, vExpert 2012-23
0 Kudos
dmitrif
Enthusiast
Enthusiast
Jump to solution

Hi Subramanyam,

This is exactly what I'm doing.

1. I use the ComputeResource instnce MOR to call QueryPerfProviderSummary: it fails (invalid argument)

is this what you call "query AvailablePerfIntervals"?

2. I call QueryAvailablePerfMetric (with the same MOR) to get the list of metric IDs: it fails too (invalid argument)

3. after that I'm suppose to call QueryPerfCounter to get metadata of the available metrics and QueryPerf to get samples.

How different it is from what you're suggesting?

Thanks!

D.
0 Kudos
dmitrif
Enthusiast
Enthusiast
Jump to solution

Thanks Doug for a good advise; I've just installed Powershell with the VMware Infrastructure Toolkit, it really helps to get things straight.

D.
0 Kudos
DougBaer
Commander
Commander
Jump to solution

I don'd know if you've seen this, but VMware has some good sample code here for Perl, Java and C#:

http://www.vmware.com/communities/content/developer/samplecode/

Doug Baer, Solution Architect, Advanced Services, Broadcom | VCDX #019, vExpert 2012-23
0 Kudos
dmitrif
Enthusiast
Enthusiast
Jump to solution

Thanks Doug, I've seen it, the code is so-so, I'm coding something a little bit more sophisticated.

But it gave me some pointers, especially Java samples.

D.
0 Kudos
DougBaer
Commander
Commander
Jump to solution

Glad to hear it. Hitting the VI client, I can pull perf data from Host, VM, Cluster, and Resource Pool objects -- my guess is that this is everything that is a perf provider.

From the API Reference ()

Managed Object - ComputeResource

Description: Represents a set of physical compute resources for a set of virtual machines.

The base type ComputeResource, when instantiated by calling vim.Folder.CreateStandaloneHost, represents a single host.

The subclass ClusterComputeResource represents a cluster of hosts and adds distributed management features such as

availability and resource scheduling. A ComputeResource always has a root ResourcePool associated with it.

Certain types of clusters such as those with VMware DRS enabled and standalone hosts (ESX Server 3) support the

creation of ResourcePool hierarchies. From the Perl Programming Guide:&gt; ==find_entity_view==

Searches the inventory tree for a managed entity that matches the specified entity type. The search begins with

the root folder unless the begin_entity parameter is specified.

Parameters:

view_type – Managed entity type specified as one of these strings:

o “ClusterComputeResource”

o “ComputeResource”

o “Datacenter”

o “Folder”

o “HostSystem”

o “ResourcePool”

o “VirtualMachine”

=== Try some code -- were you using Perl? ===

my $perfmgr_view = Vim::get_view(mo_ref =&gt; Vim::get_service_content()-&gt;perfManager);

my $perfCounterInfo = $perfmgr_view-&gt;perfCounter;

sub GetResource {

my $crs = Vim::find_entity_views(view_type =&gt; $_[0]);

foreach my $cr (@$crs) {

print $_[0]," ", $cr-&gt;name,"\n";

return $cr;

}

}

my $testVM = GetResource('VirtualMachine');

my $PerfSummary = $perfmgr_view-&gt;QueryPerfProviderSummary( entity =&gt; $testVM ) ;

print "currentSupported:",$PerfSummary-&gt;currentSupported,"\n";

print "refreshRate:",$PerfSummary-&gt;refreshRate,"\n";

print "summarySupported:",$PerfSummary-&gt;summarySupported,"\n";

print "\n";

my $testCR = GetResource('ComputeResource');

$PerfSummary = $perfmgr_view-&gt;QueryPerfProviderSummary( entity =&gt; $testCR ) ;

print "currentSupported:",$PerfSummary-&gt;currentSupported,"\n";

print "refreshRate:",$PerfSummary-&gt;refreshRate,"\n";

print "summarySupported:",$PerfSummary-&gt;summarySupported,"\n";

print "\n";

#print Dumper ($testCR) . "\n\n\n";

my $testCCR = GetResource('ClusterComputeResource');

$PerfSummary = $perfmgr_view-&gt;QueryPerfProviderSummary( entity =&gt; $testCCR ) ;

print "currentSupported:",$PerfSummary-&gt;currentSupported,"\n";

print "refreshRate:",$PerfSummary-&gt;refreshRate,"\n";

print "summarySupported:",$PerfSummary-&gt;summarySupported,"\n";

#print Dumper ($testCCR) . "\n\n\n";

__END__

For me, this returns

C:\Scripts\SAMPLES&gt;perl Myperf.pl

VirtualMachine UDA

currentSupported:1

refreshRate:20

summarySupported:1

ComputeResource DL580 Cluster

currentSupported:0

refreshRate:-1

summarySupported:1

ClusterComputeResource DL580 Cluster

currentSupported:0

refreshRate:-1

summarySupported:1

===

This tells me that, for ClusterCompute resources, current data is not kept... only summary. This kind of makes sense since it is an aggregate (assuming that a ComputeResource is, in fact, a ClusterComputeResource).

NOTE: the description for the refreshRate property:

Specifies in seconds the interval between which the system updates performance statistics.

Generally speaking, querying for a metric at a faster rate than this does not yield additional information.

This value applies only to entities that support real-time (current) statistics.

Message was edited by: DougBaer (formatting)

Doug Baer, Solution Architect, Advanced Services, Broadcom | VCDX #019, vExpert 2012-23
0 Kudos
DougBaer
Commander
Commander
Jump to solution

Bottom line is that you appear to be able to get Realtime performance stats from HostSystem and VirtualMachine objects, but summary performance only for ComputeResource, ClusterComputeResource and ResourcePool objects.

Doug Baer, Solution Architect, Advanced Services, Broadcom | VCDX #019, vExpert 2012-23
0 Kudos
dmitrif
Enthusiast
Enthusiast
Jump to solution

That's right, it seems to be the correct picture.

Thanks Doug

D.
0 Kudos