summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/check_disk.c27
-rw-r--r--plugins/t/check_disk.t2
2 files changed, 25 insertions, 4 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 3c7b0ecf..a88d2a1b 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -159,6 +159,8 @@ main (int argc, char **argv)
159 double dfree_pct = -1, dused_pct = -1; 159 double dfree_pct = -1, dused_pct = -1;
160 double dused_units, dfree_units, dtotal_units; 160 double dused_units, dfree_units, dtotal_units;
161 double dused_inodes_percent, dfree_inodes_percent; 161 double dused_inodes_percent, dfree_inodes_percent;
162 double warning_high_tide = UINT_MAX;
163 double critical_high_tide = UINT_MAX;
162 int temp_result; 164 int temp_result;
163 165
164 struct mount_entry *me; 166 struct mount_entry *me;
@@ -284,13 +286,30 @@ main (int argc, char **argv)
284 286
285 result = max_state(result, disk_result); 287 result = max_state(result, disk_result);
286 288
289 /* What a mess of units. The output shows free space, the perf data shows used space. Yikes!
290 Hack here. Trying to get warn/crit levels from freespace_(units|percent) for perf
291 data. Assumption that start=0. Roll on new syntax...
292 */
293 if (path->freespace_units->warning != NULL) {
294 warning_high_tide = dtotal_units - path->freespace_units->warning->end;
295 }
296 if (path->freespace_percent->warning != NULL) {
297 warning_high_tide = abs( min( (double) warning_high_tide, (double) (1.0 - path->freespace_percent->warning->end/100)*dtotal_units ));
298 }
299 if (path->freespace_units->critical != NULL) {
300 critical_high_tide = dtotal_units - path->freespace_units->critical->end;
301 }
302 if (path->freespace_percent->critical != NULL) {
303 critical_high_tide = abs( min( (double) critical_high_tide, (double) (1.0 - path->freespace_percent->critical->end/100)*dtotal_units ));
304 }
305
287 asprintf (&perf, "%s %s", perf, 306 asprintf (&perf, "%s %s", perf,
288 perfdata ((!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, 307 perfdata ((!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
289 dused_units, units, 308 dused_units, units,
290 FALSE, 0, /* min ((uintmax_t)dtotal_units-(uintmax_t)w_df, (uintmax_t)((1.0-w_dfp/100.0)*dtotal_units)), */ 309 TRUE, warning_high_tide,
291 FALSE, 0, /* min ((uintmax_t)dtotal_units-(uintmax_t)c_df, (uintmax_t)((1.0-c_dfp/100.0)*dtotal_units)), */ 310 TRUE, critical_high_tide,
292 FALSE, 0, /* inode_space_pct - this is not meant to be here???, */ 311 TRUE, 0,
293 FALSE, 0));; /* dtotal_units)); */ 312 TRUE, dtotal_units));
294 313
295 if (disk_result==STATE_OK && erronly && !verbose) 314 if (disk_result==STATE_OK && erronly && !verbose)
296 continue; 315 continue;
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index ec3d248c..e8e35b9f 100644
--- a/plugins/t/check_disk.t
+++ b/plugins/t/check_disk.t
@@ -5,6 +5,8 @@
5# $Id$ 5# $Id$
6# 6#
7 7
8# TODO: Add in tests for perf data. Need to beef up Nagios::Plugin::Performance to cater for max, min, etc
9
8use strict; 10use strict;
9use Test::More; 11use Test::More;
10use NPTest; 12use NPTest;