Module: check_mk
Branch: master
Commit: 3e4538e069bc15426c4a8fd3941dc90e9d8af737
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3e4538e069bc15…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Oct 27 15:18:02 2016 +0200
Add missing file from Werk #4036
---
lib/cpu_tracking.py | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/lib/cpu_tracking.py b/lib/cpu_tracking.py
new file mode 100644
index 0000000..2e3b070
--- /dev/null
+++ b/lib/cpu_tracking.py
@@ -0,0 +1,85 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2016 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-
+# tails. 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.
+
+import os, time
+
+try:
+ _
+except NameError:
+ _ = lambda x: x # Fake i18n when not available
+
+current_phase = None
+
+def start(initial_phase):
+ global times, last_time_snapshot, current_phase, phase_stack
+ times = {}
+ last_time_snapshot = _time_snapshot()
+ current_phase = initial_phase
+ phase_stack = []
+ set_phase(initial_phase)
+
+
+def end():
+ set_phase(None)
+
+
+def set_phase(phase):
+ global current_phase
+ if current_phase != None:
+ _add_times_to_phase()
+ current_phase = phase
+
+
+def push_phase(phase):
+ if current_phase != None:
+ phase_stack.append(current_phase)
+ set_phase(phase)
+
+
+def pop_phase():
+ if current_phase != None:
+ set_phase(phase_stack[-1])
+ del phase_stack[-1]
+
+
+def get_times():
+ return times
+
+
+def _add_times_to_phase():
+ global last_time_snapshot
+ new_time_snapshot = _time_snapshot()
+ for phase in current_phase, "TOTAL":
+ phase_times = times.get(phase, [ 0.0 ] * len(new_time_snapshot))
+ times[phase] = [
+ phase_times[i] + new_time_snapshot[i] - last_time_snapshot[i]
+ for i in range(len(new_time_snapshot)) ]
+ last_time_snapshot = new_time_snapshot
+
+
+def _time_snapshot():
+ return list(os.times()[:4]) + [ time.time() ]
+
Module: check_mk
Branch: master
Commit: 8733f8cc295c09a79279386004d8e5a8d39f7c6d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8733f8cc295c09…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Oct 27 15:16:43 2016 +0200
4037 FIX Fix graphs that have optional metrics
These graphs templates are not very common, but they can be
painted even if a check does not certain metrics. The bug
resulted in these graphs not being shown and single graphs
for each of their metrics instead.
---
.werks/4037 | 12 ++++++++++++
ChangeLog | 1 +
web/htdocs/metrics.py | 5 ++++-
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/.werks/4037 b/.werks/4037
new file mode 100644
index 0000000..3c8819e
--- /dev/null
+++ b/.werks/4037
@@ -0,0 +1,12 @@
+Title: Fix graphs that have optional metrics
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.4.0i2
+Date: 1477574118
+Class: fix
+
+These graphs templates are not very common, but they can be
+painted even if a check does not certain metrics. The bug
+resulted in these graphs not being shown and single graphs
+for each of their metrics instead.
diff --git a/ChangeLog b/ChangeLog
index 34fc4c8..0450755 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -54,6 +54,7 @@
* 3898 FIX: Unmonitored services: Fixed possible bug in case discovery service produces unexpected output
* 3902 FIX: Graph search view: Changing painter options made page empty
* 3969 FIX: CentOS 5.5: Fixed incompatibility with the available OpenSSL 0.98...
+ * 4037 FIX: Fix graphs that have optional metrics...
WATO:
* 3915 User access times: New icon when never logged in; New column "last seen"
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index 648f32e..124e26a 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -619,7 +619,10 @@ def evaluate_literal(expression, translated_metrics):
unit = translated_metrics[varname]["unit"]
if color == None:
- color = parse_color_into_hexrgb(metric_info[varname]["color"])
+ if varname in metric_info:
+ color = parse_color_into_hexrgb(metric_info[varname]["color"])
+ else:
+ color = "#808080"
return value, unit, color