Index: plugins/check_disk.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_disk.c,v retrieving revision 1.82 diff -u -r1.82 check_disk.c --- plugins/check_disk.c 7 Jan 2007 07:14:04 -0000 1.82 +++ plugins/check_disk.c 27 Jan 2007 18:01:18 -0000 @@ -306,16 +306,16 @@ critical_high_tide = UINT_MAX; if (path->freespace_units->warning != NULL) { - warning_high_tide = dtotal_units - path->freespace_units->warning->end; + warning_high_tide = path->freespace_units->warning->end; } if (path->freespace_percent->warning != NULL) { - warning_high_tide = abs( min( (double) warning_high_tide, (double) (1.0 - path->freespace_percent->warning->end/100)*dtotal_units )); + warning_high_tide = abs( min( (double) warning_high_tide, (double) path->freespace_percent->warning->end/100*dtotal_units )); } if (path->freespace_units->critical != NULL) { - critical_high_tide = dtotal_units - path->freespace_units->critical->end; + critical_high_tide = path->freespace_units->critical->end; } if (path->freespace_percent->critical != NULL) { - critical_high_tide = abs( min( (double) critical_high_tide, (double) (1.0 - path->freespace_percent->critical->end/100)*dtotal_units )); + critical_high_tide = abs( min( (double) critical_high_tide, (double) path->freespace_percent->critical->end/100*dtotal_units )); } asprintf (&perf, "%s %s", perf, Index: plugins/t/check_disk.t =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_disk.t,v retrieving revision 1.16 diff -u -r1.16 check_disk.t --- plugins/t/check_disk.t 8 Jan 2007 11:05:55 -0000 1.16 +++ plugins/t/check_disk.t 27 Jan 2007 18:01:18 -0000 @@ -24,7 +24,7 @@ if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") { plan skip_all => "Need 2 mountpoints to test"; } else { - plan tests => 57; + plan tests => 61; } $result = NPTest->testCmd( @@ -76,6 +76,24 @@ die "Two mountpoints with same inodes free - cannot do rest of test"; } +# Verify performance data +# First check absolute thresholds... +$result = NPTest->testCmd( + "./check_disk -w 20 -c 10 -p $mountpoint_valid" + ); +$_ = $result->perf_output; +my ($warn_absth_data, $crit_absth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;\d+/); +is ($warn_absth_data, 20, "Wrong warning in perf data using absolute thresholds"); +is ($crit_absth_data, 10, "Wrong critical in perf data using absolute thresholds"); + +# Then check percent thresholds. +$result = NPTest->testCmd( + "./check_disk -w 20% -c 10% -p $mountpoint_valid" + ); +$_ = $result->perf_output; +my ($warn_percth_data, $crit_percth_data, $total_percth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;(\d+)/); +is ($warn_percth_data, int($total_percth_data/100*20), "Wrong warning in perf data using percent thresholds"); +is ($crit_percth_data, int($total_percth_data/100*10), "Wrong critical in perf data using percent thresholds"); # Check when order of mount points are reversed, that perf data remains same