Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 179681

Capacity Planning via PowerCLI

$
0
0

Hello,

 

In regards to Capacity Planning for ESXi 5.x, I have seen various examples on capturing capacity utilizations for CPU, Memory, Number of ESXi Hosts, Number VMs, etc. at the Cluster level, and I’d like to execute this in one PowerCLI Script and exported to one .CSV file.  I don’t need Datastore statistics.

 

On JONATHAN MEDD'S BLOG, the URI below is great, however I’d like to have more control; add number of Hosts and VMs for the Cluster(s) I specify, and exported to a .CSV file.

http://www.jonathanmedd.net/2012/01/basic-cluster-vmware-capacity-check-with-powercli.html

 

Thank you!

vJoe34 <><


Below is what I’m trying to accomplish (.PS1 has also been attached):


###################################################################################


# I'd like to be able to specify multiple Cluster names - need help with correct syntax

Get-ClusterCapacityCheck -ClusterName "HA Cluster 1, HA Cluster 2, HA Cluster 3"

 

# Wasn't sure to put next line inside or outside the "function" and I'd like the data in one .CSV

$allLines = @()

 

function Get-ClusterCapacityCheck {

 

[CmdletBinding()]

param(

[Parameter(Position=0,Mandatory=$true,HelpMessage="Name of the cluster to test",

ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$true)]

[System.String]

$ClusterName

)

 

begin {

# Going back 7 days

$Finish = (Get-Date -Hour 0 -Minute 0 -Second 0)

$Start = $Finish.AddDays(-7).AddSeconds(1)

 

New-VIProperty -Name FreeSpaceGB -ObjectType Datastore -Value {

param($ds)

[Math]::Round($ds.FreeSpaceMb/1KB,0)

} -Force

}

 

process {

$Cluster = Get-Cluster $ClusterName

 

# Next two lines I've added, is for Number of Hosts and VMs in the Cluster - need help with correct syntax

$ClusterNumHosts = Get-Cluster $ClusterName | ($_ | Get-VMHost).Count

$ClusterNumVMs = Get-Cluster $ClusterName | ($_ | Get-VM).Count

 

$ClusterCPUCores = $Cluster.ExtensionData.Summary.NumCpuCores

$ClusterEffectiveMemoryGB = [math]::round(($Cluster.ExtensionData.Summary.EffectiveMemory / 1KB),0)

 

$ClusterAllocatedvCPUs = ($ClusterVMs | Measure-Object -Property NumCPu -Sum).Sum

$ClusterAllocatedMemoryGB = [math]::round(($ClusterVMs | Measure-Object -Property MemoryMB -Sum).Sum / 1KB)

 

$ClustervCPUpCPURatio = [math]::round($ClusterAllocatedvCPUs / $ClusterCPUCores,2)

$ClusterActiveMemoryPercentage = [math]::round(($Cluster | Get-Stat -Stat mem.usage.average -Start $Start -Finish $Finish | Measure-Object -Property Value -Average).Average,0)

 

# Next line I've added, is for average CPU Percentage for the Cluster - need help with correct syntax

$ClusterActiveCPUPercentage = [math]::round(($Cluster | Get-Stat -Stat cpu.usage.average -Start $Start -Finish $Finish | Measure-Object -Property Value -Average).Average,0)

 

New-Object -TypeName PSObject -Property @{

 

# I'd like the output in the .CSV file to be in this order

$Report.ClusterName = $Cluster.Name

$Report.ClusterNumHosts = $ClusterNumHosts

$Report.ClusterNumVMs = $ClusterNumVMs

$Report.ClusterActiveCPUPercentage = $ClusterActiveCPUPercentage

$Report.ClusterCPUCores = $ClusterCPUCores

$Report.ClusterAllocatedvCPUs = $ClusterAllocatedvCPUs

$Report.ClustervCPUpCPURatio = $ClustervCPUpCPURatio

$Report.ClusterEffectiveMemoryGB = $ClusterEffectiveMemoryGB

$Report.ClusterAllocatedMemoryGB = $ClusterAllocatedMemoryGB

$Report.ClusterActiveMemoryPercentage = $ClusterActiveMemoryPercentage

 

$allLines += $Report

 

}}}

 

#Again, wasn't sure to put next line inside or outside the "function" and I'd like the data in one .CSV

$allLines | Export-Csv ".\vSphereClusterReport.csv" -NoTypeInformation

 

###################################################################################


Viewing all articles
Browse latest Browse all 179681

Trending Articles



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