Thursday, December 1, 2011

Use cntcores to count CPUs and processor cores

In one of my previous posts on how to determine the number CPUs in a server, I listed several methods by Operating System (OS) type that can be used to determine the number of processors (or CPUs) and cores in a server.

Since then I have continued to get requests for assistance on determining the number of cores that a server has.  In order to simplify my life, I wrote a script called cntcores that will succinctly tell you the number of processors, cores, threads the OS, OS version, and processor type.  Below are a few sample outputs.

Oracle SPARC T4-2 running Solaris
CPUs  Cores Threads Operating System ProcType
2     16    128     SunOS 5.11       ORCL,SPARC-T4-2 2848 MHz


Oracle X4800-M2 running Solaris
CPUs  Cores Threads Operating System ProcType
8     160   160     SunOS 5.10       i86pc 2400 MHz



Sun X4150 running Oralce Enterprise Linux
CPUs  Cores Threads Operating System                ProcType
2     8     8       Oracle Linux Server release 6.1 Xeon(R) CPU E5345  @ 2.33GHz

Dell E250 running Ubuntu
CPUs  Cores Threads Operating System ProcType
1     2     2       Ubuntu 10.10     Athlon(tm) 64 X2 Dual Core Processor 4200+

Apple MacBook Pro running OSX Lion
CPUs  Cores Threads Operating System ProcType
1     4     8       Darwin 11.2.0    Intel Core i7 

The usage of the command is very straight forward.  Just run the script. ;-)  Below is the actual usage.

$ cntcores [-h] [-v] [-l]
   -h  Show Usage
   -v  Show Version
   -l  Show License
   -q  Don't show disclaimer

The script works for several Linux distributions, Solaris, OSX, HP-UX and AIX.

Unfortunately, I don't have any HP-UX or IBM AIX servers to test the script on.  If you run it on an HP-UX or IBM AIX server, be sure to share the results.

Note that although the cntcores script could be very useful for determining core counts for licensing purposes, it should not be relied upon exclusively for that purpose.  It may not always accurately represent the actual number of cores in a given server.  Therefore, ALWAYS verify all server core counts by at least two methods to assure an accurate accounting.

Thanks in advance and Enjoy!

Brad
PS: As always, the sample scripts provided in this post are for reference are not supported by me or my employer in any way.

No comments: