VMware Cloud Community
MRoushdy
Hot Shot
Hot Shot

VMHost average Compute consumption for one day

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,

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
Reply
0 Kudos
5 Replies
LucD
Leadership
Leadership

Simpler in what sense?


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

Reply
0 Kudos
MRoushdy
Hot Shot
Hot Shot

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.

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
Reply
0 Kudos
LucD
Leadership
Leadership

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


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

Reply
0 Kudos
MRoushdy
Hot Shot
Hot Shot

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 }

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
Reply
0 Kudos
LucD
Leadership
Leadership

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)
    }
}


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