[monitoring-plugins] Reform some arithmetical operations for more ...

RincewindsHat git at monitoring-plugins.org
Thu Oct 28 16:20:12 CEST 2021


 Module: monitoring-plugins
 Branch: master
 Commit: 6e0586c8e35c3990631f73d8cdb89b70751994c3
 Author: RincewindsHat <12514511+RincewindsHat at users.noreply.github.com>
   Date: Tue Oct 26 16:53:01 2021 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=6e0586c

Reform some arithmetical operations for more clarity

---

 plugins/check_disk.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 1778b61..71eab53 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -334,19 +334,21 @@ main (int argc, char **argv)
 
       /* *_high_tide must be reinitialized at each run */
 	  uint64_t warning_high_tide = UINT64_MAX;
-	  uint64_t critical_high_tide = UINT64_MAX;
 
       if (path->freespace_units->warning != NULL) {
-        warning_high_tide = path->dtotal_units - path->freespace_units->warning->end;
+        warning_high_tide = (path->dtotal_units - path->freespace_units->warning->end) * mult;
       }
       if (path->freespace_percent->warning != NULL) {
-        warning_high_tide = llabs( min( (double) warning_high_tide,  (double) (1.0 -  path->freespace_percent->warning->end/100)* path->dtotal_units ));
+        warning_high_tide = min( warning_high_tide, (uint64_t)((1.0 - path->freespace_percent->warning->end/100) * (path->dtotal_units * mult)) );
       }
+
+	  uint64_t critical_high_tide = UINT64_MAX;
+
       if (path->freespace_units->critical != NULL) {
-        critical_high_tide = path->dtotal_units - path->freespace_units->critical->end;
+        critical_high_tide = (path->dtotal_units - path->freespace_units->critical->end) * mult;
       }
       if (path->freespace_percent->critical != NULL) {
-        critical_high_tide = llabs( min( (double) critical_high_tide, (double) (1.0 - path->freespace_percent->critical->end/100)*path->dtotal_units ));
+        critical_high_tide = min( critical_high_tide, (uint64_t)((1.0 - path->freespace_percent->critical->end/100) * (path->dtotal_units * mult)) );
       }
 
       /* Nb: *_high_tide are unset when == UINT64_MAX */
@@ -354,8 +356,8 @@ main (int argc, char **argv)
 			  perfdata_uint64 (
 				  (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
 				  path->dused_units * mult, "B",
-				  (warning_high_tide == UINT64_MAX ? FALSE : TRUE), warning_high_tide * mult,
-				  (critical_high_tide == UINT64_MAX ? FALSE : TRUE), critical_high_tide * mult,
+				  (warning_high_tide == UINT64_MAX ? FALSE : TRUE), warning_high_tide,
+				  (critical_high_tide == UINT64_MAX ? FALSE : TRUE), critical_high_tide,
 				  TRUE, 0,
 				  TRUE, path->dtotal_units * mult));
 



More information about the Commits mailing list