I am trying to pull together a PowerCLI script that grabs the "cpu.usagemhz.maximum" values for all VMs on a host/in a cluster, but repeatadly get the above error, which seems to counter what I'm reading and what other people are doing...
For instance, reading the VMware documentation, this counter should be available at a VM level, at level 4 (past year):
However when I run the command to get this I get the following output:
Even running a script that appears to work for others (i.e. that described here: http://communities.vmware.com/thread/439151) doesn't work for me....
Get-Stat : 22/03/2013 11:03:14 Get-Stat The metric counter "cpu.usagemhz.maximum" doesn't exist for entity "Resources".
At C:\Work\Scripts\get-cpu-stats.ps1:5 char:1
+ Get-Stat -Entity $rp -Stat $metrics_rp -Start $midnight.adddays(-1).addminutes(- ...
+ CategoryInfo : ResourceUnavailable: (cpu.usagemhz.maximum:String) [Get-Stat], VimException
+ FullyQualifiedErrorId : Client20_RuntimeDataServiceImpl_CheckUserMetrics_MetricDoesntExist,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetViStats
Can anyone help? It feels like I'm missing something obvious but I can't work it out - I know cpu.usagemhz.maximum is available via vSphere Client performance charts, but it appears not to be available via the API/PowerCLI....
I'm using PowerCLI 5.1 accessing vCenter 5.1 managing hosts running ESXi 5.1
What could happen is that the entity for which you request the metrics didn't exist 1 year ago.
It looks as if Get-Stat looks if there are metrics on the Start date.
Are there performance data for that entity 1 year ago ?
Can you check in the vSphere client ?
Ah, yes good shout - the graphs are all blank before sometime in September... Question marked as answered.
Following on however, I wonder why that counter isn't available in the "Past month" and "Past week" intervals, even though it is via performance charts?