Module: check_mk
Branch: master
Commit: 06197e7adfabbf8299280b0fb8aab52c36e85018
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=06197e7adfabbf…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Mar 9 16:49:08 2015 +0100
#2056 winperf_processor: additionally reports user and privileged(system) time
The windows performance counter already provided this information, so there is
no need to update anything. The check itself now reports the total utilization, as
well as the user and privileged percentages. The pnp template has been updated
accordingly.
---
.werks/2056 | 13 +++
ChangeLog | 1 +
checks/winperf_processor | 32 +++++--
pnp-templates/check_mk-winperf_processor.util.php | 100 ++++++++++++++++++++-
4 files changed, 136 insertions(+), 10 deletions(-)
diff --git a/.werks/2056 b/.werks/2056
new file mode 100644
index 0000000..1a54767
--- /dev/null
+++ b/.werks/2056
@@ -0,0 +1,13 @@
+Title: winperf_processor: additionally reports user and privileged(system) time
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1425916010
+Class: feature
+
+The windows performance counter already provided this information, so there is
+no need to update anything. The check itself now reports the total utilization, as
+well as the user and privileged percentages. The pnp template has been updated
+accordingly.
+
diff --git a/ChangeLog b/ChangeLog
index b4debe9..34b1132 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -117,6 +117,7 @@
* 2099 ibm_svc_portsas, ibm_svc_portfc: checks now have a more meaningful service
description if the device firmware supports it...
NOTE: Please refer to the migration notes!
* 1225
sansymphony_alerts,sansymphony_pool,sansymphony_ports,sansymphony_serverstatus,sansymphony_virtualdiskstatus:
New Checks for Datacore Sansymphony...
+ * 2056 winperf_processor: additionally reports user and privileged(system) time...
* 1457 FIX: logins: new check renamed from "users" check...
NOTE: Please refer to the migration notes!
* 1762 FIX: lnx_thermal: Now ignoring trip points with level 0...
diff --git a/checks/winperf_processor b/checks/winperf_processor
index ed1309d..69120aa 100644
--- a/checks/winperf_processor
+++ b/checks/winperf_processor
@@ -42,16 +42,22 @@ def inventory_winperf_util(info):
# params: levels for warn / crit in percentage
def check_winperf_util(_no_item, params, info):
if not info:
- return 3, "Got no information from agent"
+ yield 3, "Got no information from agent"
+ return
+
this_time = int(float(info[0][0]))
+ what_map = { "-232": "util",
+ "-96": "user",
+ "-94": "privileged"}
for line in info[1:]:
- if line[0] == '-232':
+ if line[0] in what_map:
+ what = what_map[line[0]]
# Windows sends one counter for each CPU plus one counter that
# sums up to total (called _Total). We only need that last value.
ticks = int(line[-2])
num_cpus = len(line) - 3
- ticks_per_sec = get_rate("winperf_util", this_time, ticks, onwrap =
RAISE)
+ ticks_per_sec = get_rate("winperf_util.%s" % what, this_time,
ticks, onwrap = RAISE)
# We get the value of the PERF_100NSEC_TIMER_INV here.
# This counter type shows the average percentage of active time observed
# during the sample interval. This is an inverse counter. Counters of this
@@ -60,7 +66,11 @@ def check_winperf_util(_no_item, params, info):
#
# 1 tick = 100ns, convert to seconds
cpusecs_per_sec = ticks_per_sec / 10000000.0
- used_perc = 100.0 * (1 - cpusecs_per_sec)
+
+ if what == "util":
+ used_perc = 100.0 * (1 - cpusecs_per_sec)
+ else:
+ used_perc = 100.0 * cpusecs_per_sec
# Due to timeing invariancies the measured level can become > 100%.
# This makes users unhappy, so cut it off.
@@ -69,12 +79,16 @@ def check_winperf_util(_no_item, params, info):
elif used_perc > 100:
used_perc = 100
- state, infotext, perfdata = check_cpu_util(used_perc, params, this_time)
- perfdata[0] = perfdata[0][:5] + (num_cpus,)
- infotext += ", %d CPUs" % num_cpus
- return state, infotext, perfdata
+ if what == "util":
+ state, infotext, perfdata = check_cpu_util(used_perc, params, this_time)
+ perfdata[0] = perfdata[0][:5] + (num_cpus,)
+ yield state, infotext, perfdata
+ elif what == "user":
+ yield 0, "%s perc: %.1f %%" % (what, used_perc), [(what,
used_perc)]
+ else: # privileged
+ yield 0, "%s perc: %.1f %%" % (what, used_perc)
- return (3, "counter for CPU (6) not found")
+ yield 0, "%d CPUs" % num_cpus
check_info["winperf_processor.util"] = {
diff --git a/pnp-templates/check_mk-winperf_processor.util.php
b/pnp-templates/check_mk-winperf_processor.util.php
deleted file mode 120000
index a7d9073..0000000
--- a/pnp-templates/check_mk-winperf_processor.util.php
+++ /dev/null
@@ -1 +0,0 @@
-check_mk-esx_vsphere_hostsystem.cpu_usage.php
\ No newline at end of file
diff --git a/pnp-templates/check_mk-winperf_processor.util.php
b/pnp-templates/check_mk-winperf_processor.util.php
new file mode 100644
index 0000000..d9d232b
--- /dev/null
+++ b/pnp-templates/check_mk-winperf_processor.util.php
@@ -0,0 +1,99 @@
+<?php
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+# Do not depend on numbers, use names
+$RRD = array();
+foreach ($NAME as $i => $n) {
+ $RRD[$n] = "$RRDFILE[$i]:$DS[$i]:MAX";
+ $RRD_AVG[$n] = "$RRDFILE[$i]:$DS[$i]:AVERAGE";
+ $WARN[$n] = $WARN[$i];
+ $CRIT[$n] = $CRIT[$i];
+ $MIN[$n] = $MIN[$i];
+ $MAX[$n] = $MAX[$i];
+}
+
+$num_threads = $MAX[1];
+$warnthreads = $WARN[1] * $num_threads / 100.0;
+$critthreads = $CRIT[1] * $num_threads / 100.0;
+$rightscale = 100.0 / $num_threads;
+
+$opt[1] = "--vertical-label 'Used CPU threads' --right-axis $rightscale:0
--right-axis-format '%4.1lf%%' --right-axis-label 'Utilization %' -l0 -ru
$num_threads --title \"CPU Utilization for $hostname ($num_threads CPU
threads)\" ";
+
+$def[1] = "DEF:perc=$RRD_AVG[util] "
+ . "CDEF:util=perc,$num_threads,*,100,/ "
+ . "DEF:userperc=$RRD_AVG[user] "
+ . "CDEF:user=userperc,$num_threads,*,100,/ "
+ . "CDEF:privileged=util,user,- "
+ . "CDEF:privilegedperc=privileged,$num_threads,/,100,* "
+ ;
+
+$def[1] .= "HRULE:$MAX[util]#0040d0:\"$num_threads CPU Threads\\n\"
"
+ ;
+
+$def[1] .= "LINE:util#50b01a:\"Utilization\: \" "
+ . "GPRINT:perc:LAST:\"%4.1lf%%\" "
+ . "GPRINT:util:LAST:\"(%3.1lf Threads) \" "
+ . "GPRINT:perc:MIN:\"min\: %4.1lf%%,\t\" "
+ . "GPRINT:util:MIN:\"(%4.1lf), \" "
+ . "GPRINT:perc:MAX:\"max\: %4.1lf%%\" "
+ . "GPRINT:util:MAX:\"(%4.1lf)\\n\" "
+
+ . "AREA:privileged#f03020:\"Privileged perc\:\" "
+ . "GPRINT:privilegedperc:LAST:\"%4.1lf%%\" "
+ . "GPRINT:privileged:LAST:\"(%3.1lf Threads) \" "
+ . "GPRINT:privilegedperc:MIN:\"min\: %4.1lf%%,\t\" "
+ . "GPRINT:privileged:MIN:\"(%4.1lf), \" "
+ . "GPRINT:privilegedperc:MAX:\"max\: %4.1lf%%\" "
+ . "GPRINT:privileged:MAX:\"(%4.1lf)\\n\" "
+
+ . "AREA:user#6060f0:\"User perc\: \":STACK "
+ . "GPRINT:userperc:LAST:\"%4.1lf%%\" "
+ . "GPRINT:user:LAST:\"(%3.1lf Threads) \" "
+ . "GPRINT:userperc:MIN:\"min\: %4.1lf%%,\t\" "
+ . "GPRINT:user:MIN:\"(%4.1lf), \" "
+ . "GPRINT:userperc:MAX:\"max\: %4.1lf%%\" "
+ . "GPRINT:user:MAX:\"(%4.1lf)\\n\" "
+ ;
+
+
+if (isset($RRD_AVG["avg"])) {
+ $def[1] .= "DEF:aperc=$RRD_AVG[avg] ".
+ "CDEF:avg=aperc,$num_threads,*,100,/ ".
+ "LINE:avg#004000:\"Averaged\: \" ".
+ "GPRINT:aperc:LAST:\"%.1lf%%,\" ".
+ "GPRINT:aperc:MIN:\"min\: %.1lf%%,\" ".
+ "GPRINT:aperc:MAX:\"max\: %.1lf%%\\n\" ".
+ "";
+}
+
+if ($WARN['util']) {
+ $def[1] .= "HRULE:$warnthreads#fff000:\"Warn at $WARN[util]% \"
"
+ . "HRULE:$critthreads#ff0000:\"Critical at $CRIT[util]%\\n\"
";
+}
+else {
+ $def[1] .= "COMMENT:\"\\n\" ";
+}
+
+?>