Automation

 View Only
  • 1.  VMHost average Compute consumption for one day

    Posted Dec 16, 2020 09:29 AM

    Hello,

     

    Just to have the average for thelast 24 hours for CPU and memory consumtpion on VMhosts.

     

    Thus article by LUCD https://www.lucd.info/2010/01/05/powercli-vsphere-statistics-part-2-come-together/ is awesome, but I needed something much simpler.

     

    Thanks,



  • 2.  RE: VMHost average Compute consumption for one day

    Posted Dec 16, 2020 09:45 AM

    Simpler in what sense?



  • 3.  RE: VMHost average Compute consumption for one day

    Posted Dec 16, 2020 12:30 PM

    Simpler in the use I meant .>> I just want to generate a report of the average of each ESXi host, with a single value, not the average for each day, if I specified a range of days I mean. I hope it's a bit clear now, and pardon me if I'm mistaken about something.



  • 4.  RE: VMHost average Compute consumption for one day

    Posted Dec 16, 2020 12:51 PM

    You mean something like this?

    Get-VMHost -Name "my-ESX-hostname" | 
    Get-Stat -Start (Get-Date).AddDays(-1) -Stat 'cpu.usage.average' |
    Measure-Object -Property Value -Average |
    Select -ExpandProperty Average


  • 5.  RE: VMHost average Compute consumption for one day

    Posted Dec 21, 2020 10:55 AM

    Thanks a lot. what's the possibility of having also the average of memory, along with the host name please?

     

    I'm using this format:

     

    foreach {$i in $host1) { get-VMHost -Name $i | Get-Stat -Start (Get-Date).AddDays(-1) -Stat 'cpu.usage.average' | Measure-Object -Property Value -Average |Select -ExpandProperty Average }



  • 6.  RE: VMHost average Compute consumption for one day

    Posted Dec 21, 2020 11:22 AM

    You could do something like this.
    But that is probably not 'simple' enough 

    Get-VMHost -Name $host1 |
    Get-Stat -Start (Get-Date).AddDays(-1) -Stat 'cpu.usage.average','mem.usage.average' -Instance '' |
    Group-Object -Property {$_.Entity.Name} |
    ForEach-Object -Process {
        New-Object -TypeName PSObject -Property @{
            VMHost = $_.Name
            CPU = [math]::Round(($_.Group | where{$_.MetricId -eq 'cpu.usage.average'} |
                Measure-Object -Property Value -Average |
                Select -ExpandProperty Average),1)
            Memory = [math]::Round(($_.Group | where{$_.MetricId -eq 'mem.usage.average'} |
                Measure-Object -Property Value -Average |
                Select -ExpandProperty Average),1)
        }
    }