aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> 2021-10-26 16:53:01 +0200
committerGravatar RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> 2021-10-26 17:07:09 +0200
commit6e0586c8e35c3990631f73d8cdb89b70751994c3 (patch)
tree723bf4f3a5175c00eaaef5f5b84c1492bdfe06d2
parent1c0882def0d9ce4ed5b2d443884138622e6d839b (diff)
downloadmonitoring-plugins-6e0586c8e35c3990631f73d8cdb89b70751994c3.tar.gz
Reform some arithmetical operations for more clarity
-rw-r--r--plugins/check_disk.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 1778b613..71eab531 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));