Module: check_mk
Branch: master
Commit: e304efa97bbd10300e8e3cae84cf48a040034fe3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e304efa97bbd10…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Oct 14 11:58:39 2013 +0200
psperf.bat/ps: Plugin output processing no longer crashes when
the ps service is clustered
---
ChangeLog | 2 ++
agents/windows/plugins/psperf.bat | 1 +
checks/ps | 23 ++++++++++++++---------
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4d82de5..1ebc0c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -77,6 +77,8 @@
* FIX: check_mk_agent.linux: limit Livestatus check to 3 seconds
* FIX: esx_vsphere_vm: fixed exception when memory info for vm is missing
* FIX: esx_vsphere_hostsystem: Fixed typo in check output
+ * FIX: psperf.bat/ps: Plugin output processing no longer crashes when
+ the ps service is clustered
Multisite:
* Filtering in views by Hostalias is possible now too
diff --git a/agents/windows/plugins/psperf.bat b/agents/windows/plugins/psperf.bat
index a9fdbc9..d793112 100644
--- a/agents/windows/plugins/psperf.bat
+++ b/agents/windows/plugins/psperf.bat
@@ -5,3 +5,4 @@ rem directly supported by the normal ps check.
echo ^<^<^<ps:sep^(44^)^>^>^>
echo [wmic process]
wmic process get
ProcessId,name,pagefileusage,virtualsize,workingsetsize,usermodetime,kernelmodetime,ThreadCount
/format:csv
+echo [wmic process end]
\ No newline at end of file
diff --git a/checks/ps b/checks/ps
index 6d7d705..a18d1d2 100644
--- a/checks/ps
+++ b/checks/ps
@@ -74,17 +74,22 @@ def ps_parse_info(info):
wmic_info = {}
cpu_cores = 1
try:
+ is_wmic = False
while True:
line = lines.next()
if line[-1] == '[wmic process]':
- break
- result.append(line)
- # part of wmic data
- headers = ["node"] + lines.next()[1:]
- while True:
- row = dict(zip(headers, lines.next()))
- wmic_info[(row["node"], row["Name"])] = row
-
+ is_wmic = True
+ wmic_headers = ["node"] + lines.next()[1:]
+ continue
+ elif line[-1] == '[wmic process end]':
+ is_wmic = False
+ continue
+
+ if not is_wmic:
+ result.append(line)
+ else:
+ row = dict(zip(wmic_headers, line))
+ wmic_info[(row["node"], row["Name"])] = row
except StopIteration:
pass
@@ -96,7 +101,7 @@ def ps_parse_info(info):
psinfo = wmic_info.get(tuple(line))
# Get number of CPU cores from system idle process
if psinfo:
- if "ThreadCount" in headers and
psinfo["Name"].lower() == "system idle process":
+ if "ThreadCount" in wmic_headers and
psinfo["Name"].lower() == "system idle process":
cpucores = int(psinfo["ThreadCount"])
pid = int(psinfo["ProcessId"])
if pid not in seen_pids: