vsphere powercli/powershell – VM average performance stats for x number of days

execute the code below after connecting to your VI server: change values as needed:

 

example:

C:\PS>Connect-VIServer -Server 10.23.112.235 -Protocol https -User Administrator
 -Password pass01

 

Get-VM | where {$_.name -like “*publ*”} | Select Name, VMHost, NumCpu, MemoryMB, `
@{N=”CPU Usage (Average), Mhz” ; E={[Math]::Round((($_ | Get-Stat -Stat cpu.usagemhz.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}}, `
@{N=”Memory Usage (Average), %” ; E={[Math]::Round((($_ | Get-Stat -Stat mem.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} , `
@{N=”Network Usage (Average), KBps” ; E={[Math]::Round((($_ | Get-Stat -Stat net.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} , `
@{N=”Disk Usage (Average), KBps” ; E={[Math]::Round((($_ | Get-Stat -Stat disk.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} |`
Export-Csv -Path d:\centrilogic\scripts\AverageUsage.csv

 

output: servername —left blank below intentionally.

Name CPU Usage (Average), Mhz Memory Usage (Average), % Network Usage (Average), KBps Disk Usage (Average), KBps
119.6 7.92 16.49 232.47
90.76 2.89 102.71 92.56
19.91 2.44 10.3 74.68
33.01 3.23 8.42 88.35
13.53 5.25 1.29 13.57
3.64 0.13 0.04 4.02
2.52 0.14 0.01 1.56
7.81 4.68 0 6.23
11.07 1.79 0 3.37
16.04 4.23 1.11 35.89
29.24 3.61 3.69 1.12
13.96 2.64 1.03 26.45
132.05 6.52 116.8 118.66
99.52 8.67 108.45 118.32
40.97 3.97 0.04 6.76
17.5 1.05 4.39 3.31
17.25 1.17 3.89 1.64
20.39 3.68 7.95 4.19
21.33 3.71 8.56 5.61

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories

Best Buy Co, Inc.
Best Buy Co, Inc.
Best Buy Co, Inc.