KB: Find the number of processor sockets in your VMware environment

This article offers two tools to retrieve the number of processor sockets in your VMware environment. You need to know the number of processor sockets when using the VMware Management Pack because each processor socket requires a license.

You can download a zip file containing the OpsLogix.VMware.HostInventory command line tool here. This tool will connect to your vCenter server and retrieve the number of processor sockets per ESXi host and the total count.

 

You can also run a PowerShell script if you have the VMware PowerCLI installed:

Video

## ===========================================================
## GetCoreAndSocketCount.ps1
## ===========================================================
## Vmware license inventory script
## OpsLogix
## Michel Kamp
## -----------------------------------------------------------
## This Script counts the number of sockets over all ESX hosts 
## that are member of the VCenter connection
## -----------------------------------------------------------
## Requirements:
##        -        vSphere PowerCLI must be installed.
##                Can be downloaded from www.vmware.com
##                https://my.vmware.com/group/vmware/details?downloadGroup=PCLI630R1&productId=491
##        -        run using logged on as top level account
## Configuration:
##        -        Change $VCenter to the VCenter server name.
##                Or run it directly on the VCenter server.
## ===========================================================


$VCenter = "localhost"


## Connecto to Vcenter
Connect-viserver -Server $VCenter


## get the cpu inventory
$result = @() 
$EsxHosts = Get-view  -ViewType HostSystem 
 foreach ($EsxHost in $EsxHosts) { 
     $obj = new-object psobject 
     $obj | Add-Member -MemberType NoteProperty -Name name -Value $EsxHost.Name 
     $obj | Add-Member -MemberType NoteProperty -Name CPUSocket -Value $EsxHost.hardware.CpuInfo.NumCpuPackages 
     $obj | Add-Member -MemberType NoteProperty -Name Corepersocket -Value $EsxHost.hardware.CpuInfo.NumCpuCores 
     $obj | Add-Member -MemberType NoteProperty -Name TotalCores -Value ($EsxHost.hardware.CpuInfo.NumCpuPackages * $EsxHost.hardware.CpuInfo.NumCpuCores) 
     $result += $obj 
 } 


 ## provide full details
 Write-Output "Overview of all sockets and cores per ESX host"
 $result  | ft *
 
 ## calculate the total sockets
 Write-Output "Total Socket count from all ESX hosts"
 ($result | Measure-Object -Property CPUSocket -Sum).Sum
 
 ## calculate the total cores
 Write-Output "Total Core Count over all Sockets from all ESX hosts"
 ($result | Measure-Object -Property TotalCores -Sum).sum
 
## ===========================================================
## End script
## ===========================================================