diff options
-rw-r--r-- | plugins/check_disk.c | 8 | ||||
-rw-r--r-- | plugins/t/check_disk.t | 10 |
2 files changed, 9 insertions, 9 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 476c892..99a7201 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
@@ -306,16 +306,16 @@ main (int argc, char **argv) | |||
306 | critical_high_tide = UINT_MAX; | 306 | critical_high_tide = UINT_MAX; |
307 | 307 | ||
308 | if (path->freespace_units->warning != NULL) { | 308 | if (path->freespace_units->warning != NULL) { |
309 | warning_high_tide = path->freespace_units->warning->end; | 309 | warning_high_tide = dtotal_units - path->freespace_units->warning->end; |
310 | } | 310 | } |
311 | if (path->freespace_percent->warning != NULL) { | 311 | if (path->freespace_percent->warning != NULL) { |
312 | warning_high_tide = abs( min( (double) warning_high_tide, (double) path->freespace_percent->warning->end/100*dtotal_units )); | 312 | warning_high_tide = abs( min( (double) warning_high_tide, (double) (1.0 - path->freespace_percent->warning->end/100)*dtotal_units )); |
313 | } | 313 | } |
314 | if (path->freespace_units->critical != NULL) { | 314 | if (path->freespace_units->critical != NULL) { |
315 | critical_high_tide = path->freespace_units->critical->end; | 315 | critical_high_tide = dtotal_units - path->freespace_units->critical->end; |
316 | } | 316 | } |
317 | if (path->freespace_percent->critical != NULL) { | 317 | if (path->freespace_percent->critical != NULL) { |
318 | critical_high_tide = abs( min( (double) critical_high_tide, (double) path->freespace_percent->critical->end/100*dtotal_units )); | 318 | critical_high_tide = abs( min( (double) critical_high_tide, (double) (1.0 - path->freespace_percent->critical->end/100)*dtotal_units )); |
319 | } | 319 | } |
320 | 320 | ||
321 | asprintf (&perf, "%s %s", perf, | 321 | asprintf (&perf, "%s %s", perf, |
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t index 7235d70..dd13ce5 100644 --- a/plugins/t/check_disk.t +++ b/plugins/t/check_disk.t | |||
@@ -82,9 +82,9 @@ $result = NPTest->testCmd( | |||
82 | "./check_disk -w 20 -c 10 -p $mountpoint_valid" | 82 | "./check_disk -w 20 -c 10 -p $mountpoint_valid" |
83 | ); | 83 | ); |
84 | $_ = $result->perf_output; | 84 | $_ = $result->perf_output; |
85 | my ($warn_absth_data, $crit_absth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;\d+/); | 85 | my ($warn_absth_data, $crit_absth_data, $total_absth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;(\d+)/); |
86 | is ($warn_absth_data, 20, "Wrong warning in perf data using absolute thresholds"); | 86 | is ($warn_absth_data, $total_absth_data - 20, "Wrong warning in perf data using absolute thresholds"); |
87 | is ($crit_absth_data, 10, "Wrong critical in perf data using absolute thresholds"); | 87 | is ($crit_absth_data, $total_absth_data - 10, "Wrong critical in perf data using absolute thresholds"); |
88 | 88 | ||
89 | # Then check percent thresholds. | 89 | # Then check percent thresholds. |
90 | $result = NPTest->testCmd( | 90 | $result = NPTest->testCmd( |
@@ -92,8 +92,8 @@ $result = NPTest->testCmd( | |||
92 | ); | 92 | ); |
93 | $_ = $result->perf_output; | 93 | $_ = $result->perf_output; |
94 | my ($warn_percth_data, $crit_percth_data, $total_percth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;(\d+)/); | 94 | my ($warn_percth_data, $crit_percth_data, $total_percth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;(\d+)/); |
95 | is ($warn_percth_data, int($total_percth_data/100*20), "Wrong warning in perf data using percent thresholds"); | 95 | is ($warn_percth_data, int((1-20/100)*$total_percth_data), "Wrong warning in perf data using percent thresholds"); |
96 | is ($crit_percth_data, int($total_percth_data/100*10), "Wrong critical in perf data using percent thresholds"); | 96 | is ($crit_percth_data, int((1-10/100)*$total_percth_data), "Wrong critical in perf data using percent thresholds"); |
97 | 97 | ||
98 | 98 | ||
99 | # Check when order of mount points are reversed, that perf data remains same | 99 | # Check when order of mount points are reversed, that perf data remains same |