Просмотр исходного кода

Revert 1643463 (reversed disk thresholds) keeping the thresholds checks.

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1594 f882894a-f735-0410-b71e-b25c423dba1c
Thomas Guyot-Sionnest 19 лет назад
Родитель
Сommit
a69aa93a2c
2 измененных файлов с 9 добавлено и 9 удалено
  1. 4 4
      plugins/check_disk.c
  2. 5 5
      plugins/t/check_disk.t

+ 4 - 4
plugins/check_disk.c

@@ -306,16 +306,16 @@ main (int argc, char **argv)
       critical_high_tide = UINT_MAX;
       critical_high_tide = UINT_MAX;
 
 
       if (path->freespace_units->warning != NULL) {
       if (path->freespace_units->warning != NULL) {
-        warning_high_tide = path->freespace_units->warning->end;
+        warning_high_tide = dtotal_units - path->freespace_units->warning->end;
       }
       }
       if (path->freespace_percent->warning != NULL) {
       if (path->freespace_percent->warning != NULL) {
-        warning_high_tide = abs( min( (double) warning_high_tide, (double) path->freespace_percent->warning->end/100*dtotal_units ));
+        warning_high_tide = abs( min( (double) warning_high_tide, (double) (1.0 - path->freespace_percent->warning->end/100)*dtotal_units ));
       }
       }
       if (path->freespace_units->critical != NULL) {
       if (path->freespace_units->critical != NULL) {
-        critical_high_tide = path->freespace_units->critical->end;
+        critical_high_tide = dtotal_units - path->freespace_units->critical->end;
       }
       }
       if (path->freespace_percent->critical != NULL) {
       if (path->freespace_percent->critical != NULL) {
-        critical_high_tide = abs( min( (double) critical_high_tide, (double) path->freespace_percent->critical->end/100*dtotal_units ));
+        critical_high_tide = abs( min( (double) critical_high_tide, (double) (1.0 - path->freespace_percent->critical->end/100)*dtotal_units ));
       }
       }
 
 
       asprintf (&perf, "%s %s", perf,
       asprintf (&perf, "%s %s", perf,

+ 5 - 5
plugins/t/check_disk.t

@@ -82,9 +82,9 @@ $result = NPTest->testCmd(
         "./check_disk -w 20 -c 10 -p $mountpoint_valid"
         "./check_disk -w 20 -c 10 -p $mountpoint_valid"
         );
         );
 $_ = $result->perf_output;
 $_ = $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");
+my ($warn_absth_data, $crit_absth_data, $total_absth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;(\d+)/);
+is ($warn_absth_data, $total_absth_data - 20, "Wrong warning in perf data using absolute thresholds");
+is ($crit_absth_data, $total_absth_data - 10, "Wrong critical in perf data using absolute thresholds");
 
 
 # Then check percent thresholds.
 # Then check percent thresholds.
 $result = NPTest->testCmd(
 $result = NPTest->testCmd(
@@ -92,8 +92,8 @@ $result = NPTest->testCmd(
         );
         );
 $_ = $result->perf_output;
 $_ = $result->perf_output;
 my ($warn_percth_data, $crit_percth_data, $total_percth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;(\d+)/);
 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");
+is ($warn_percth_data, int((1-20/100)*$total_percth_data), "Wrong warning in perf data using percent thresholds");
+is ($crit_percth_data, int((1-10/100)*$total_percth_data), "Wrong critical in perf data using percent thresholds");
 
 
 
 
 # Check when order of mount points are reversed, that perf data remains same
 # Check when order of mount points are reversed, that perf data remains same