PowerCLI

 View Only
  • 1.  cpu stats

    Posted Feb 01, 2013 07:56 PM

    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.



  • 2.  RE: cpu stats

    Posted Feb 01, 2013 09:13 PM

    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


  • 3.  RE: cpu stats

    Posted Feb 01, 2013 10:03 PM

    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?



  • 4.  RE: cpu stats

    Posted Feb 01, 2013 10:12 PM

    Whatever you prefer, I read posts on both :smileyhappy: