Module: check_mk
Branch: master
Commit: a3cbd46a7fcc7683dc2ac6005c98e2ce60e71a44
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a3cbd46a7fcc76…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Jul 12 15:18:22 2016 +0200
fixed dmidecode if there are already phy. arrays
---
inventory/dmidecode | 37 ++++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/inventory/dmidecode b/inventory/dmidecode
index 7bf90c2..86404a2 100644
--- a/inventory/dmidecode
+++ b/inventory/dmidecode
@@ -202,6 +202,7 @@ def inv_dmidecode_parse_physical_mem_array(lines):
"devices" : []
}
node.append(array)
+
for line in lines:
if line[0] == "Location":
array["location"] = line[1]
@@ -213,24 +214,15 @@ def inv_dmidecode_parse_physical_mem_array(lines):
array["maximum_capacity"] = dmidecode_parse_size(line[1])
def inv_dmidecode_parse_mem_device(lines):
- # Do we already have an entry for a memory array? Then
- # we assume that this device belongs to the most recently
- # read array. Otherwise we create a dummy entry and replace
- # that later with actual information
- node = inv_tree_list("hardware.memory.arrays:")
- if node:
- array = node[-1]
- else:
- array = { "devices": []}
- node.append(array)
-
+ node = inv_tree_list("hardware.memory.arrays:")
device = {}
+
inv_dmidecode_parse_generic(device, lines, {
"Total Width" : "total_width", # 64 bits
"Data Width" : "data_width", # 64 bits
"Form Factor" : "form_factor", # SODIMM
"Set" : "set", # None
- "Locator" : "locator", # DIMM 2
+ "Locator" : "locator", # PROC 1 DIMM 2
"Bank Locator" : "bank_locator", # Bank 2/3
"Type" : "type", # DDR2
"Type Detail" : "type_detail", # Synchronous
@@ -242,10 +234,29 @@ def inv_dmidecode_parse_mem_device(lines):
"Size" : "size", # 2048 MB
})
+ # Do we already have an entry for a memory array? Then
+ # we assume that this device belongs to the most recently
+ # read array. Otherwise we create a dummy entry and replace
+ # that later with actual information
+ # If there are already arrays we try to find the right index of
+ # the phy. array
+ index = None
+ if device.get("locator") and
device["locator"].startswith("PROC"):
+ index = device["locator"].split()[1]
+
+ if node:
+ try:
+ array = node[int(index) - 1]
+ except:
+ array = node[-1]
+ else:
+ array = { "devices": [] }
+ node.append(array)
+
if device["size"] != "No Module Installed":
# Convert speed and size into numbers
device["speed"] = dmidecode_parse_speed(device.get("speed",
"Unknown"))
- device["size"] = dmidecode_parse_size(device.get("size",
"Unknown"))
+ device["size"] = dmidecode_parse_size(device.get("size",
"Unknown"))
array["devices"].append(device)