Module: check_mk
Branch: master
Commit: 910956e51df152a1a73bd7ca90edf6c92ff62474
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=910956e51df152…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Wed Oct 28 10:29:34 2015 +0100
winperf_if: fixed warning about dhcp in werk #2705 didn't work on some localized
windows versions
---
agents/windows/plugins/mk_dhcp_enabled.bat | 4 ++--
checks/winperf_if | 11 +++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/agents/windows/plugins/mk_dhcp_enabled.bat
b/agents/windows/plugins/mk_dhcp_enabled.bat
index 4b4d2e3..0a64918 100644
--- a/agents/windows/plugins/mk_dhcp_enabled.bat
+++ b/agents/windows/plugins/mk_dhcp_enabled.bat
@@ -1,3 +1,3 @@
@echo off
-echo ^<^<^<dhcp:sep^(44^)^>^>^>
-wmic path Win32_NetworkAdapterConfiguration get Description, dhcpenabled /format:csv
+echo ^<^<^<dhcp^>^>^>
+wmic path Win32_NetworkAdapterConfiguration get Description, dhcpenabled
diff --git a/checks/winperf_if b/checks/winperf_if
index 5777404..9843a5f 100644
--- a/checks/winperf_if
+++ b/checks/winperf_if
@@ -285,6 +285,17 @@ def check_if_dhcp(item, params, info, nic_names, nic_index):
header = lines.next()
for line in lines:
+ # wmic is bugged on some windows versions such that we can't use proper csv
output, only
+ # visual tables. Those aren't properly split up by the check_mk parser.
+ # Try to fix that mess
+
+ # assumption 1: header fields contain no spaces
+ num_fields = len(header)
+ # assumption 2: only the leftmost field contains spaces
+ lm_field = " ".join(line[:(num_fields - 1) * -1])
+
+ line = [lm_field] + line[(len(line) - num_fields + 1):]
+
as_dict = dict(zip(header, map(lambda x: x.rstrip(), line)))
name = winperf_if_normalize_nic_name(as_dict["Description"],
nic_names)
idx = nic_index.get(name)