summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_swap.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 56c5f42..e7ee785 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -401,7 +401,7 @@ check_swap(float free_swap_mb, float total_swap_mb)
401 uint64_t free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */ 401 uint64_t free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */
402 uint64_t usage_percentage = ((total_swap_mb - free_swap_mb) / total_swap_mb) * 100; 402 uint64_t usage_percentage = ((total_swap_mb - free_swap_mb) / total_swap_mb) * 100;
403 403
404 if (warn.value && crit.value) { /* Thresholds defined */ 404 if (warn.value || crit.value) { /* Thresholds defined */
405 if (!crit.is_percentage && crit.value >= free_swap) return STATE_CRITICAL; 405 if (!crit.is_percentage && crit.value >= free_swap) return STATE_CRITICAL;
406 if (!warn.is_percentage && warn.value >= free_swap) return STATE_WARNING; 406 if (!warn.is_percentage && warn.value >= free_swap) return STATE_WARNING;
407 407
@@ -546,13 +546,7 @@ process_arguments (int argc, char **argv)
546int 546int
547validate_arguments (void) 547validate_arguments (void)
548{ 548{
549 if (warn.value && !crit.value) { 549 if ((warn.is_percentage == crit.is_percentage) && (warn.value < crit.value)) {
550 usage4(_("Must define both warning and critical thresholds"));
551 }
552 else if (crit.value && !warn.value) {
553 usage4(_("Must define both warning and critical thresholds"));
554 }
555 else if ((warn.is_percentage == crit.is_percentage) && (warn.value < crit.value)) {
556 /* This is NOT triggered if warn and crit are different units, e.g warn is percentage 550 /* This is NOT triggered if warn and crit are different units, e.g warn is percentage
557 * and crit is absolute. We cannot determine the condition at this point since we 551 * and crit is absolute. We cannot determine the condition at this point since we
558 * dont know the value of total swap yet 552 * dont know the value of total swap yet