Module: check_mk
Branch: master
Commit: c1110b0817320727f83d246279f23a4f17f312a2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c1110b08173207…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jun 24 15:37:39 2013 +0200
Support Windows with new plugin "psperf.bat".
---
ChangeLog | 4 +-
agents/windows/check_mk_agent.cc | 2 +-
agents/windows/check_mk_agent.exe | Bin 112640 -> 112640 bytes
agents/windows/install_agent.exe | Bin 131811 -> 131817 bytes
agents/windows/plugins/psperf.bat | 7 ++++
checkman/ps.perf | 4 ++
checkman/wmic_process | 4 ++
checks/ps | 76 +++++++++++++++++++++++++++++++++++-
web/plugins/perfometer/check_mk.py | 11 ++++++
9 files changed, 105 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 14fa65c..d0e2d76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,8 +30,10 @@
was misleading for different agent versions on multiple nodes)
* job check: better handling of unexpected agent output
* lnx_thermal: Added check for linux thermal sensors (e.g. acpi)
- * hwg_temp: Make WATO-Rule "Room Temperature" match, add man page, graph
+ * hwg_temp: Make WATO-Rule "Room Temperature" match, add man page, graph
and Perf-O-Meter
+ * ps.perf: Support Windows with new plugin "psperf.bat". wmicchecks.bat
+ is obsolete now.
Multisite:
* User accounts can now be locked after a specified amount of auth
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index 4b2249c..242a15c 100755
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -533,7 +533,7 @@ void section_df(SOCKET &out)
void section_ps(SOCKET &out)
{
crash_log("<<<ps>>>");
- output(out, "<<<ps>>>\n");
+ output(out, "<<<ps:sep(0)>>>\n");
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index b3f2665..8e49bd0 100755
Binary files a/agents/windows/check_mk_agent.exe and b/agents/windows/check_mk_agent.exe
differ
diff --git a/agents/windows/install_agent.exe b/agents/windows/install_agent.exe
index 2f33014..5d5583d 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe
differ
diff --git a/agents/windows/plugins/psperf.bat b/agents/windows/plugins/psperf.bat
new file mode 100644
index 0000000..d901b1a
--- /dev/null
+++ b/agents/windows/plugins/psperf.bat
@@ -0,0 +1,7 @@
+rem This plugin obsoletes wmicchecks.bat. It is better because it is
+rem directly supported by the normal ps check.
+
+@echo off
+echo ^<^<^<ps:sep^(44^)^>^>^>
+echo [wmic process]
+wmic process get
ProcessId,name,pagefileusage,virtualsize,workingsetsize,usermodetime,kernelmodetime,ThreadCount
/format:csv
diff --git a/checkman/ps.perf b/checkman/ps.perf
index 6563d06..405fbda 100644
--- a/checkman/ps.perf
+++ b/checkman/ps.perf
@@ -7,6 +7,10 @@ description:
This check does exactly the same as {ps}, but in addition
outputs performance data. Please refer to the manpage of {ps} for more details.
+ Note: If you want to use {ps.perf} on Windows systems then you need to install
+ the plugin {psperf.bat} into the {plugins} directory of you Windows agent.
+ Do not use {wmicchecks.bat}. This is obsolete.
+
perfdata:
In all cases the number of matching running processes found on the target
system is sent. If the agent supports it, also the virtual prozess size (VSZ)
diff --git a/checkman/wmic_process b/checkman/wmic_process
index 1d2c640..b3a0422 100644
--- a/checkman/wmic_process
+++ b/checkman/wmic_process
@@ -4,6 +4,10 @@ author: Mathias Kettner <mk(a)mathias-kettner.de>
license: GPL
distribution: check_mk
description:
+ Note: This check is obsolete. Do not install {wmicchecks.bat} anymore. Use
+ {psperf.bat} in combination with the normal {ps.perf} check. The rest of
+ this man page is unchanged for legacy reasons:
+
This check uses the output of {wmic process} in order to monitor the ressource
consumption of processes on Windows servers. On the target host this check
needs the command line utility {wmic} and the agent plugin {wmicchecks.bat}
diff --git a/checks/ps b/checks/ps
index e258e18..7336dea 100644
--- a/checks/ps
+++ b/checks/ps
@@ -33,6 +33,22 @@
# Third generation (from 1.1.5) output also virtual memory, resident memory and %CPU:
# (class,122376,88128,0.0) /usr/jre1.6.0_13/bin/java -Dn=Cart_16TH13 -Dmcs.node=zbgh1ca
-Dmcs.mdt.redundan
+# Windows agent now ships a plugin "psperf.bat" that adds a section from wmic
+# to the output:
+# <<<ps:sep(44)>>>
+# [wmic process]
+# ^M
+#
Node,KernelModeTime,Name,PageFileUsage,ThreadCount,UserModeTime,VirtualSize,WorkingSetSize^M
+# WINDOWSXP,43478281250,System Idle Process,0,2,0,0,28672^M
+# WINDOWSXP,155781250,System,0,59,0,1957888,253952^M
+# WINDOWSXP,468750,smss.exe,176128,3,156250,3928064,442368^M
+# WINDOWSXP,56406250,csrss.exe,1863680,12,11406250,25780224,3956736^M
+# WINDOWSXP,18593750,winlogon.exe,6832128,19,4843750,59314176,2686976^M
+# WINDOWSXP,167500000,services.exe,1765376,16,13750000,22601728,4444160^M
+# WINDOWSXP,16875000,lsass.exe,3964928,21,3906250,43462656,6647808^M
+# WINDOWSXP,8750000,VBoxService.exe,1056768,8,468750,26652672,3342336^M
+
+
# New since 1.2.1i2: WATO compatible syntax
#
# Holds a list of rules which are matching hosts by names or tags and
@@ -52,6 +68,50 @@ inventory_processes_perf = []
ANY_USER = None
GRAB_USER = False
+def ps_parse_info(info):
+ result = []
+ lines = iter(info)
+ wmic_info = {}
+ cpu_cores = 1
+ try:
+ 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
+
+ except StopIteration:
+ pass
+
+ # Add wmic_info to process table, but only if present:
+ if wmic_info:
+ info = []
+ seen_pids = set([]) # Remove duplicate entries
+ for line in result:
+ 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":
+ cpucores = int(psinfo["ThreadCount"])
+ pid = int(psinfo["ProcessId"])
+ if pid not in seen_pids:
+ seen_pids.add(pid)
+ mem = int(psinfo["WorkingSetSize"]) / 1024 # Bytes
-> KB
+ page = int(psinfo["PageFileUsage"]) / 1024 # Bytes ->
KB
+ userc = int(psinfo["UserModeTime"]) # do not resolve
counter here!
+ kernelc = int(psinfo["KernelModeTime"]) # do not resolve
counter here!
+ line[1:1] = [ "(unknown,%d,%d,@%d/%d/%d)" % (mem, page,
pid, userc, kernelc) ]
+ info.append(line)
+ return cpu_cores, info
+ else:
+ return cpu_cores, info
+
+
def inventory_ps(info):
return inventory_ps_common(inventory_processes, info)
@@ -59,6 +119,7 @@ def inventory_ps_perf(info):
return inventory_ps_common(inventory_processes_perf, info, True)
def inventory_ps_common(invdata, info, handle_perfdata = False):
+ cpu_cores, info = ps_parse_info(info) # parse windows wmic information
inventory = []
entries = []
@@ -197,6 +258,7 @@ def process_matches(ps, procname, l_user):
return False
def check_procs(item, params, info, with_perfdata):
+ cpu_cores, info = ps_parse_info(info) # parse windows wmic information
if len(params) == 5:
procname, warnmin, okmin, okmax, warnmax = params
user = None
@@ -224,7 +286,15 @@ def check_procs(item, params, info, with_perfdata):
if len(addinfo) >= 4: # extended performance data
virtual_size += int(addinfo[1]) # kB
resident_size += int(addinfo[2]) # kB
- percent_cpu += savefloat(addinfo[3])
+ if addinfo[3].startswith('@'): # wmic counters :-(
+ pid, user_c, kernel_c = map(int,
addinfo[3][1:].split('/'))
+ timedif, user_per_sec = get_counter("ps_wmic.user.%d"
% pid, time.time(), user_c)
+ timedif, kernel_per_sec =
get_counter("ps_wmic.kernel.%d" % pid, time.time(), kernel_c)
+ user_perc = user_per_sec / 100000.0 / cpu_cores
+ kernel_perc = kernel_per_sec / 100000.0 / cpu_cores
+ percent_cpu += user_perc + kernel_perc
+ else:
+ percent_cpu += savefloat(addinfo[3])
extended_perfdata = True
if with_perfdata:
@@ -250,6 +320,10 @@ def check_procs(item, params, info, with_perfdata):
if running_on:
infotext += " [running on %s]" % ", ".join(running_on)
+ if virtual_size:
+ infotext += " %.1f MB virtual, %.1f MB resident, %.1f%% CPU" % (
+ virtual_size / 1024.0, resident_size / 1024.0, percent_cpu)
+
if count > warnmax or count < warnmin:
return (2, infotext + " (ok from %d to %d)" % (okmin, okmax),
perfdata)
elif count > okmax or count < okmin:
diff --git a/web/plugins/perfometer/check_mk.py b/web/plugins/perfometer/check_mk.py
index 047bf6b..db4eac7 100644
--- a/web/plugins/perfometer/check_mk.py
+++ b/web/plugins/perfometer/check_mk.py
@@ -415,6 +415,17 @@ def perfometer_cpu_utilization(row, check_command, perf_data):
perfometers["check_mk-h3c_lanswitch_cpu"] = perfometer_cpu_utilization
perfometers["check_mk-winperf_processor.util"] = perfometer_cpu_utilization
+def perfometer_ps_perf(row, check_command, perf_data):
+ perf_dict = dict([(p[0], float(p[1])) for p in perf_data])
+ try:
+ perc = perf_dict["pcpu"]
+ return "%.1f%%" % perc, perfometer_linear(perc, "#30ff80")
+ except:
+ return "", ""
+
+perfometers["check_mk-ps.perf"] = perfometer_ps_perf
+
+
def perfometer_hpux_snmp_cs_cpu(row, check_command, perf_data):
h = '<table><tr>'
h += perfometer_td(float(perf_data[0][1]), "#60f020")