Quantcast
Channel: VMware Communities: Message List - need a script to collect the performance report.
Viewing all articles
Browse latest Browse all 46

Re: need a script to collect the performance report.

$
0
0

Both metrics return results in %

For the 2 hour interval you need to use the 2nd script. Btw the 2 hours interval is the default for that Historical Interval.

See my PowerCLI & vSphere statistics – Part 1 – The basics post for more info on that.

The scripts above display the result on the console. To get the results in a CSV file just pipe the objects coming from the Select to an Export-Csv cmdlet.

 

 

$vms=Get-VM$metric="cpu.usage.average","mem.usage.average"$now=Get-Date-Hour0-Minute0-Second0$finish=$now.AddDays(-$now.Day)$start=$finish.AddMonths(-1).AddDays(1)$finish=$finish.AddDays(1).AddMinutes(-1)$stats=Get-Stat-Entity$vms-Stat$metric-Start$start-Finish$finish
$stats | Group-Object-Property {$_.Entity.Name},{$_.Timestamp} | Select @{N="VM";E={$_.Values[0]}}, @{N="Time";E={$_.Values[1]}}, @{N="CPU";E={($_.Group | where {$_.MetricId -eq"cpu.usage.average"}).Value}}, @{N="Memory";E={($_.Group | where {$_.MetricId -eq"mem.usage.average"}).Value}} |Export-Csv"C:\stat-report.csv"-NoTypeInformation-UseCulture

Viewing all articles
Browse latest Browse all 46

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>