Module: check_mk
Branch: master
Commit: 4f9fb74e92e4f20398d3e1949e8c6a982fcf978c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4f9fb74e92e4f2…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Mar 13 14:18:55 2013 +0100
wmic_processs: cpucores now being considered when calculating user/kernel percentages
---
ChangeLog | 2 ++
agents/windows/plugins/wmicchecks.bat | 2 +-
checks/wmic_process | 17 ++++++++++-------
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3fc9973..b86d237 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -77,6 +77,8 @@
Checks & Agents:
* FIX: jolokia_metrics.mem - now able to handle negative/missing max values
* ADD: tcp_conn_stats: now additionally uses /proc/net/tcp6
+ * ADD: wmic_processs: cpucores now being considered when calculating
+ user/kernel percentages. (thanks to William Baum)
Livestatus:
* FIX: possible crash with VERY long downtime comments
diff --git a/agents/windows/plugins/wmicchecks.bat
b/agents/windows/plugins/wmicchecks.bat
index 8f69810..3980217 100644
--- a/agents/windows/plugins/wmicchecks.bat
+++ b/agents/windows/plugins/wmicchecks.bat
@@ -1,3 +1,3 @@
@echo off
echo ^<^<^<wmic_process:sep^(44^)^>^>^>
-wmic process get
name,pagefileusage,virtualsize,workingsetsize,usermodetime,kernelmodetime /format:csv
+wmic process get
name,pagefileusage,virtualsize,workingsetsize,usermodetime,kernelmodetime,ThreadCount
/format:csv
diff --git a/checks/wmic_process b/checks/wmic_process
index 7342e26..6e56849 100644
--- a/checks/wmic_process
+++ b/checks/wmic_process
@@ -28,24 +28,27 @@
def check_wmic_process(item, params, info):
name, memwarn, memcrit, pagewarn, pagecrit, cpuwarn, cpucrit = params
count, mem, page, userc, kernelc = 0, 0, 0, 0, 0
+ cpucores = 1
if len(info) == 0:
return (3, "No output from agent in section wmic_process")
legend = info[0]
for line in info[1:]:
psinfo = dict(zip(legend, line))
- if psinfo["Name"].lower() == name.lower():
- count += 1
- mem += int(psinfo["WorkingSetSize"])
- page += int(psinfo["PageFileUsage"])
- userc += int(psinfo["UserModeTime"])
+ if "ThreadCount" in legend and psinfo["Name"].lower() ==
"system idle process":
+ cpucores = int(psinfo["ThreadCount"])
+ elif psinfo["Name"].lower() == name.lower():
+ count += 1
+ mem += int(psinfo["WorkingSetSize"])
+ page += int(psinfo["PageFileUsage"])
+ userc += int(psinfo["UserModeTime"])
kernelc += int(psinfo["KernelModeTime"])
mem_mb = mem / 1048576.0
page_mb = page / 1048576.0
timedif, user_per_sec = get_counter("wmic_process.user.%s.%d" % (name,
count), time.time(), userc)
timedif, kernel_per_sec = get_counter("wmic_process.kernel.%s.%d" % (name,
count), time.time(), kernelc)
- user_perc = user_per_sec / 100000.0
- kernel_perc = kernel_per_sec / 100000.0
+ user_perc = user_per_sec / 100000.0 / cpucores
+ kernel_perc = kernel_per_sec / 100000.0 / cpucores
cpu_perc = user_perc + kernel_perc
perfdata = [
("mem", mem_mb, memwarn, memcrit),