summaryrefslogtreecommitdiffstats
path: root/plugins/check_swap.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_swap.c')
-rw-r--r--plugins/check_swap.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index b8f82db..3bf7d43 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -55,6 +55,7 @@ main (int argc, char **argv)
55 long unsigned int dsktotal, dskused, dskfree; 55 long unsigned int dsktotal, dskused, dskfree;
56 int result = STATE_OK; 56 int result = STATE_OK;
57 char input_buffer[MAX_INPUT_BUFFER]; 57 char input_buffer[MAX_INPUT_BUFFER];
58 char *perf;
58#ifdef HAVE_PROC_MEMINFO 59#ifdef HAVE_PROC_MEMINFO
59 FILE *fp; 60 FILE *fp;
60#else 61#else
@@ -73,6 +74,7 @@ main (int argc, char **argv)
73 textdomain (PACKAGE); 74 textdomain (PACKAGE);
74 75
75 status = strdup(""); 76 status = strdup("");
77 perf = strdup("");
76 78
77 if (process_arguments (argc, argv) != OK) 79 if (process_arguments (argc, argv) != OK)
78 usage (_("Invalid command arguments supplied\n")); 80 usage (_("Invalid command arguments supplied\n"));
@@ -222,7 +224,12 @@ main (int argc, char **argv)
222 asprintf (&status, _(" %d%% free (%lu MB out of %lu MB)%s"), 224 asprintf (&status, _(" %d%% free (%lu MB out of %lu MB)%s"),
223 (100 - percent_used), free_swap, total_swap, status); 225 (100 - percent_used), free_swap, total_swap, status);
224 226
225 die (result, "SWAP %s:%s\n", state_text (result), status); 227 asprintf (&perf, "%s", perfdata ("swap", free_swap, "MB",
228 TRUE, max (warn_size/1024, warn_percent/100.0*total_swap),
229 TRUE, max (crit_size/1024, crit_percent/100.0*total_swap),
230 TRUE, 0,
231 TRUE, total_swap));
232 die (result, "SWAP %s:%s |%s\n", state_text (result), status, perf);
226 return STATE_UNKNOWN; 233 return STATE_UNKNOWN;
227} 234}
228 235
@@ -329,12 +336,12 @@ process_arguments (int argc, char **argv)
329 c = optind; 336 c = optind;
330 if (c == argc) 337 if (c == argc)
331 return validate_arguments (); 338 return validate_arguments ();
332 if (warn_percent > 100 && is_intnonneg (argv[c])) 339 if (warn_percent == 0 && is_intnonneg (argv[c]))
333 warn_percent = atoi (argv[c++]); 340 warn_percent = atoi (argv[c++]);
334 341
335 if (c == argc) 342 if (c == argc)
336 return validate_arguments (); 343 return validate_arguments ();
337 if (crit_percent > 100 && is_intnonneg (argv[c])) 344 if (crit_percent == 0 && is_intnonneg (argv[c]))
338 crit_percent = atoi (argv[c++]); 345 crit_percent = atoi (argv[c++]);
339 346
340 if (c == argc) 347 if (c == argc)
@@ -357,7 +364,7 @@ process_arguments (int argc, char **argv)
357int 364int
358validate_arguments (void) 365validate_arguments (void)
359{ 366{
360 if (warn_percent > 100 && crit_percent > 100 && warn_size == 0 367 if (warn_percent == 0 && crit_percent == 0 && warn_size == 0
361 && crit_size == 0) { 368 && crit_size == 0) {
362 return ERROR; 369 return ERROR;
363 } 370 }