[checkmk-commits] Check_MK Git: check_mk: #1995 FIX dmidecode: Fix parsing when memory devices are listed before controller

Mathias Kettner mk at mathias-kettner.de
Wed Feb 18 16:42:41 CET 2015


Module: check_mk
Branch: master
Commit: f5267e0b4cb78567ee98dbf6c33c8342e41ece44
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f5267e0b4cb78567ee98dbf6c33c8342e41ece44

Author: Mathias Kettner <mk at mathias-kettner.de>
Date:   Wed Feb 18 16:42:37 2015 +0100

#1995 FIX dmidecode: Fix parsing when memory devices are listed before controller

---

 .werks/1995         |   10 ++++++++++
 ChangeLog           |    1 +
 inventory/dmidecode |   29 +++++++++++++++++++++--------
 3 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/.werks/1995 b/.werks/1995
new file mode 100644
index 0000000..0c8fe31
--- /dev/null
+++ b/.werks/1995
@@ -0,0 +1,10 @@
+Title: dmidecode: Fix parsing when memory devices are listed before controller
+Level: 1
+Component: inv
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1424274114
+
+
diff --git a/ChangeLog b/ChangeLog
index cb3cc0f..89715af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -260,6 +260,7 @@
     * 1855 esx_systeminfo: new inventory plugin to retrieve info about the host operating system for ESX servers
     * 1851 FIX: win_exefiles: inventory check can now handle time stamps in us english locale
     * 1943 FIX: inventory plugin win_os: no longer detects incorrect i386 architecture...
+    * 1995 FIX: dmidecode: Fix parsing when memory devices are listed before controller
 
 
 1.2.6b1:
diff --git a/inventory/dmidecode b/inventory/dmidecode
index befa861..382875e 100644
--- a/inventory/dmidecode
+++ b/inventory/dmidecode
@@ -130,7 +130,7 @@ def inv_dmidecode_parse_system(lines):
 def inv_dmidecode_parse_chassis(lines):
     inv_dmidecode_parse_generic("hardware.chassis.", lines, {
         "Manufacturer" : "manufacturer",
-        "Type" : "type",
+        "Type"         : "type",
     })
 
 # Note: This node is also being filled by lnx_cpuinfo
@@ -185,10 +185,16 @@ def inv_dmidecode_parse_processor(lines):
 def inv_dmidecode_parse_physical_mem_array(lines):
     # We expect several possible arrays
     node = inv_tree("hardware.memory.arrays:")
-    array = {
-        "devices" : []
-    }
-    node.append(array)
+
+    # If we have a dummy entry from previous Memory Devices (see below)
+    # then we fill that entry rather than creating a new one
+    if len(node) == 1 and node[0].keys() == [ "devices" ]:
+        array = node[0]
+    else:
+        array = {
+            "devices" : []
+        }
+        node.append(array)
     for line in lines:
          if line[0] == "Location":
              array["location"] = line[1]
@@ -200,10 +206,17 @@ def inv_dmidecode_parse_physical_mem_array(lines):
              array["maximum_capacity"] = dmidecode_parse_size(line[1])
 
 def inv_dmidecode_parse_mem_device(lines):
-    # We assume that this devices belongs to an array
-    # that we've just found
+    # 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("hardware.memory.arrays:")
-    array = node[-1]
+    if node:
+        array = node[-1]
+    else:
+        array = { "devices": []}
+        node.append(array)
+
     device = {}
     inv_dmidecode_parse_generic(device, lines, {
         "Total Width"   : "total_width",  # 64 bits



More information about the checkmk-commits mailing list