Private/CloudVMSizing.ps1
|
# Helper function to calculate percentile function Get-Percentile { param( [Parameter(Mandatory = $true)] [double[]]$Values, [Parameter(Mandatory = $true)] [ValidateRange(0, 100)] [int]$Percentile ) $sorted = $Values | Sort-Object $index = [math]::Ceiling(($Percentile / 100) * $sorted.Count) - 1 $index = [math]::Max(0, $index) return $sorted[$index] } # Helper function for CPU justification function Get-CPUJustification { param($Status, $Current, $Recommended, $Peak, $Avg) switch ($Status) { "Downsize" { return "CPU utilization peaks at $Peak% with average of $([math]::Round($Avg, 2))%. Reducing from $Current to $Recommended vCPUs will still provide adequate headroom." } "Upsize" { return "CPU utilization peaks at $Peak% with average of $([math]::Round($Avg, 2))%. Increasing from $Current to $Recommended vCPUs will provide better performance and headroom." } "Optimal" { return "CPU utilization peaks at $Peak% with average of $([math]::Round($Avg, 2))%. Current $Current vCPUs configuration is optimal." } } } # Helper function for Memory justification function Get-MemoryJustification { param($Status, $Current, $Recommended, $Peak, $Avg) switch ($Status) { "Downsize" { return "Memory utilization peaks at $([math]::Round($Peak, 2)) MB ($([math]::Round(($Peak / $Current) * 100, 2))%) with average of $([math]::Round($Avg, 2)) MB. Reducing from $Current MB to $Recommended MB will still provide adequate headroom." } "Upsize" { return "Memory utilization peaks at $([math]::Round($Peak, 2)) MB ($([math]::Round(($Peak / $Current) * 100, 2))%) with average of $([math]::Round($Avg, 2)) MB. Increasing from $Current MB to $Recommended MB will prevent potential out-of-memory issues." } "Optimal" { return "Memory utilization peaks at $([math]::Round($Peak, 2)) MB ($([math]::Round(($Peak / $Current) * 100, 2))%) with average of $([math]::Round($Avg, 2)) MB. Current $Current MB configuration is optimal." } } } |