Hey guys,
I'm new to the PowerCLI utility, and I'm noticing a lot of references in sample scripts for cpu.usage.average, cpu.usage.maximum, and cpu.usage.minimum. I've figured out a few scripts using those statistics, but I'm looking for something a little more Realtime.
Is there a way to pull Realtime CPU/Memory/Network statistics from all hosts and/or VMs in vCenter using PowerCLI (or any other scriptable method?). I'd like to take this data and feed it into Dashing to integrate App server data with Oracle database data that we already have semi-working through OEM. (Dashing - The exceptionally handsome dashboard framework.)
Thanks for helping!
With the Get-Stat cmdlet you can also fetch Realtime statistics.
The sample interval in that case is 20 seconds.
Another option is to use the Get-Esxtop cmdlet, that will you data in 5 second intervals.
But the use of that cmdlet is not really for the faint of hearth imho :smileygrin:
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD,
So far I've got this:
Get-VMHost | Get-Stat -Stat cpu.usage.average -MaxSamples 1 -IntervalMins 5 -Realtime | foreach { $_.Value } | Measure-Object -Average | select Average | Format-Table -HideTableHeaders
That works, but it looks like it gives me CPU average for all CPU's across all hosts. Is there an easy way to feed that Get-VMhost to a foreach so that it runs that Get-Stat section for each host?
Thanks again,
The way I would do this is to call Get-Stat for all the hosts (like you did).
But then use a Group-Object cmdlet on the result, and thus split it up in an object per host.
You'll find an example of that in my PowerCLI & vSphere statistics – Part 2 – Come together post.
Note, if you ask for Realtime, don't specify the IntervalMins parameter as well
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Ok, so here's what I've got now...
Get-VMHost | foreach-object {$x=(Get-Stat -Entity $_.name -Stat cpu.usage.average -MaxSamples 1 -Realtime | foreach { $_.Value } | Measure-Object -Average | select Average | Format-Table -HideTableHeaders);echo $_.name $X}
That's pretty functional I think...
Yes, that will work.
But you are still calling Get-Stat once for each ESXi host.
That could be quite time-consuming in a bigger environment.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference