diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2021-10-26 14:53:01 (GMT) |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2021-10-26 15:07:09 (GMT) |
commit | 6e0586c8e35c3990631f73d8cdb89b70751994c3 (patch) | |
tree | 723bf4f3a5175c00eaaef5f5b84c1492bdfe06d2 /plugins | |
parent | 1c0882def0d9ce4ed5b2d443884138622e6d839b (diff) | |
download | monitoring-plugins-6e0586c8e35c3990631f73d8cdb89b70751994c3.tar.gz |
Reform some arithmetical operations for more clarity
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_disk.c | 16 |
1 files 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) | |||
334 | 334 | ||
335 | /* *_high_tide must be reinitialized at each run */ | 335 | /* *_high_tide must be reinitialized at each run */ |
336 | uint64_t warning_high_tide = UINT64_MAX; | 336 | uint64_t warning_high_tide = UINT64_MAX; |
337 | uint64_t critical_high_tide = UINT64_MAX; | ||
338 | 337 | ||
339 | if (path->freespace_units->warning != NULL) { | 338 | if (path->freespace_units->warning != NULL) { |
340 | warning_high_tide = path->dtotal_units - path->freespace_units->warning->end; | 339 | warning_high_tide = (path->dtotal_units - path->freespace_units->warning->end) * mult; |
341 | } | 340 | } |
342 | if (path->freespace_percent->warning != NULL) { | 341 | if (path->freespace_percent->warning != NULL) { |
343 | warning_high_tide = llabs( min( (double) warning_high_tide, (double) (1.0 - path->freespace_percent->warning->end/100)* path->dtotal_units )); | 342 | warning_high_tide = min( warning_high_tide, (uint64_t)((1.0 - path->freespace_percent->warning->end/100) * (path->dtotal_units * mult)) ); |
344 | } | 343 | } |
344 | |||
345 | uint64_t critical_high_tide = UINT64_MAX; | ||
346 | |||
345 | if (path->freespace_units->critical != NULL) { | 347 | if (path->freespace_units->critical != NULL) { |
346 | critical_high_tide = path->dtotal_units - path->freespace_units->critical->end; | 348 | critical_high_tide = (path->dtotal_units - path->freespace_units->critical->end) * mult; |
347 | } | 349 | } |
348 | if (path->freespace_percent->critical != NULL) { | 350 | if (path->freespace_percent->critical != NULL) { |
349 | critical_high_tide = llabs( min( (double) critical_high_tide, (double) (1.0 - path->freespace_percent->critical->end/100)*path->dtotal_units )); | 351 | critical_high_tide = min( critical_high_tide, (uint64_t)((1.0 - path->freespace_percent->critical->end/100) * (path->dtotal_units * mult)) ); |
350 | } | 352 | } |
351 | 353 | ||
352 | /* Nb: *_high_tide are unset when == UINT64_MAX */ | 354 | /* Nb: *_high_tide are unset when == UINT64_MAX */ |
@@ -354,8 +356,8 @@ main (int argc, char **argv) | |||
354 | perfdata_uint64 ( | 356 | perfdata_uint64 ( |
355 | (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, | 357 | (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, |
356 | path->dused_units * mult, "B", | 358 | path->dused_units * mult, "B", |
357 | (warning_high_tide == UINT64_MAX ? FALSE : TRUE), warning_high_tide * mult, | 359 | (warning_high_tide == UINT64_MAX ? FALSE : TRUE), warning_high_tide, |
358 | (critical_high_tide == UINT64_MAX ? FALSE : TRUE), critical_high_tide * mult, | 360 | (critical_high_tide == UINT64_MAX ? FALSE : TRUE), critical_high_tide, |
359 | TRUE, 0, | 361 | TRUE, 0, |
360 | TRUE, path->dtotal_units * mult)); | 362 | TRUE, path->dtotal_units * mult)); |
361 | 363 | ||