Hi,
with powercli performance data could be exported for automatically created reports.
The command let for such task is Get-Stat
Some examples.
To get the whole list for a VM use
1 | PS D:\> Get-Stat -Entity ( Get-vm "MyVM" ) |
This retrieves a list with performance data. By default a value is stored every 20 second.
Filtering is also possible. This gets a list for the last 24 hours.
1 | PS D:\> Get-Stat -Entity ( Get-vm "MyVM" ) -Start (( get-date ).AddDays(-1)) |
Data for a specific time range
1 | PS D:\> Get-Stat -Entity ( Get-vm "MyVM" ) -Start (( get-date ).AddDays(-2)) -Finish (( get-date ).AddDays(-1)) |
Retrieve only specific metric(s)
cpu.usage.average
cpu.usagemhz.average
disk.usage.average
mem.usage.average
net.usage.average
sys.uptime.latest
CPU time in percent
1 | PS D:\> Get-Stat -Entity ( Get-vm "MyVM" ) -Stat "cpu.usage.average" |
CPU time in percent and Mhz
1 | PS D:\> Get-Stat -Entity ( Get-vm "MyVM" ) -Stat @( "cpu.usage.average" , "cpu.usagemhz.average" ) |
cpu.usage.average can also have multiple instances, for example for CPU0, CPU1…
It’s possible to get performance data for a specific class, for example CPU times
1 | PS D:\> Get-Stat -Entity ( Get-vm "MyVM" ) -CPU |
Available classes
-Cpu
-Disk
-Memory
-Network
The default interval of 20 sec can also be motified. This gets values in 5 minute intervals:
1 | PS D:\> Get-Stat -Entity ( Get-vm "MyVM" ) -IntervalMins 5 |
The Realtime switch retrieves the data of the last hour
1 | PS D:\> Get-Stat -Entity ( Get-vm "MyVM" ) -Realtime |
Export the data to a csv for an import in excel
1 | PS D:\> Get-Stat -Entity ( Get-vm "MyVM" ) -Realtime |Select -Object Entity,Timestamp,Value |Export -Csv -Delimiter ";" -LiteralPath D:\Temp\perfdata.txt |
Michael
Thanks, but if seeking memory stats, what format is the output? is it in KB, MB, or GB?
Running this command [PS D:\> Get-Stat -Entity (Get-vm “MyVM”) -Start ((get-date).AddDays(-1))], but screen still only shows output in 20-second intervals for past hour. Any thoughts why?