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,
Simpler in what sense?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
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
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 }
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