Our native vSphere client does not allow us to collect performance report of multiple entities in one shot. I wrote the below script which can grab performance report of multiple VMs in a single csv file. We can use the data in csv, draw charts, get a clear view and comparison of resource utilization / performance of multiple VMs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################## | |
# Script for collecting performance report of multiple VMs # | |
################################################################## | |
$vCenter = Read-Host "Enter the vCenter name wherein the target cluster resides" | |
$list = Read-Host "Enter path to text file that contains list of VMs to which performance report need to be grabbed" | |
$sdate = Get-Date (Read-Host "Enter start date of the report(mm/dd/yyyy)") | |
$fdate = Get-Date (Read-Host "Enter finish date of the report(mm/dd/yyyy)") | |
$nsamples = Read-Host "How many samples you want to be retrieved in specified interval" | |
$VMs = Get-Content $list | |
$stats = @() | |
Connect-VIServer $vCenter | |
foreach($VM in $VMs) | |
{ | |
Write-Host "Collecting data for" $VM "…" | |
$stats += Get-Stat -Entity $VM -Common -MaxSamples $nsamples -Start $sdate -Finish $fdate | |
} | |
$stats | Export-Csv -Path .\PerfResult.csv -Force -NoTypeInformation | |
Invoke-Item .\PerfResult.csv | |
Disconnect-VIServer $vCenter -Confirm:$false |
You need to supply the data in format according to date setting in local system in which script is being executed (mm/dd/yyyy in my case).
The –Common switch in Get-Stat commandlet retrieves the below metrics by default.
cpu.usage.average
cpu.usagemhz.average
mem.usage.average
disk.usage.average
net.usage.average
sys.uptime.latest
However more mertics can be retrieved using -Stat switch by supplying input in format – “counter group”.”counter name”.”rollup type”, Eg : cpu.usage.min.
The below is the nice pivot chart I got, showing the average CPU usage of two VMs over time (stacked graph).
Thanks for reading !
Please, can you put the script?? Thanks.
LikeLike
It is available here – https://gist.github.com/prakashhce/20fc9b7cec30a1504e77#file-vmperfreport-ps1
LikeLike