diff options
author | Napsty <ck@claudiokuenzler.com> | 2024-04-12 08:47:55 (GMT) |
---|---|---|
committer | Sven Nierlein <sven@nierlein.org> | 2024-04-12 14:50:15 (GMT) |
commit | 9b4fab066492ca4065adfdf1080086fe6ffa53c2 (patch) | |
tree | c15f25dd110c776f35750a13f75b43b96e22fff6 /plugins/check_swap.c | |
parent | ee0f70486f722e70d56eea2f7f3251a2d435e12a (diff) | |
download | monitoring-plugins-9b4fab066492ca4065adfdf1080086fe6ffa53c2.tar.gz |
Allow single threshold
Diffstat (limited to 'plugins/check_swap.c')
-rw-r--r-- | plugins/check_swap.c | 10 |
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) | |||
546 | int | 546 | int |
547 | validate_arguments (void) | 547 | validate_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 |