Module: check_mk
Branch: master
Commit: 021f3a8904fc6f14db14a3971a6bf7b131945bf8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=021f3a8904fc6f…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Mon Jan 26 15:34:11 2015 +0100
doc/treasures: Windows CPU Check who creates one pnp graph by processor
---
doc/treasures/checks/winperf_processor.single | 79 +++++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/doc/treasures/checks/winperf_processor.single
b/doc/treasures/checks/winperf_processor.single
new file mode 100644
index 0000000..e83781f
--- /dev/null
+++ b/doc/treasures/checks/winperf_processor.single
@@ -0,0 +1,79 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | 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.
+
+# This Checks creates one PNP Graph for each Processor.
+# Just place it in your local/share/check_mk/checks
+
+winperf_cpu_default_levels = { "levels": ( 101.0, 101.0 ) }
+
+def inventory_winperf_single(info):
+ if len(info) <= 1:
+ return None
+
+ for line in info[1:]:
+ try:
+ if line[0] == '-232':
+ return [(None, "winperf_cpu_default_levels")]
+ except:
+ pass
+
+
+# params: levels for warn / crit in percentage
+def check_winperf_single(_no_item, params, info):
+ if not info:
+ return
+ this_time = int(float(info[0][0]))
+
+ for line in info[1:]:
+ if line[0] == '-232':
+ num_cpus = len(line)-2
+ for cpu in range(1, num_cpus):
+ ticks = int(line[cpu])
+ ticks_per_sec = get_rate("winperf_single_"+str(cpu), this_time,
ticks)
+ cpusecs_per_sec = ticks_per_sec / 10000000.0
+ used_perc = 100.0 * (1 - cpusecs_per_sec)
+
+ # Due to timeing invariancies the measured level can become > 100%.
+ # This makes users unhappy, so cut it off.
+ if used_perc < 0:
+ used_perc = 0
+ elif used_perc > 100:
+ used_perc = 100
+
+ #state, infotext, perfdata = check_cpu_single(used_perc, params,
this_time)
+ perfdata = [("CPU%s" % cpu, used_perc)]
+ infotext = "CPU%s: %d %%" % (cpu, used_perc)
+ yield 0, infotext, perfdata
+
+
+check_info["winperf_processor.single"] = {
+ 'check_function': check_winperf_single,
+ 'inventory_function': inventory_winperf_single,
+ 'service_description': 'CPU utiliztion single',
+ 'has_perfdata': True,
+ 'group': 'cpu_utilization_os',
+ #'includes': [ "cpu_single.include" ],
+}