Module: check_mk
Branch: master
Commit: 1fcee8524caab7a46d2fb4fd4926de7152feee02
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1fcee8524caab7…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Feb 7 08:49:14 2017 +0100
4325 FIX check_cpu_peaks: Make the check working with current Check_MK APi
Change-Id: I01114608b250c7792b68a48a8deb00780c2f1476
---
.werks/4325 | 9 +++++++++
ChangeLog | 1 +
active_checks/.f12 | 4 ++--
active_checks/check_cpu_peaks | 27 ++++-----------------------
4 files changed, 16 insertions(+), 25 deletions(-)
diff --git a/.werks/4325 b/.werks/4325
new file mode 100644
index 0000000..cc338a2
--- /dev/null
+++ b/.werks/4325
@@ -0,0 +1,9 @@
+Title: check_cpu_peaks: Make the check working with current Check_MK APi
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i4
+Date: 1486453730
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 1e43620..a22e79a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -93,6 +93,7 @@
NOTE: Please refer to the migration notes!
* 4123 FIX: active check check_sql: changed handling of query results and fixed
hostname parameter...
* 4338 FIX: aix_hacmp_resources: fixed state handling
+ * 4325 FIX: check_cpu_peaks: Make the check working with current Check_MK APi
Multisite:
* 4169 View action: Default values of sticky, notification and persistent options can
now be configured via global settings....
diff --git a/active_checks/.f12 b/active_checks/.f12
index d2d5c70..6ed9828 100755
--- a/active_checks/.f12
+++ b/active_checks/.f12
@@ -1,10 +1,10 @@
#!/bin/bash
-SITE=${SITE:-$(cat ../../../.site 2>/dev/null)}
+SITE=${SITE:-$(cat ../.site 2>/dev/null)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
echo "Installing to /omd/sites/$SITE/lib/nagios/plugins"
make
-RSYNC_OPTS="-av
+RSYNC_OPTS="-a
--chown=root:root
--exclude=.*.swp
--exclude=Makefile
diff --git a/active_checks/check_cpu_peaks b/active_checks/check_cpu_peaks
index 30d90ab..2baf6af 100755
--- a/active_checks/check_cpu_peaks
+++ b/active_checks/check_cpu_peaks
@@ -26,23 +26,8 @@
import sys, os, time, getopt
-class MKGeneralException(Exception):
- def __init__(self, reason):
- super(MKGeneralException, self).__init__()
- self.reason = reason
-
-
- def __str__(self):
- return self.reason
-
-
-# Note: This check only works in an OMD environment!
-# TODO: Clean this mess up! Define and use an official API to predictive monitoring.
-sys.path.append(os.path.expanduser("~/share/check_mk/modules"))
-execfile(os.path.expanduser("~/etc/check_mk/defaults"))
-execfile(os.path.expanduser("~/share/check_mk/modules/prediction.py"))
-execfile(os.path.expanduser("~/share/check_mk/modules/check_mk_base.py"))
-rrdcached_socket = None
+from cmk.exceptions import MKGeneralException
+import cmk_base.prediction as prediction
def usage():
sys.stderr.write("""== check_cpu_peaks ==
@@ -112,9 +97,7 @@ try:
util_total = []
is_windows = True
try:
- # can not check for get_rrd_data because it's hacky included with execfile
- # pylint: disable=undefined-variable
- data = get_rrd_data(host, "CPU utilization", "util",
"MAX", fromtime, untiltime)
+ data = prediction.get_rrd_data(host, "CPU utilization",
"util", "MAX", fromtime, untiltime)
datasets.append(data[1])
step_secs = data[0]
#util_total = [ x for x in datasets[0] if x != None ]
@@ -125,9 +108,7 @@ try:
# looks like this is not a windows rrd...
is_windows = False
for key in ["system", "user", "wait"]:
- # can not check for get_rrd_data because it's hacky included with
execfile
- # pylint: disable=undefined-variable
- data = get_rrd_data(host, "CPU utilization", key, "MAX",
fromtime, untiltime)
+ data = prediction.get_rrd_data(host, "CPU utilization", key,
"MAX", fromtime, untiltime)
datasets.append(data[1])
step_secs = data[0]