Module: check_mk
Branch: master
Commit: 135113889098295edd3524bcbebbb62ab699bfcb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=13511388909829…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jun 26 11:36:44 2015 +0200
New key for graph definitions: optional_metrics
---
web/htdocs/metrics.py | 43 +++++++++++++++++++++++++++++++++++++--
web/plugins/metrics/check_mk.py | 13 ++++--------
2 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index fce0a6a..fcd3343 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -836,9 +836,13 @@ def get_graph_templates(translated_metrics):
for graph_template in graph_info:
if graph_possible(graph_template, translated_metrics):
yield graph_template
+ elif graph_possible_without_optional_metrics(graph_template,
translated_metrics):
+ html.debug("JA")
+ yield graph_without_missing_optional_metrics(graph_template,
translated_metrics)
def graph_possible(graph_template, translated_metrics):
+
for metric_definition in graph_template["metrics"]:
try:
evaluate(metric_definition[0], translated_metrics)
@@ -847,13 +851,48 @@ def graph_possible(graph_template, translated_metrics):
# Allow graphs to be disabled if certain (better) metrics
# are available
- if "not_if_have" in graph_template:
- for var in graph_template["not_if_have"]:
+ if "conflicting_metrics" in graph_template:
+ for var in graph_template["conflicting_metrics"]:
if var in translated_metrics:
return False
return True
+
+def graph_possible_without_optional_metrics(graph_template, translated_metrics):
+ if "optional_metrics" in graph_template:
+ return graph_possible(graph_template,
+ add_fake_metrics(translated_metrics,
graph_template["optional_metrics"]))
+
+
+def graph_without_missing_optional_metrics(graph_template, translated_metrics):
+ working_metrics = []
+
+ for metric_definition in graph_template["metrics"]:
+ try:
+ evaluate(metric_definition[0], translated_metrics)
+ working_metrics.append(metric_definition)
+ except:
+ pass
+
+ reduced_graph_template = graph_template.copy()
+ reduced_graph_template["metrics"] = working_metrics
+ html.debug(reduced_graph_template)
+ return reduced_graph_template
+
+
+
+def add_fake_metrics(translated_metrics, metric_names):
+ with_fake = translated_metrics.copy()
+ for metric_name in metric_names:
+ with_fake[metric_name] = {
+ "value" : 1.0,
+ "scale" : 1.0,
+ "unit" : unit_info[""],
+ "color" : "#888888",
+ }
+ return with_fake
+
# Called with exactly one variable: the template ID. Example:
# "check_mk-kernel.util:guest,steal,system,user,wait".
def page_pnp_template():
diff --git a/web/plugins/metrics/check_mk.py b/web/plugins/metrics/check_mk.py
index 34ea12c..e206d69 100644
--- a/web/plugins/metrics/check_mk.py
+++ b/web/plugins/metrics/check_mk.py
@@ -1802,7 +1802,7 @@ graph_info.append({
"scalars" : [
"load1:warn",
"load1:crit",
- ]
+ ],
})
graph_info.append({
@@ -1988,12 +1988,10 @@ graph_info.append({
],
})
-# TODO: Warum sind die in einem Graphen? Kann man
-# die irgendwie addieren?
graph_info.append({
"metrics" : [
- ( "deadlocks", "line" ),
- ( "lockwaits", "line" ),
+ ( "deadlocks", "area" ),
+ ( "lockwaits", "stack" ),
],
})
@@ -2003,9 +2001,6 @@ graph_info.append({
],
})
-# TODO: Warum auch hier line? Sollte mit
-# areas arbeiten. Habe das mal umgestellt, aber noch
-# nicht getestet.
graph_info.append({
"metrics" : [
( "tablespace_used", "area" ),
@@ -2116,7 +2111,7 @@ graph_info.append({
("mem_lnx_active", "area"),
("mem_lnx_inactive", "area"),
],
- "not_if_have" : [ "mem_lnx_active_anon" ],
+ "conflicting_metrics" : [ "mem_lnx_active_anon" ],
})
graph_info.append({