[checkmk-commits] Check_MK Git: check_mk: #1860 df and other filesystem checks:

Goetz Golla gg at mathias-kettner.de
Tue Feb 3 18:13:46 CET 2015


  process total fs size as perfdata
Message-ID: <54d101ca.PN716HMBM2MJIM73%gg at mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Module: check_mk
Branch: master
Commit: f6aa51ca381fb724ada14ba386e9e4afd8dee64d
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f6aa51ca381fb724ada14ba386e9e4afd8dee64d

Author: Goetz Golla <gg at mathias-kettner.de>
Date:   Tue Feb  3 18:12:52 2015 +0100

#1860 df and other filesystem checks: process total fs size as perfdata

Since the total size of a filesystem may change we store the total size
as additional performance data and plot it with rrdtools like the used space.
As a consequence another rrd database file is created for every filesystem,
and slightly more disk space will be used for the rrd data of your site.

---

 .werks/1860                   |   13 +++++++++++++
 ChangeLog                     |    1 +
 checks/df.include             |    1 +
 pnp-templates/check_mk-df.php |   22 +++++++++++++---------
 4 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/.werks/1860 b/.werks/1860
new file mode 100644
index 0000000..6495038
--- /dev/null
+++ b/.werks/1860
@@ -0,0 +1,13 @@
+Title: df and other filesystem checks: process total fs size as perfdata
+Level: 2
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1422983316
+Class: feature
+
+
+Since the total size of a filesystem may change we store the total size
+as additional performance data and plot it with rrdtools like the used space.
+As a consequence another rrd database file is created for every filesystem,
+and slightly more disk space will be used for the rrd data of your site.
diff --git a/ChangeLog b/ChangeLog
index 6ca25b2..b6f1e91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -69,6 +69,7 @@
     * 1219 synology_disks, synology_fans, synology_info, synology_raid, synology_status, synology_update: Multiple Synology NAS Checks
     * 1968 qlogic_fcport, qlogic_sanbox, qlogic_sanbox_fabric_element: Supporting SAN Switch Module for IBM BladeCenter(R) now
     * 1220 if,if64: Discovery can now be based on port description...
+    * 1860 df and other filesystem checks: process total fs size as perfdata...
     * 1457 FIX: logins: new check renamed from "users" check...
             NOTE: Please refer to the migration notes!
     * 1762 FIX: lnx_thermal: Now ignoring trip points with level 0...
diff --git a/checks/df.include b/checks/df.include
index b48a5eb..921e126 100644
--- a/checks/df.include
+++ b/checks/df.include
@@ -309,6 +309,7 @@ def df_check_filesystem_single(hostname, mountpoint, size_mb, avail_mb, reserved
     # TODO: In some future version use a fixed name as perf variable
     perf_var = mountpoint.replace(" ", "_")
     perfdata = [(perf_var, str(used_mb) + 'MB', warn_mb, crit_mb, 0, size_mb)]
+    perfdata.append(('fs_size', str(size_mb) + 'MB'))
 
     if size_gb < 10240:
         infotext = "%.1f%% used (%.2f of %.2f GB)" % (used_perc, used_mb / 1024.0, size_gb)
diff --git a/pnp-templates/check_mk-df.php b/pnp-templates/check_mk-df.php
index d936251..1e4126a 100644
--- a/pnp-templates/check_mk-df.php
+++ b/pnp-templates/check_mk-df.php
@@ -66,25 +66,30 @@ $opt[1] = "--vertical-label GB -l 0 -u $maxgb --title '$hostname: Filesystem $fs
 
 # First graph show current filesystem usage. If there is a "reserved" RRD
 # then substract that and show as extra area
+$def[1] = "DEF:mb=$RRDFILE[1]:$DS[1]:MAX ";
 if (isset($RRD['reserved']))
 {
-    $def[1] = "DEF:mb=$RRDFILE[1]:$DS[1]:MAX ";
     $def[1] .= "DEF:reserved=$RRD[reserved] ";
     $def[1] .= "CDEF:used=mb,reserved,- ";
     $def[1] .= "CDEF:var1=used,1024,/ ";
-    $def[1] .= "AREA:var1#00ffc6:\"used space on $fsname\\n\" ";
+    $def[1] .= "AREA:var1#00ffc6:\"used space on $fsname\" ";
     $def[1] .= "CDEF:reserved_gb=reserved,1024,/ ";
-    $def[1] .= "AREA:reserved_gb#48b79e:\"reserved for root\\n\" ";
-
+    $def[1] .= "AREA:reserved_gb#B748B2:\"reserved for root\\n\" ";
 }
-else
-{
-#
-    $def[1] = "DEF:mb=$RRDFILE[1]:$DS[1]:MAX ";
+else {
     $def[1] .= "CDEF:var1=mb,1024,/ ";
     $def[1] .= "AREA:var1#00ffc6:\"used space on $fsname\\n\" ";
 }
 
+# Optional size of fs plotted
+if(isset($RRD['fs_size'])) {
+    $def[1] .= "DEF:size_plotted_mb=".$RRD['fs_size']." ";
+    $def[1] .= "CDEF:size_plotted_gb=size_plotted_mb,1024,/ ";
+    $def[1] .= "LINE:size_plotted_gb#003300:\"Size $sizegb GB \" ";
+} else {
+    $def[1] .= "HRULE:$maxgb#003300:\"Size ($sizegb GB) \" ";
+}
+
 # Optional uncommitted usage e.g. for esx hosts
 if (isset($RRD['uncommitted'])) {
     $def[1] .= "DEF:uncommitted_mb=".$RRD['uncommitted']." ";
@@ -95,7 +100,6 @@ 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\" ";



More information about the checkmk-commits mailing list