Module: check_mk
Branch: master
Commit: 78969d9ec8fe9d2b5bf090edc5bee120007791f8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=78969d9ec8fe9d…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue May 27 17:30:22 2014 +0200
Fix computation of number of cores and cpus
---
inventory/lnx_cpuinfo | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/inventory/lnx_cpuinfo b/inventory/lnx_cpuinfo
index 4f6f904..8a94858 100644
--- a/inventory/lnx_cpuinfo
+++ b/inventory/lnx_cpuinfo
@@ -57,7 +57,8 @@
# Note: This node is also being filled by dmidecode
def inv_lnx_cpuinfo(info):
node = inv_tree("hardware.cpu.")
- num_cpus = 0
+ num_threads_total = 0
+ num_sockets = 0
for varname, value in info:
if varname == "cpu cores":
node["cores_per_cpu"] = int(value)
@@ -74,15 +75,19 @@ def inv_lnx_cpuinfo(info):
node["cache_size"] = int(value.split()[0]) * 1024 # everything is
normalized to bytes!
elif varname == "model name":
node["model"] = value
+ # For the following two entries we assume that all
+ # entries are numbered in increasing order in /proc/cpuinfo.
elif varname == "processor":
- num_cpus = int(value) + 1
+ num_threads_total = int(value) + 1
+ elif varname == "physical id":
+ num_sockets = int(value) + 1
- if num_cpus:
+ if num_threads_total:
node.setdefault("cores_per_cpu", 1)
node.setdefault("threads_per_cpu", 1)
- node["cores"] = num_cpus * node["cores_per_cpu"]
- node["threads"] = num_cpus * node["threads_per_cpu"]
- node["cpus"] = num_cpus
+ node["cores"] = num_sockets * node["cores_per_cpu"]
+ node["threads"] = num_sockets * node["threads_per_cpu"]
+ node["cpus"] = num_sockets
inv_info['lnx_cpuinfo'] = {
"inv_function" : inv_lnx_cpuinfo,