Module: check_mk
Branch: master
Commit: 1dc3701e10393ca39c2f05cce62dda2cd0b5418e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1dc3701e10393c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 29 08:08:32 2016 +0200
inventory: clarified node type a bit more
---
inventory/aix_packages | 2 +-
inventory/aix_service_packs | 2 +-
inventory/aruba_wlc_aps | 2 +-
inventory/dmidecode | 6 +++---
inventory/esx_vsphere_clusters | 2 +-
inventory/if | 2 +-
inventory/lnx_ip_a | 2 +-
inventory/lnx_ip_r | 2 +-
inventory/lnx_packages | 2 +-
inventory/lnx_video | 2 +-
inventory/mssql_versions | 2 +-
inventory/netapp_api_disks | 2 +-
inventory/snmp_extended_info | 2 +-
inventory/solaris_pkginfo | 2 +-
inventory/win_disks | 2 +-
inventory/win_exefiles | 2 +-
inventory/win_reg_uninstall | 2 +-
inventory/win_video | 2 +-
inventory/win_wmi_software | 2 +-
modules/inventory.py | 8 ++++++++
20 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/inventory/aix_packages b/inventory/aix_packages
index fcfe7e3..7552626 100644
--- a/inventory/aix_packages
+++ b/inventory/aix_packages
@@ -36,7 +36,7 @@
def inv_aix_packages(info):
- paclist = inv_tree("software.packages:")
+ paclist = inv_tree_list("software.packages:")
headers = info[0]
headers[0] = headers[0].lstrip("#")
for line in info[1:]:
diff --git a/inventory/aix_service_packs b/inventory/aix_service_packs
index 50f258c..ee97af7 100644
--- a/inventory/aix_service_packs
+++ b/inventory/aix_service_packs
@@ -25,7 +25,7 @@
# Boston, MA 02110-1301 USA.
def inv_aix_service_packs(info):
- node = inv_tree("software.os.service_packs:")
+ node = inv_tree_list("software.os.service_packs:")
for line in info:
node.append({ "name" : line[0]})
diff --git a/inventory/aruba_wlc_aps b/inventory/aruba_wlc_aps
index eb3443d..8269cee 100644
--- a/inventory/aruba_wlc_aps
+++ b/inventory/aruba_wlc_aps
@@ -44,7 +44,7 @@ def inv_aruba_wlc_aps(info):
"72" : "ap227", "73" : "ap214",
"74" : "ap215", "75" : "ap228",
"76" : "ap205H", "9999" : "undefined",
}
- node = inv_tree("networking.wlan.controller.accesspoints:")
+ node = inv_tree_list("networking.wlan.controller.accesspoints:")
for ap_name, ap_status, ap_unprovisioned, ap_ip, ap_group, \
ap_model, ap_serial, ap_sysloc in info:
node.append({
diff --git a/inventory/dmidecode b/inventory/dmidecode
index c553139..7bf90c2 100644
--- a/inventory/dmidecode
+++ b/inventory/dmidecode
@@ -172,7 +172,7 @@ def inv_dmidecode_parse_processor(lines):
# node["module_voltage"] = dmidecode_parse_voltage(line[1])
#
# def inv_dmidecode_parse_mem_module(lines):
-# node = inv_tree("hardware.memory.modules:")
+# node = inv_tree_list("hardware.memory.modules:")
# module = {}
# node.append(module)
# for line in lines:
@@ -191,7 +191,7 @@ 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:")
+ node = inv_tree_list("hardware.memory.arrays:")
# If we have a dummy entry from previous Memory Devices (see below)
# then we fill that entry rather than creating a new one
@@ -217,7 +217,7 @@ def inv_dmidecode_parse_mem_device(lines):
# 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:")
+ node = inv_tree_list("hardware.memory.arrays:")
if node:
array = node[-1]
else:
diff --git a/inventory/esx_vsphere_clusters b/inventory/esx_vsphere_clusters
index ffd6eb6..71b4637 100644
--- a/inventory/esx_vsphere_clusters
+++ b/inventory/esx_vsphere_clusters
@@ -31,7 +31,7 @@
def inv_esx_vsphere_clusters(info):
- node = inv_tree("software.applications.vmwareesx:")
+ node = inv_tree_list("software.applications.vmwareesx:")
datacenters = {}
for line in info:
diff --git a/inventory/if b/inventory/if
index d7aa318..f45c967 100644
--- a/inventory/if
+++ b/inventory/if
@@ -44,7 +44,7 @@ def inv_if(info, params):
total_ethernet_ports = 0
available_ethernet_ports = 0
- node = inv_tree("networking.interfaces:")
+ node = inv_tree_list("networking.interfaces:")
for if_index, if_descr, if_alias, if_type, if_speed, if_high_speed, \
if_oper_status, if_admin_status, if_phys_address, if_last_change in port_info:
diff --git a/inventory/lnx_ip_a b/inventory/lnx_ip_a
index aba85f5..f557fa7 100644
--- a/inventory/lnx_ip_a
+++ b/inventory/lnx_ip_a
@@ -50,7 +50,7 @@ def inv_lnx_ip_a(info):
"type" : '.' in address and "ipv4" or
"ipv6",
}
- addresses = inv_tree("networking.addresses:")
+ addresses = inv_tree_list("networking.addresses:")
for line in info:
if line[0][-1] == ':':
device = line[1].rstrip(':')
diff --git a/inventory/lnx_ip_r b/inventory/lnx_ip_r
index a9f4d12..a7535e5 100644
--- a/inventory/lnx_ip_r
+++ b/inventory/lnx_ip_r
@@ -58,7 +58,7 @@ def parse_lnx_ip_route(line):
def inv_lnx_ip_r(info):
- routes = inv_tree("networking.routes:")
+ routes = inv_tree_list("networking.routes:")
for line in info:
routes.append(parse_lnx_ip_route(line))
diff --git a/inventory/lnx_packages b/inventory/lnx_packages
index eb0a3d9..a01fd40 100644
--- a/inventory/lnx_packages
+++ b/inventory/lnx_packages
@@ -43,7 +43,7 @@
def inv_lnx_packages(info):
- paclist = inv_tree("software.packages:")
+ paclist = inv_tree_list("software.packages:")
for pacname, version, arch, pactype, summary, inststate in info:
if pactype == "deb":
if "installed" not in inststate:
diff --git a/inventory/lnx_video b/inventory/lnx_video
index 1adba39..4446aa9 100644
--- a/inventory/lnx_video
+++ b/inventory/lnx_video
@@ -44,7 +44,7 @@
def inv_lnx_video(info):
- node = inv_tree("hardware.video:")
+ node = inv_tree_list("hardware.video:")
array = {}
for line in info:
if len(line) > 1:
diff --git a/inventory/mssql_versions b/inventory/mssql_versions
index bcf6b7e..f0e6080 100644
--- a/inventory/mssql_versions
+++ b/inventory/mssql_versions
@@ -33,7 +33,7 @@
# MSSQL_MSSQLSERVER|10.50.1600.1|Enterprise Edition
def inv_mssql_versions(info):
- node = inv_tree("software.applications.mssql.instances")
+ node = inv_tree_list("software.applications.mssql.instances:")
for line in info:
if len(line) not in [2, 4]:
diff --git a/inventory/netapp_api_disks b/inventory/netapp_api_disks
index aef23ab..df412f4 100644
--- a/inventory/netapp_api_disks
+++ b/inventory/netapp_api_disks
@@ -29,7 +29,7 @@
# disk
4E455441:50502020:56442D39:3030304D:422D465A:2D353230:38383633:32303037:00000000:00000000
used-space 9458679808 serial-number 88632007 raid-type pending vendor-id ..
def inv_netapp_api_disk(info):
- node = inv_tree("hardware.storage.disks:")
+ node = inv_tree_list("hardware.storage.disks:")
for line in info:
disk = {}
line_dict = dict(map(lambda x: x.split(" ", 1), line))
diff --git a/inventory/snmp_extended_info b/inventory/snmp_extended_info
index 63cbed7..980f563 100644
--- a/inventory/snmp_extended_info
+++ b/inventory/snmp_extended_info
@@ -66,7 +66,7 @@ def inv_snmp_extended_info(info):
location_info = (map_type[parsed[parent][2]], parent)
else:
location_info = ("Missing in ENTITY table", parent)
- node = inv_tree("hardware.components.%ss:" %
(map_type[entity_type]).lower())
+ node = inv_tree_list("hardware.components.%ss:" %
(map_type[entity_type]).lower())
node.append({
"index" : index,
"name" : name,
diff --git a/inventory/solaris_pkginfo b/inventory/solaris_pkginfo
index a243907..0196639 100644
--- a/inventory/solaris_pkginfo
+++ b/inventory/solaris_pkginfo
@@ -47,7 +47,7 @@
def inv_solaris_pkginfo(info):
- paclist = inv_tree("software.packages:")
+ paclist = inv_tree_list("software.packages:")
entry = {}
translation_dict = {
"ARCH" : "arch",
diff --git a/inventory/win_disks b/inventory/win_disks
index 013c3ed..05e7627 100644
--- a/inventory/win_disks
+++ b/inventory/win_disks
@@ -58,7 +58,7 @@
# SCSITargetId : 0
def inv_win_disks(info):
- node = inv_tree("hardware.storage.disks:")
+ node = inv_tree_list("hardware.storage.disks:")
array = {}
first_varname = None
diff --git a/inventory/win_exefiles b/inventory/win_exefiles
index d9a1641..3e30976 100644
--- a/inventory/win_exefiles
+++ b/inventory/win_exefiles
@@ -32,7 +32,7 @@
# C:\Program Files\Common Files\Microsoft
Shared\OfficeSoftwareProtectionPlatform\OSPPSVC.EXE|5132888
def inv_win_exefiles(info):
- paclist = inv_tree("software.packages:")
+ paclist = inv_tree_list("software.packages:")
for line in info:
if len(line) != 6:
continue # ignore broken lines containing parse errors
diff --git a/inventory/win_reg_uninstall b/inventory/win_reg_uninstall
index 903389d..a8d3c0f 100644
--- a/inventory/win_reg_uninstall
+++ b/inventory/win_reg_uninstall
@@ -29,7 +29,7 @@
# ...
def inv_win_reg_uninstall(info):
- paclist = inv_tree("software.packages:")
+ paclist = inv_tree_list("software.packages:")
for line in info:
if len(line) == 7:
display_name, publisher, path, pacname, version, estimated_size, date = line
diff --git a/inventory/win_video b/inventory/win_video
index ab4489e..8733530 100644
--- a/inventory/win_video
+++ b/inventory/win_video
@@ -37,7 +37,7 @@
def inv_win_video(info):
- node = inv_tree("hardware.video:")
+ node = inv_tree_list("hardware.video:")
array = {}
first_varname = None
for line in info:
diff --git a/inventory/win_wmi_software b/inventory/win_wmi_software
index 1140c71..00a778b 100644
--- a/inventory/win_wmi_software
+++ b/inventory/win_wmi_software
@@ -35,7 +35,7 @@
def inv_win_wmi_software(info):
- paclist = inv_tree("software.packages:")
+ paclist = inv_tree_list("software.packages:")
for line in info:
pacname, vendor, version = line[0:3]
dat = line[3]
diff --git a/modules/inventory.py b/modules/inventory.py
index 0070cf2..937e960 100644
--- a/modules/inventory.py
+++ b/modules/inventory.py
@@ -67,6 +67,14 @@ for f in filelist:
sys.exit(5)
+# This is just a small wrapper for the inv_tree() function which makes
+# it clear that the requested tree node is treated as a list.
+def inv_tree_list(path):
+ l = []
+ l += inv_tree(path)
+ return l
+
+
# Function for accessing the inventory tree of the current host
# Example: path = "software.packages:17."
# The path must end with : or .