Module: check_mk
Branch: master
Commit: 23cda860e5850b2aa1b2198e2c4fdba559e924ae
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=23cda860e5850b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Apr 30 14:37:26 2013 +0200
Added perfometer and pnp template which visualize overcommittments for esx datastore
check
---
pnp-templates/check_mk-df.php | 32 ++++++++++++++++++++++++++---
web/plugins/perfometer/check_mk.py | 39 ++++++++++++++++++++++++++++++++----
2 files changed, 64 insertions(+), 7 deletions(-)
diff --git a/pnp-templates/check_mk-df.php b/pnp-templates/check_mk-df.php
index 917a713..35c26df 100644
--- a/pnp-templates/check_mk-df.php
+++ b/pnp-templates/check_mk-df.php
@@ -25,6 +25,16 @@
setlocale(LC_ALL, "POSIX");
+// Make data sources available via names
+$RRD = array();
+foreach ($NAME as $i => $n) {
+ $RRD[$n] = "$RRDFILE[$i]:$DS[$i]:MAX";
+ $WARN[$n] = $WARN[$i];
+ $CRIT[$n] = $CRIT[$i];
+ $MIN[$n] = $MIN[$i];
+ $MAX[$n] = $MAX[$i];
+}
+
# RRDtool Options
#$servicedes=$NAGIOS_SERVICEDESC
@@ -49,14 +59,30 @@ $opt[1] = "--vertical-label GB -l 0 -u $maxgb --title
'$hostname: Filesystem $fs
# First graph show current filesystem usage
$def[1] = "DEF:mb=$RRDFILE[1]:$DS[1]:MAX ";
$def[1] .= "CDEF:var1=mb,1024,/ ";
-$def[1] .= "AREA:var1#00ffc6:\"used space on $fsname\\n\" ";
-$def[1] .= "LINE1:var1#226600: ";
+$def[1] .= "AREA:var1#00ffc6:\"used space on $fsname\\n\" ";
+
+# Optional uncommitted usage e.g. for esx hosts
+if(isset($RRD['uncommitted'])) {
+ $def[1] .= "DEF:uncommitted_mb=".$RRD['uncommitted']."
";
+ $def[1] .= "CDEF:uncommitted_gb=uncommitted_mb,1024,/ ";
+ $def[1] .= "CDEF:total_gb=uncommitted_gb,var1,+ ";
+} else {
+ $def[1] .= "CDEF:total_gb=var1 ";
+}
+
$def[1] .= "HRULE:$maxgb#003300:\"Size ($sizegb GB) \" ";
$def[1] .= "HRULE:$warngb#ffff00:\"Warning at $warngbtxt GB \" ";
$def[1] .= "HRULE:$critgb#ff0000:\"Critical at $critgbtxt GB \\n\"
";
$def[1] .= "GPRINT:var1:LAST:\"current\: %6.2lf GB\" ";
$def[1] .= "GPRINT:var1:MAX:\"max\: %6.2lf GB \" ";
-$def[1] .= "GPRINT:var1:AVERAGE:\"avg\: %6.2lf GB\" ";
+$def[1] .= "GPRINT:var1:AVERAGE:\"avg\: %6.2lf GB\\n\" ";
+
+if(isset($RRD['uncommitted'])) {
+ $def[1] .= "AREA:uncommitted_gb#eeccff:\"Uncommited\":STACK ";
+ $def[1] .= "GPRINT:uncommitted_gb:MAX:\"%6.2lf GB\l\" ";
+}
+
+$def[1] .= "LINE1:total_gb#226600 ";
# Second graph is optional and shows trend. The MAX field
# of the third variable contains (size of the filesystem in MB
diff --git a/web/plugins/perfometer/check_mk.py b/web/plugins/perfometer/check_mk.py
index df58f7f..38c33a7 100644
--- a/web/plugins/perfometer/check_mk.py
+++ b/web/plugins/perfometer/check_mk.py
@@ -55,11 +55,10 @@ def perfometer_check_mk_df(row, check_command, perf_data):
varname, value, unit, warn, crit, minn, maxx = perf_data[0]
perc_used = 100 * (float(value) / float(maxx))
perc_free = 100 - float(perc_used)
- color = { 0: "#0f8", 1: "#ff2", 2: "#f22", 3:
"#fa2" }[row["service_state"]]
- h += perfometer_td(perc_used, color)
+ h += perfometer_td(perc_used, "#00ffc6")
h += perfometer_td(perc_free, "white")
h += "</tr></table>"
- return "%d%%" % perc_used, h
+ return "%0.2f%%" % perc_used, h
perfometers["check_mk-df"] = perfometer_check_mk_df
perfometers["check_mk-vms_df"] = perfometer_check_mk_df
@@ -72,7 +71,39 @@ perfometers["check_mk-hr_fs"] = perfometer_check_mk_df
perfometers["check_mk-oracle_asm_diskgroup"] = perfometer_check_mk_df
perfometers["check_mk-mysql_capacity"] = perfometer_check_mk_df
perfometers["check_mk-esx_vsphere_counters.ramdisk"] = perfometer_check_mk_df
-perfometers["check_mk-esx_vsphere_datastores"] = perfometer_check_mk_df
+
+def perfometer_esx_vsphere_datastores(row, check_command, perf_data):
+ used_mb = perf_data[0][1]
+ maxx = perf_data[0][-1]
+ uncommitted_mb = perf_data[3][1]
+ perc_used = 100 * (float(used_mb) / float(maxx))
+ perc_uncommitted = 100 * (float(uncommitted_mb) / float(maxx))
+ perc_totally_free = 100 - perc_used - perc_uncommitted
+ perc_free = 100 - perc_used
+
+ h = '<table><tr>'
+ if perc_used + perc_uncommitted <= 100:
+ # Regular handling, no overcommitt
+ h += perfometer_td(perc_used, "#00ffc6")
+ h += perfometer_td(perc_uncommitted, "#eeccff")
+ h += perfometer_td(perc_totally_free, "white")
+ else:
+ # Visualize overcommitted space by scaling to total overcommittment value
+ # and drawing the capacity as red line in the perfometer
+ total = perc_used + perc_uncommitted
+ perc_used = perc_used * 100 / total
+ perc_uncommitted = perc_uncommitted * 100 / total
+ perc_free = perc_free * 100 / total
+
+ h += perfometer_td(perc_used, "#00ffc6")
+ h += perfometer_td(perc_free, "#eeccff")
+ h += perfometer_td(1, "red") # This line visualizes the capacity
+ h += perfometer_td(perc_uncommitted - perc_free, "#eeccff")
+ h += "</tr></table>"
+
+ return "%0.2f%% (+%0.2f%%)" % (perc_used, perc_uncommitted), h
+
+perfometers["check_mk-esx_vsphere_datastores"] =
perfometer_esx_vsphere_datastores
def perfometer_check_mk_kernel_util(row, check_command, perf_data):