aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sven Nierlein <sven@nierlein.org> 2019-03-28 16:55:22 +0100
committerGravatar GitHub <noreply@github.com> 2019-03-28 16:55:22 +0100
commit5f16ba81c4af1a05e67806ca989a1dd46248a5fd (patch)
treee53b5e4b7ea286679c209b2f4b86c0a9becb2242
parent71582d8bf98a115281ae6d4af5056b99c4ae46a2 (diff)
parent6995b510759cf531d70745b7d0c6e8a0d9010b06 (diff)
downloadmonitoring-plugins-5f16ba81c4af1a05e67806ca989a1dd46248a5fd.tar.gz
Merge pull request #1491 from odenbach/no_swap
check_swap: repaired "-n" behaviour
-rw-r--r--plugins/check_swap.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 4d5a4071..0ff0c770 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -51,7 +51,7 @@ const char *email = "devel@monitoring-plugins.org";
# define SWAP_CONVERSION 1
#endif
-int check_swap (int usp, float free_swap_mb);
+int check_swap (int usp, float free_swap_mb, float total_swap_mb);
int process_arguments (int argc, char **argv);
int validate_arguments (void);
void print_usage (void);
@@ -128,7 +128,7 @@ main (int argc, char **argv)
percent=100.0;
else
percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
- result = max_state (result, check_swap (percent, dskfree_mb));
+ result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb));
if (verbose)
xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
}
@@ -227,7 +227,7 @@ main (int argc, char **argv)
free_swap_mb += dskfree_mb;
if (allswaps) {
percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
- result = max_state (result, check_swap (percent, dskfree_mb));
+ result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb));
if (verbose)
xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
}
@@ -289,7 +289,7 @@ main (int argc, char **argv)
if(allswaps && dsktotal_mb > 0){
percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
- result = max_state (result, check_swap (percent, dskfree_mb));
+ result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb));
if (verbose) {
xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
}
@@ -328,7 +328,7 @@ main (int argc, char **argv)
if(allswaps && dsktotal_mb > 0){
percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
- result = max_state (result, check_swap (percent, dskfree_mb));
+ result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb));
if (verbose) {
xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
}
@@ -355,7 +355,7 @@ main (int argc, char **argv)
status = "- Swap is either disabled, not present, or of zero size. ";
}
- result = max_state (result, check_swap (percent_used, free_swap_mb));
+ result = max_state (result, check_swap (percent_used, free_swap_mb, total_swap_mb));
printf (_("SWAP %s - %d%% free (%d MB out of %d MB) %s|"),
state_text (result),
(100 - percent_used), (int) free_swap_mb, (int) total_swap_mb, status);
@@ -372,10 +372,10 @@ main (int argc, char **argv)
int
-check_swap (int usp, float free_swap_mb)
+check_swap (int usp, float free_swap_mb, float total_swap_mb)
{
- if (!free_swap_mb) return no_swap_state;
+ if (!total_swap_mb) return no_swap_state;
int result = STATE_UNKNOWN;
float free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */