Optional Stats Collection.

Temporary workaround for problems with vSphere  6.x
This commit is contained in:
mycloudrevolution
2016-11-28 11:19:09 +01:00
parent c2bd42eb6c
commit a0d2450ff1

View File

@@ -8,6 +8,7 @@ function Recommend-Sizing {
=========================================================================== ===========================================================================
Changelog: Changelog:
2016.11 ver 1.0 Base Release 2016.11 ver 1.0 Base Release
2016.11 ver 1.1 Optional Stats Collection.
=========================================================================== ===========================================================================
External Code Sources: External Code Sources:
http://www.lucd.info/2011/04/22/get-the-maximum-iops/ http://www.lucd.info/2011/04/22/get-the-maximum-iops/
@@ -26,7 +27,7 @@ function Recommend-Sizing {
This Function collects Basic vSphere Informations for a Hardware Sizing Recomamndation. Focus is in Compute Ressources. This Function collects Basic vSphere Informations for a Hardware Sizing Recomamndation. Focus is in Compute Ressources.
.Example .Example
Recommend-Sizing -ClusterNames Cluster01, Cluster02 -StatsRange 480 -Verbose Recommend-Sizing -ClusterNames Cluster01, Cluster02 -Stats -StatsRange 60 -Verbose
.Example .Example
Recommend-Sizing -ClusterNames Cluster01, Cluster02 Recommend-Sizing -ClusterNames Cluster01, Cluster02
@@ -37,6 +38,11 @@ function Recommend-Sizing {
.PARAMETER ClusterNames .PARAMETER ClusterNames
List of your vSphere Cluser Names to process. List of your vSphere Cluser Names to process.
.PARAMETER Stats
Enables Stats Collection.
Warning: At the moment this is only tested and supported with vSphere 5.5!
.PARAMETER StatsRange .PARAMETER StatsRange
Time Range in Minutes for the Stats Collection. Time Range in Minutes for the Stats Collection.
Default is 24h. Default is 24h.
@@ -49,12 +55,18 @@ function Recommend-Sizing {
param( param(
[Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)] [Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)]
[Array] $ClusterNames, [Array] $ClusterNames,
[Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=1)] [Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=2)]
[switch] $Stats,
[Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=2)]
[int] $StatsRange = 1440 [int] $StatsRange = 1440
) )
Begin { Begin {
[int]$TimeRange = "-" + $StatsRange if ($Stats) {
Write-Warning "Stats Collection enabled.`nAt the moment this is only tested and supported with vSphere 5.5"
[int]$TimeRange = "-" + $StatsRange
}
$Validate = $True $Validate = $True
#region: Check Clusters #region: Check Clusters
Write-Verbose "$(Get-Date -Format G) Starting Cluster Validation..." Write-Verbose "$(Get-Date -Format G) Starting Cluster Validation..."
@@ -108,27 +120,32 @@ Process {
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Memory Details completed" Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Memory Details completed"
#endregion #endregion
#region: Creating Disk Metrics if ($Stats) {
Write-Verbose "$(Get-Date -Format G) Create $($Cluster.name) IOPS Metrics..." #region: Creating Disk Metrics
$DiskMetrics = "virtualDisk.numberReadAveraged.average","virtualDisk.numberWriteAveraged.average" Write-Verbose "$(Get-Date -Format G) Create $($Cluster.name) IOPS Metrics..."
$start = (Get-Date).AddMinutes($TimeRange) $DiskMetrics = "virtualDisk.numberReadAveraged.average","virtualDisk.numberWriteAveraged.average"
$DiskStats = Get-Stat -Stat $DiskMetrics -Entity $ClusterVMsPoweredOn -Start $start -Verbose:$False $start = (Get-Date).AddMinutes($TimeRange)
Write-Verbose "$(Get-Date -Format G) Create $($Cluster.name) IOPS Metrics completed" $DiskStats = Get-Stat -Stat $DiskMetrics -Entity $ClusterVMsPoweredOn -Start $start -Verbose:$False
#endregion Write-Verbose "$(Get-Date -Format G) Create $($Cluster.name) IOPS Metrics completed"
#endregion
#region: Creating IOPS Reports
Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) IOPS Report..." #region: Creating IOPS Reports
$reportDiskPerf = @() Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) IOPS Report..."
$reportDiskPerf = $DiskStats | Group-Object -Property {$_.Entity.Name},Instance | %{ $reportDiskPerf = @()
New-Object PSObject -Property @{ $reportDiskPerf = $DiskStats | Group-Object -Property {$_.Entity.Name},Instance | %{
IOPSMax = ($_.Group | ` New-Object PSObject -Property @{
Group-Object -Property Timestamp | ` IOPSMax = ($_.Group | `
%{$_.Group[0].Value + $_.Group[1].Value} | ` Group-Object -Property Timestamp | `
Measure-Object -Maximum).Maximum %{$_.Group[0].Value + $_.Group[1].Value} | `
Measure-Object -Maximum).Maximum
}
} }
Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) IOPS Report completed"
#endregion
}
else {
Write-Verbose "$(Get-Date -Format G) Stats Cellocetion skipped..."
} }
Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) IOPS Report completed"
#endregion
#region: Create VM Disk Space Report #region: Create VM Disk Space Report
Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) VM Disk Space Report..." Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) VM Disk Space Report..."
@@ -174,11 +191,11 @@ Process {
PhysicalMemoryGB = $PhysicalMemory PhysicalMemoryGB = $PhysicalMemory
AllocatedVMMemoryGB = $AllocatedVMMemoryGB AllocatedVMMemoryGB = $AllocatedVMMemoryGB
ClusterMemoryUsage = "$MemoryUsage %" ClusterMemoryUsage = "$MemoryUsage %"
SumMaxVMIOPS = [math]::round( ($reportDiskPerf | Measure-Object -Sum -Property IOPSMax).sum, 1 )
AverageMaxVMIOPs = [math]::round( ($reportDiskPerf | Measure-Object -Average -Property IOPSMax).Average,1 )
SumVMDiskSpaceGB = [math]::round( ($reportDiskSpace | Measure-Object -Sum -Property CapacityGB).sum, 1 ) SumVMDiskSpaceGB = [math]::round( ($reportDiskSpace | Measure-Object -Sum -Property CapacityGB).sum, 1 )
SumDatastoreSpaceGB = [math]::round( ($DatastoreReport | Measure-Object -Sum -Property CapacityGB).sum, 1 ) SumDatastoreSpaceGB = [math]::round( ($DatastoreReport | Measure-Object -Sum -Property CapacityGB).sum, 1 )
SumDatastoreUsedSpaceGB = [math]::round( ($DatastoreReport | Measure-Object -Sum -Property UsedSpaceGB).sum, 1 ) SumDatastoreUsedSpaceGB = [math]::round( ($DatastoreReport | Measure-Object -Sum -Property UsedSpaceGB).sum, 1 )
SumMaxVMIOPS = [math]::round( ($reportDiskPerf | Measure-Object -Sum -Property IOPSMax).sum, 1 )
AverageMaxVMIOPs = [math]::round( ($reportDiskPerf | Measure-Object -Average -Property IOPSMax).Average,1 )
} }
$MyView += $SizingReport $MyView += $SizingReport
Write-Verbose "$(Get-Date -Format G) Process Global Report completed" Write-Verbose "$(Get-Date -Format G) Process Global Report completed"