VMware Cloud Community
SithL0rd
Contributor
Contributor

cpu stats

I am looking to pull cpu average, cpu min, cpu max in mhz for all of the vms in managed by vcenter. I would like to get one weeks worth of these numbers. I am using get-vm | get-stattype cpu.usage.average... though i am getting an error that says get-stattype cannot be used in a pipeline. Any help would be greatly appreciated.

0 Kudos
3 Replies
LucD
Leadership
Leadership

To retrieve the metrics you'll need the Get-Stat cmdlet.

Have a look at my PowerCLI & vSphere statistics – Part 1 – The basics to see how the Get-Stat cmdlet works.

The following is a simple example how this could be done

$start = (Get-Date).AddDays(-7)
$metrics = "cpu.usagemhz.average","cpu.usagemhz.maximum","cpu.usagemhz.minimum"

Get-VM
| Get-Stat -Start $start -Stat $metrics |
Select
TimeStamp,@{N="VM";E={$_.entity.Name}},MetricId,Value


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

SithL0rd
Contributor
Contributor

Thanks LucD. I'll review your page. if i have any questions on putting the script together should i post them here or on your site?

0 Kudos
LucD
Leadership
Leadership

Whatever you prefer, I read posts on both Smiley Happy


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

0 Kudos