Module: check_mk
Branch: master
Commit: acb7702b490ef28ae392e3d256b9b0051162ffc6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=acb7702b490ef2…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Thu Jun 13 10:54:11 2013 +0200
check_mk-df.php now uses names instead of offsets
---
ChangeLog | 1 +
pnp-templates/check_mk-df.php | 36 +++++++++++++++++++-----------------
2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7b72d7d..61a1d66 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,7 @@
performance value. This might not always be the one you like, but
its far better than nothing.
* logwatch: Logwatch icon no longer uses notes_url
+ * check_mk-if.pnp: fixed bug with pnp template on esx hosts without perfdata
Checks & Agents:
* esx_hostystem multipath: criticize standby paths only if not equal to active paths
diff --git a/pnp-templates/check_mk-df.php b/pnp-templates/check_mk-df.php
index 35c26df..4bb18da 100644
--- a/pnp-templates/check_mk-df.php
+++ b/pnp-templates/check_mk-df.php
@@ -28,7 +28,9 @@ setlocale(LC_ALL, "POSIX");
// Make data sources available via names
$RRD = array();
foreach ($NAME as $i => $n) {
- $RRD[$n] = "$RRDFILE[$i]:$DS[$i]:MAX";
+ $RRD[$n] = "$RRDFILE[$i]:$DS[$i]:MAX";
+ $RRD_MIN[$n] = "$RRDFILE[$i]:$DS[$i]:MIN";
+ $RRD_AVG[$n] = "$RRDFILE[$i]:$DS[$i]:AVERAGE";
$WARN[$n] = $WARN[$i];
$CRIT[$n] = $CRIT[$i];
$MIN[$n] = $MIN[$i];
@@ -87,8 +89,8 @@ $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
# / range in hours). From that we can compute the configured range.
-if (isset($DS[2])) {
- $size_mb_per_hours = floatval($MAX[3]); // this is size_mb / range(hours)
+if (isset($RRD['growth'])) {
+ $size_mb_per_hours = floatval($MAX['trend']); // this is size_mb /
range(hours)
$size_mb = floatval($MAX[1]);
$hours = 1.0 / ($size_mb_per_hours / $size_mb);
$range = sprintf("%.0fh", $hours);
@@ -96,32 +98,32 @@ if (isset($DS[2])) {
// Current growth / shrinking. This value is give as MB / 24 hours.
// Note: This has changed in 1.1.13i3. Prior it was MB / trend_range!
$opt[2] = "--vertical-label '+/- MB / 24h' -l -1 -u 1 -X0 --title
'$hostname: Growth of $fstitle' ";
- $def[2] = "DEF:growth_max=$RRDFILE[2]:$DS[2]:MAX ";
- $def[2] .= "DEF:growth_min=$RRDFILE[2]:$DS[2]:MIN ";
- $def[2] .= "DEF:trend=$RRDFILE[3]:$DS[3]:AVERAGE ";
+ $def[2] = "DEF:growth_max=${RRD['growth']} ";
+ $def[2] .= "DEF:growth_min=${RRD_MIN['growth']} ";
+ $def[2] .= "DEF:trend=${RRD_AVG['trend']} ";
$def[2] .= "CDEF:growth_pos=growth_max,0,MAX ";
$def[2] .= "CDEF:growth_neg=growth_min,0,MIN ";
- $def[2] .= "CDEF:growth_minabs=0,growth_min,- ";
+ $def[2] .= "CDEF:growth_minabs=0,growth_min,- ";
$def[2] .= "CDEF:growth=growth_minabs,growth_max,MAX ";
$def[2] .= "HRULE:0#c0c0c0 ";
- $def[2] .= "AREA:growth_pos#3060f0:\"Grow\" ";
- $def[2] .= "AREA:growth_neg#30f060:\"Shrink \" ";
+ $def[2] .= "AREA:growth_pos#3060f0:\"Grow\" ";
+ $def[2] .= "AREA:growth_neg#30f060:\"Shrink \" ";
$def[2] .= "GPRINT:growth:LAST:\"Current\: %+9.2lfMB / 24h\" ";
$def[2] .= "GPRINT:growth:MAX:\"Max\: %+9.2lfMB / 24h\\n\" ";
// Trend
$opt[3] = "--vertical-label '+/- MB / 24h' -l -1 -u 1 -X0 --title
'$hostname: Trend for $fstitle' ";
- $def[3] = "DEF:trend=$RRDFILE[3]:$DS[3]:AVERAGE ";
+ $def[3] = "DEF:trend=${RRD_AVG['trend']} ";
$def[3] .= "HRULE:0#c0c0c0 ";
$def[3] .= "LINE1:trend#000000:\"Trend\:\" ";
- $def[3] .= "GPRINT:trend:LAST:\"%+7.2lf MB/24h\" ";
- if ($WARN[3]) {
- $warn_mb = sprintf("%.2fMB", $WARN[3] * $hours / 24.0);
- $def[3] .= "LINE1:$WARN[3]#ffff00:\"Warn\: $warn_mb / $range\"
";
+ $def[3] .= "GPRINT:trend:LAST:\"%+7.2lf MB/24h\" ";
+ if ($WARN['trend']) {
+ $warn_mb = sprintf("%.2fMB", $WARN['trend'] * $hours / 24.0);
+ $def[3] .= "LINE1:${WARN['trend']}#ffff00:\"Warn\: $warn_mb /
$range\" ";
}
- if ($CRIT[3]) {
- $crit_mb = sprintf("%.2fMB", $CRIT[3] * $hours / 24.0);
- $def[3] .= "LINE1:$CRIT[3]#ff0000:\"Crit\: $crit_mb / $range\"
";
+ if ($CRIT['trend']) {
+ $crit_mb = sprintf("%.2fMB", $CRIT['trend'] * $hours / 24.0);
+ $def[3] .= "LINE1:${CRIT['trend']}#ff0000:\"Crit\: $crit_mb /
$range\" ";
}
$def[3] .= "COMMENT:\"\\n\" ";
}