With hyper-threading and multi-core CPUs, it isn't easy to find out how many physical CPUs (or sockets) there are on a server. Recently we were given such a task to ensure we were properly licensed. Since Microsoft's CPU licensing scheme is per socket, we can't just look in Task Manager or Computer Properties as we'll see the virtual CPU count. Due to this, I did some searching to find out if the number of sockets could be queried in the registry or if there was some other method available. I was unable to find any registry solution, but I was able to find three free tools. These tools are CPUCount, Process Explorer, and WinAudit.
CPUCount is a tool from Intel that detects multi-core processor topology in an IA-32 platform. It provides exactly the information that I am after but only on Intel servers. It does not provide the correct information on AMD servers with multi-core processors as seen on both of our 4-node clusters that use AMD hardware. Also, I was unclear whether it provided accurate information about 64-bit Intel servers. Due to both of these, I went searching for other tools.
CPUCount with inaccurate information on AMD hardware (our server has 4 dual-core CPUs):
Process Explorer is one of the tools available in the Sysinternals Suite, which is a collection of "utilities to help you manage, troubleshoot and diagnose your Windows systems and applications." To get to the physical CPU count, go to "System Information..." in the "View" menu. Tick the box for "Show one graph per CPU". The information is shown graphically in the "CPU Usage History" section. On one of my systems, we have 4 dual-core CPUs. Using Process Explorer, I can graphically see the 8 CPUs as well as the 4 sockets due to how it is grouped.
Process Explorer showing the correct information graphically (in red, yellow shows the sockets):
WinAudit is a tool from PXServer that reports on computer inventory and configuration. Once you launch the tool, click either the "Audit button" or the "Here" link. Since it collects a lot of information, it will take a few seconds to render. The physical CPU count is on the first page presented to us, which is "System Overview", in the "Number of Processors" field.
WinAudit showing the correct information (removed sensitive information):
There are other tools and solutions (WMI for example) that can get the physical CPU count, but I ended up using WinAudit as it not only provided accurate information on all of our servers, but it also was the easiest to use and is very lightweight.
I found these three tools while searching and came upon Scott's comments in this blog post.