2 Replies Latest reply on Feb 2, 2011 7:54 AM by mattboren

    Script for indentifying how many sockets are in vCenter?

    peter79 Enthusiast

      We are currently reviewing our licenses and I was wondering is there a way of writing a script that will list how many processors are present in all the hosts in vCenter and also output the results to a CSV file?

        • 1. Re: Script for indentifying how many sockets are in vCenter?
          mattboren Master
          vExpert

          Hello, @peter79-

           

          Thanks to the Hardware.CpuInfo.NumCpuPackages property of the HostSystem .Net view object (where NumCpuPackages is the number of physical processors in the host), this is pretty straightforward:

          Get-View -ViewType HostSystem -Property Name,Hardware.CpuInfo.NumCpuPackages | Select-Object Name,@{n="NumCpuPkgs"; e={$_.Hardware.CpuInfo.NumCpuPackages}} | Export-Csv -NoTypeInformation C:\temp\VMHostCPUCounts.csv
          

           

          And, since this one-liner uses the Get-View cmdlet and specifies to return only two (2) properties, it should be quite fast (took less than one second to get this CPU socket count info for about 175 hosts for me).

           

          Enjoy

          • 2. Re: Script for indentifying how many sockets are in vCenter?
            mattboren Master
            vExpert

            Hey again, @peter79-

             

            As I thought a bit more about it, if it is just the total CPU count that you desire, you could do something like:

            Get-View -ViewType HostSystem -Property Name,Hardware.CpuInfo.NumCpuPackages | Select-Object Name,@{n="NumCpuPkgs"; e={$_.Hardware.CpuInfo.NumCpuPackages}} | Measure-Object -Sum -Property NumCpuPkgs | Select-Object @{n="NumHosts"; e={$_.Count}}, @{n="TotalCPUs"; e={$_.Sum}}
            

             

            This returns the sum of the CPU count, along with the number of hosts.  So, if you do not need per-host CPU info, just a sum, you could go this route.

             

            Enjoy

             

            Message was edited by mattboren at 10:53a EST on 02 Feb 2011:  code snipped was truncated.  Corrected.

            1 person found this helpful