Module: check_mk
Branch: master
Commit: 3deb8c1d87cdc36f7316fa544fbee16f53d6410b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3deb8c1d87cdc3…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Jun 30 16:41:11 2015 +0200
Automatically create graphs for all perf variables that are not graphed
---
web/htdocs/metrics.py | 75 ++++++++++++++++++++++++++++++++++++---
web/plugins/metrics/check_mk.py | 53 +++++++++++++++++++++------
2 files changed, 112 insertions(+), 16 deletions(-)
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index b48b99e..de87d5f 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -192,6 +192,10 @@ cmk_color_palette = {
"53" : (0.083, 0.8, 0.55), # brown 2
}
+def get_palette_color_by_index(i, shading='a'):
+ color_key = sorted(cmk_color_palette.keys())[i % len(cmk_color_palette)]
+ return "%s/%s" % (color_key, shading)
+
# 23/c -> #ff8040
# #ff8040 -> #ff8040
@@ -326,6 +330,7 @@ def translate_metrics(perf_data, check_command):
cm = check_metrics[check_command]
translated_metrics = {}
+ color_index = 0
for nr, entry in enumerate(perf_data):
varname = entry[0]
@@ -342,12 +347,17 @@ def translate_metrics(perf_data, check_command):
# Translate name
metric_name = translation_entry.get("name", varname)
+ if metric_name in translated_metrics:
+ continue # ignore duplicate value
if metric_name not in metric_info:
+ color_index += 1
+ palette_color = get_palette_color_by_index(color_index)
mi = {
- "title" : metric_name,
- "unit" : "count",
- "color" : "#888888",
+ "title" : metric_name.title(),
+ "unit" : "",
+ "color" : parse_color_into_hexrgb(palette_color),
+ "palHIRN" : palette_color,
}
else:
mi = metric_info[metric_name].copy()
@@ -833,11 +843,54 @@ def build_perfometer(perfometer, translated_metrics):
def get_graph_templates(translated_metrics):
if not translated_metrics:
return
+
+ explicit_templates = get_explicit_graph_templates(translated_metrics)
+ already_graphed_metrics = get_graphed_metrics(explicit_templates)
+ implicit_templates = get_implicit_graph_templates(translated_metrics,
already_graphed_metrics)
+ templates = explicit_templates + implicit_templates
+ return templates
+
+
+def get_explicit_graph_templates(translated_metrics):
+ templates = []
for graph_template in graph_info:
if graph_possible(graph_template, translated_metrics):
- yield graph_template
+ templates.append(graph_template)
elif graph_possible_without_optional_metrics(graph_template,
translated_metrics):
- yield graph_without_missing_optional_metrics(graph_template,
translated_metrics)
+ templates.append(graph_without_missing_optional_metrics(graph_template,
translated_metrics))
+ return templates
+
+
+def get_implicit_graph_templates(translated_metrics, already_graphed_metrics):
+ templates = []
+ for metric_name in sorted(translated_metrics.keys()):
+ if metric_name not in already_graphed_metrics:
+ templates.append(generic_graph_template(metric_name))
+ return templates
+
+
+def get_graphed_metrics(graph_templates):
+ graphed_metrics = set([])
+ for graph_template in graph_templates:
+ graphed_metrics.update(metrics_used_by_graph(graph_template))
+ return graphed_metrics
+
+
+def metrics_used_by_graph(graph_template):
+ used_metrics = []
+ for metric_definition in graph_template["metrics"]:
+ used_metrics += list(metrics_used_in_definition(metric_definition[0]))
+ return used_metrics
+
+
+def metrics_used_in_definition(metric_definition):
+ without_unit = metric_definition.split("@")[0]
+ without_color = metric_definition.split("#")[0]
+ parts = without_color.split(",")
+ for part in parts:
+ metric_name = part.split(".")[0] # drop .min, .max, .average
+ if metric_name in metric_info:
+ yield metric_name
def graph_possible(graph_template, translated_metrics):
@@ -891,6 +944,18 @@ def add_fake_metrics(translated_metrics, metric_names):
}
return with_fake
+def generic_graph_template(metric_name):
+ return {
+ "metrics" : [
+ ( metric_name, "area" ),
+ ],
+ "scalars" : [
+ metric_name + ":warn",
+ metric_name + ":crit",
+ ]
+ }
+
+
# 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 e32af7b..b9ec17e 100644
--- a/web/plugins/metrics/check_mk.py
+++ b/web/plugins/metrics/check_mk.py
@@ -871,6 +871,20 @@ metric_info["io_wait"] = {
"color" : "#00b0c0",
}
+metric_info["cpu_util_guest"] = {
+ "title" : _("Guest operating systems"),
+ "help" : _("CPU time spent for executing guest operating
systems"),
+ "unit" : "%",
+ "color" : "12/a",
+}
+
+metric_info["cpu_util_steal"] = {
+ "title" : _("Steal"),
+ "help" : _("CPU time stolen by other operating systems"),
+ "unit" : "%",
+ "color" : "16/a",
+}
+
metric_info["idle"] = {
"title" : _("Idle"),
"help" : _("CPU idle time"),
@@ -2530,7 +2544,12 @@ check_metrics["check_mk-mysql_capacity"]
= {}
check_metrics["check_mk-mysql_slave"] = {}
check_metrics["check_mk-hr_cpu"] = {}
-check_metrics["check_mk-kernel.util"] = {
"wait" : { "name" : "io_wait" } }
+check_metrics["check_mk-kernel.util"] = {
+ "wait" : { "name" : "io_wait" },
+ "guest" : { "name" : "cpu_util_guest" },
+ "steal" : { "name" : "cpu_util_steal" },
+}
+
check_metrics["check_mk-lparstat_aix.cpu_util"] = {
"wait" : { "name" : "io_wait" } }
check_metrics["check_mk-ucd_cpu_util"] = {
"wait" : { "name" : "io_wait" } }
check_metrics["check_mk-vms_cpu"] = {
"wait" : { "name" : "io_wait" } }
@@ -2835,6 +2854,8 @@ check_metrics["check_mk-ps.perf"] =
check_metrics["check_mk-ps"]
check_metrics["check_mk-ruckus_spot_ap"] = {}
+check_metrics["check_mk-local"] = {}
+
#.
# .--Perf-O-Meters-------------------------------------------------------.
# | ____ __ ___ __ __ _ |
@@ -3384,15 +3405,7 @@ perfometer_info.append({
# ('tablespace_used', 'area')
def define_generic_graph(metric_name):
- graph_info.append({
- "metrics" : [
- ( metric_name, "area" ),
- ],
- "scalars" : [
- metric_name + ":warn",
- metric_name + ":crit",
- ]
- })
+ graph_info.append(generic_graph_template(metric_name))
define_generic_graph("context_switches")
define_generic_graph("major_page_faults")
@@ -3782,6 +3795,25 @@ graph_info.append({
( "io_wait", "stack" ),
( "user,system,io_wait,+,+#004080", "line",
_("Total") ),
],
+ "conflicting_metrics" : [
+ "cpu_util_guest",
+ "cpu_util_steal",
+ ],
+ "mirror_legend" : True,
+ "range" : (0, 100),
+})
+
+graph_info.append({
+ "title" : _("CPU utilization"),
+ "metrics" : [
+ ( "user", "area" ),
+ ( "system", "stack" ),
+ ( "io_wait", "stack" ),
+ ( "cpu_util_guest", "stack" ),
+ ( "cpu_util_steal", "stack" ),
+ ( "user,system,io_wait,cpu_util_guest,cpu_util_steal,+,+,+,+#004080",
"line", _("Total") ),
+ ],
+ "omit_zero_metrics" : True,
"mirror_legend" : True,
"range" : (0, 100),
})
@@ -4273,7 +4305,6 @@ graph_info.append({
"scalars" : [
"mem_heap:warn",
"mem_heap:crit",
- "mem_heap:max",
]
})