Module: check_mk
Branch: master
Commit: b330459a38cc27db21a926cb939bd2a9c060b2a1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b330459a38cc27…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Sep 9 13:59:53 2014 +0200
winperf_if: Improved matching of data from wmic_if.bat / wmic_if.ps1 scripts
---
.werks/1104 | 15 ++++++++++++++
ChangeLog | 1 +
checks/winperf_if | 60 ++++++++++++++++++++++++++++++++++++++++++-----------
3 files changed, 64 insertions(+), 12 deletions(-)
diff --git a/.werks/1104 b/.werks/1104
new file mode 100644
index 0000000..cb7dcea
--- /dev/null
+++ b/.werks/1104
@@ -0,0 +1,15 @@
+Title: winperf_if: Improved matching of data from wmic_if.bat / wmic_if.ps1 scripts
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i6
+Date: 1410263307
+Class: fix
+
+Interfaces reported by the wmic_if.bat, wmic_if.ps1 script were not
+entirely identical with the interface names reported by the windows
+performance counters.
+The matching algorhytm has been improved. Due to the better matching
+the interface checks will provide more output, like the mac address.
+
+Note: The new matching algorhythm should have no negative side effects for existing
winperf_if checks
diff --git a/ChangeLog b/ChangeLog
index ca3a162..4269915 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -79,6 +79,7 @@
* 0651 FIX: f5_bigip_interfaces: Fix invalid throughput values, detect newer F5
devices...
* 1393 FIX: casa_cpu_temp, casa_cpu_util: Change service description to standard...
NOTE: Please refer to the migration notes!
+ * 1104 FIX: winperf_if: Improved matching of data from wmic_if.bat / wmic_if.ps1
scripts...
Multisite:
* 1066 Implemented Dashboard Designer...
diff --git a/checks/winperf_if b/checks/winperf_if
index b16ca5a..03438c8 100644
--- a/checks/winperf_if
+++ b/checks/winperf_if
@@ -77,7 +77,6 @@ def convert_winperf_if(info):
if counter:
for nr, value in enumerate(line[1:len(nic_names)+1]):
nics[nic_names[nr]][counter] = int(value)
-
# Not and integer: then this must be the line with the additional
# information from wmic (which is optional!)
else:
@@ -91,20 +90,58 @@ def convert_winperf_if(info):
nic_name += " " + str(conn_id)
except:
pass
+
+
+ def transform_name(name):
+ # Intel[R] PRO 1000 MT-Desktopadapter__3 (perf counter)
+ # Intel(R) PRO/1000 MT-Desktopadapter 3 (wmic name)
+ # Intel(R) PRO/1000 MT-Desktopadapter #3 (wmic
InterfaceDescription)
+ mod_nic_name = name
+ for from_token, to_token in [ ("/", " "),
("(", "["), (")", "]"), ("#", "
") ]:
+ for n in nic_names:
+ if from_token in n:
+ # we do not modify it if this character is in any of
the counter names
+ break
+ else:
+ mod_nic_name = mod_nic_name.replace(from_token,
to_token).replace(" ", " ")
+ return mod_nic_name
+
+ found_match = False
+
+ # Exact match
+ if nic_name in nic_names:
+ found_match = True
+
# In the perf counters the nics have strange suffixes, e.g.
# Ethernetadapter der AMD-PCNET-Familie 2 - Paketplaner-Miniport,
while
# in wmic it's only named "Ethernetadapter der
AMD-PCNET-Familie 2".
- longest_match = 0
- if nic_name not in nic_names:
- for n in nic_names:
- if n.startswith(nic_name + " "):
- l = len(nic_name)
- if not (n[l:].strip()[0]).isdigit():
- nic_name = n
- break
+ if not found_match:
+ mod_nic_name = transform_name(nic_name)
+
+ if mod_nic_name not in nic_names:
+ for n in nic_names:
+ if n.startswith(mod_nic_name + " "):
+ l = len(mod_nic_name)
+ if not (n[l:].strip()[0]).isdigit():
+ nic_name = n
+ found_match = True
+ break
else:
- # Ignore interfaces that do not have counters
- continue
+ nic_name = mod_nic_name
+
+ # The last straw. Try to find this the name as exact match in other
fields
+ if not found_match:
+ for entry in [ "NetConnectionID",
"InterfaceDescription" ]:
+ if as_dict.get(entry):
+ mod_nic_name = transform_name(as_dict.get(entry))
+ if mod_nic_name in nic_names:
+ nic_name = mod_nic_name
+ found_match = True
+ break
+
+ if not found_match:
+ # Ignore interfaces that do not have counters
+ continue
nics[nic_name].update(as_dict)
except StopIteration:
@@ -113,7 +150,6 @@ def convert_winperf_if(info):
# Now convert the dicts into the format that is needed by if.include
converted = []
-
# Sort NIC names are create artifical index
nic_names = nics.keys()
nic_names.sort()