From 3cf9823dfee9bdb7b6e37ebed8d535ed5ccb309b Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Tue, 11 Nov 2003 10:27:16 +0000 Subject: Added perfdata git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@761 f882894a-f735-0410-b71e-b25c423dba1c 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) long unsigned int dsktotal, dskused, dskfree; int result = STATE_OK; char input_buffer[MAX_INPUT_BUFFER]; + char *perf; #ifdef HAVE_PROC_MEMINFO FILE *fp; #else @@ -73,6 +74,7 @@ main (int argc, char **argv) textdomain (PACKAGE); status = strdup(""); + perf = strdup(""); if (process_arguments (argc, argv) != OK) usage (_("Invalid command arguments supplied\n")); @@ -222,7 +224,12 @@ main (int argc, char **argv) asprintf (&status, _(" %d%% free (%lu MB out of %lu MB)%s"), (100 - percent_used), free_swap, total_swap, status); - die (result, "SWAP %s:%s\n", state_text (result), status); + asprintf (&perf, "%s", perfdata ("swap", free_swap, "MB", + TRUE, max (warn_size/1024, warn_percent/100.0*total_swap), + TRUE, max (crit_size/1024, crit_percent/100.0*total_swap), + TRUE, 0, + TRUE, total_swap)); + die (result, "SWAP %s:%s |%s\n", state_text (result), status, perf); return STATE_UNKNOWN; } @@ -329,12 +336,12 @@ process_arguments (int argc, char **argv) c = optind; if (c == argc) return validate_arguments (); - if (warn_percent > 100 && is_intnonneg (argv[c])) + if (warn_percent == 0 && is_intnonneg (argv[c])) warn_percent = atoi (argv[c++]); if (c == argc) return validate_arguments (); - if (crit_percent > 100 && is_intnonneg (argv[c])) + if (crit_percent == 0 && is_intnonneg (argv[c])) crit_percent = atoi (argv[c++]); if (c == argc) @@ -357,7 +364,7 @@ process_arguments (int argc, char **argv) int validate_arguments (void) { - if (warn_percent > 100 && crit_percent > 100 && warn_size == 0 + if (warn_percent == 0 && crit_percent == 0 && warn_size == 0 && crit_size == 0) { return ERROR; } -- cgit v0.10-9-g596f