Module: check_mk
Branch: master
Commit: 13afa378f018382329476ebe245eb3a62b19f5f9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=13afa378f01838…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Jul 31 17:31:59 2015 +0200
esx_vsphere_counters: improved item handling. now uses instance name as fallback if no
human readable name is available
---
checks/esx_vsphere_counters | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/checks/esx_vsphere_counters b/checks/esx_vsphere_counters
index bb8e3f1..f292a4c 100644
--- a/checks/esx_vsphere_counters
+++ b/checks/esx_vsphere_counters
@@ -130,18 +130,27 @@ def parse_esx_vsphere_counters(info):
parsed[counter][instance].append((value, unit))
return parsed
+# esx datastores are either shown by human readable name (if available) or by the uid
+def esx_vsphere_counters_get_item_mapping(parsed):
+ map_instance_to_item = {}
+ for instance in parsed.get("datastore.read").keys():
+ map_instance_to_item[instance] = instance
+
+ for instance, values in parsed.get("datastore.name").items():
+ if instance in map_instance_to_item and values[0][0] != "":
+ map_instance_to_item[instance] = values[0][0]
+ return map_instance_to_item
+
def inventory_esx_vsphere_counters_datastoreio(parsed):
- return inventory_diskstat_generic(map(lambda x: [None, x[0][0]],
- parsed.get("datastore.name").values()))
+ return inventory_diskstat_generic(map(lambda x: [None, x],
+ esx_vsphere_counters_get_item_mapping(parsed).values()))
def check_esx_vsphere_counters_datastoreio(item, params, parsed):
if not parsed:
raise MKCounterWrapped("Counter data is missing")
datastores = {}
- map_instance_to_name = {}
- for instance, values in parsed.get("datastore.name").items():
- map_instance_to_name[instance] = values[0][0]
+ item_mapping = esx_vsphere_counters_get_item_mapping(parsed)
for new_name, name, scaling in [ ("read_throughput",
"datastore.read", 1024),
("write_throughput",
"datastore.write", 1024),
@@ -151,7 +160,7 @@ def check_esx_vsphere_counters_datastoreio(item, params, parsed):
field_data = parsed.get(name, {})
for instance, values in field_data.items():
- item_name = map_instance_to_name[instance]
+ item_name = item_mapping[instance]
datastores.setdefault(item_name, {})
datastores[item_name][new_name] = int(values[0][0]) * scaling