In our company we have some 3rd-party products installed on CentOS/RHEL systems. The Application team needed to do some accounting on how each product was licensed using number of CPU sockets in the each system. Sadly they did not have any type of CMDB in place to help (Configuration Management Database – something very handy to have when it comes to looking at your server inventory). Here is a short note to get the number of CPU sockets on a CentOS/RHEL system.
Determine number of CPU sockets
1. To accurately determine the number of CPU sockets on a system without physically opening and manually inspecting it, one must rely on the system’s DMI table (populated by the BIOS). Install the dmidecode package (if necessary) and then, as root, run the following:
# dmidecode -t4 | grep Socket.Designation: | wc -l
2. If all the CPU sockets on the system are filled (i.e., each socket has a processor in it), performing any of the following as a normal user will be sufficient:
– Consult the /proc/cpuinfo file, e.g.:
$ grep physical.id /proc/cpuinfo | sort -u | wc -l
– RHEL6 and above: Use the lscpu command, e.g.:
$ lscpu | grep -i "socket(s)"
– RHEL6 and above: Use the lstopo command, provided by the hwloc package, e.g.:
$ lstopo --whole-system --only Socket