Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 220961

Re: Script to Generate IOPS Report

$
0
0

You mean something like this ?

It collects the IOPS for the complete previous day and send the result via email

 

$metrics="disk.numberwrite.summation","disk.numberread.summation"
$finish=Get-Date-Hour0-Minute0-Second0
$start=$finish.AddDays(-1)
$report=@()

$vms=Get-VM|where {$_.PowerState-eq"PoweredOn"}
$stats=Get-Stat-Stat$metrics-Entity$vms-Start$start-Finish$finish
$interval=$stats[0].IntervalSecs

$lunTab=@{}
foreach($dsin (Get-Datastore-VM$vms|where {$_.Type-eq"VMFS"})){
 
$ds.ExtensionData.Info.Vmfs.Extent|%{
   
$lunTab[$_.DiskName] =$ds.Name
  }
}

$report=$stats|Group-Object-Property {$_.Entity.Name},Instance|%{
 
$readStat=$_.Group|
   
where{$_.MetricId-eq"disk.numberread.summation"} |
   
Measure-Object-PropertyValue-Average-Maximum
 
$writeStat=$_.Group|
   
where{$_.MetricId-eq"disk.numberwrite.summation"} |
   
Measure-Object-PropertyValue-Average-Maximum
 
New-ObjectPSObject-Property@{
   
VM=$_.Values[0]
   
Start=$start
   
Finish=$finish
   
Disk=$_.Values[1]
   
IOPSWriteMax= [math]::Round($writeStat.Maximum/$interval,0)
   
IOPSWriteAvg= [math]::Round($writeStat.Average/$interval,0)
   
IOPSReadMax= [math]::Round($readStat.Maximum/$interval,0)
   
IOPSReadAvg= [math]::Round($readStat.Average/$interval,0)
   
Datastore=$lunTab[$_.Values[1]]
  }
}

Send-MailMessage-Subject"IOPS Report"-Fromlucd@lucd.info`
 
-Tolucd@lucd.info-SmtpServermail.lucd.info`
 
-BodyAsHtml-Body ($report|SelectVM,Start,Finish,Disk,Datastore,IOPSWriteAvg,
   
IOPSWriteMax,IOPSReadAvg,IOPSReadMax|ConvertTo-Html|Out-String)

Viewing all articles
Browse latest Browse all 220961

Trending Articles



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