From 6e0586c8e35c3990631f73d8cdb89b70751994c3 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Tue, 26 Oct 2021 16:53:01 +0200 Subject: Reform some arithmetical operations for more clarity 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)); -- cgit v0.10-9-g596f