X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fcheck_swap.c;h=bcc6b170c6d4e554682d8c2c5fa94032828c696b;hb=187f86275426bfb501c7180c48161e1e22af1ef7;hp=3016e1ad5c63fbd441a09527e47c1dd23a67779b;hpb=589d4664919638bedd6e2e1710c323887d19584a;p=nagiosplug.git diff --git a/plugins/check_swap.c b/plugins/check_swap.c index 3016e1a..bcc6b17 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c @@ -25,15 +25,15 @@ * *****************************************************************************/ -#include "common.h" -#include "popen.h" -#include "utils.h" - const char *progname = "check_swap"; const char *revision = "$Revision$"; -const char *copyright = "2000-2003"; +const char *copyright = "2000-2004"; const char *email = "nagiosplug-devel@lists.sourceforge.net"; +#include "common.h" +#include "popen.h" +#include "utils.h" + int check_swap (int usp, long unsigned int free_swap); int process_arguments (int argc, char **argv); int validate_arguments (void); @@ -53,13 +53,13 @@ main (int argc, char **argv) int percent_used, percent; unsigned long long total_swap = 0, used_swap = 0, free_swap = 0; unsigned long long dsktotal = 0, dskused = 0, dskfree = 0, tmp = 0; - int result = STATE_OK; + int result = STATE_UNKNOWN; char input_buffer[MAX_INPUT_BUFFER]; char *perf; - int conv_factor = SWAP_CONVERSION; #ifdef HAVE_PROC_MEMINFO FILE *fp; #else + int conv_factor = SWAP_CONVERSION; # ifdef HAVE_SWAP char *temp_buffer; char *swap_command; @@ -89,8 +89,8 @@ main (int argc, char **argv) tmp_status = strdup (""); perf = strdup (""); - if (process_arguments (argc, argv) != OK) - usage (_("Incorrect arguments supplied\n")); + if (process_arguments (argc, argv) == ERROR) + usage4 (_("Could not parse arguments")); #ifdef HAVE_PROC_MEMINFO fp = fopen (PROC_MEMINFO, "r"); @@ -194,7 +194,7 @@ main (int argc, char **argv) dskfree = dskfree / conv_factor; # endif if (verbose >= 3) - printf (_("total=%d, free=%d\n"), dsktotal, dskfree); + printf (_("total=%llu, free=%llu\n"), dsktotal, dskfree); dskused = dsktotal - dskfree; total_swap += dsktotal; @@ -239,7 +239,7 @@ main (int argc, char **argv) /* and now, tally 'em up */ swapctl_res=swapctl(SC_LIST, tbl); if(swapctl_res < 0){ - perror("swapctl failed: "); + perror(_("swapctl failed: ")); result = STATE_WARNING; } @@ -278,7 +278,7 @@ main (int argc, char **argv) /* and now, tally 'em up */ swapctl_res=swapctl(SWAP_STATS, ent, nswaps); if(swapctl_res < 0){ - perror("swapctl failed: "); + perror(_("swapctl failed: ")); result = STATE_WARNING; } @@ -326,7 +326,6 @@ main (int argc, char **argv) - int check_swap (int usp, long unsigned int free_swap) { @@ -346,6 +345,7 @@ check_swap (int usp, long unsigned int free_swap) } + /* process command-line arguments */ int process_arguments (int argc, char **argv) @@ -388,7 +388,7 @@ process_arguments (int argc, char **argv) break; } else { - usage (_("Warning threshold must be integer or percentage!\n")); + usage4 (_("Warning threshold must be integer or percentage!")); } case 'c': /* critical size threshold */ if (is_intnonneg (optarg)) { @@ -405,7 +405,7 @@ process_arguments (int argc, char **argv) break; } else { - usage (_("Critical threshold must be integer or percentage!\n")); + usage4 (_("Critical threshold must be integer or percentage!")); } case 'a': /* all swap */ allswaps = TRUE; @@ -420,7 +420,7 @@ process_arguments (int argc, char **argv) print_help (); exit (STATE_OK); case '?': /* error */ - usage (_("Invalid argument\n")); + usage2 (_("Unknown argument"), optarg); } } @@ -450,8 +450,6 @@ process_arguments (int argc, char **argv) - - int validate_arguments (void) { @@ -460,21 +458,18 @@ validate_arguments (void) return ERROR; } else if (warn_percent < crit_percent) { - usage - (_("Warning percentage should be more than critical percentage\n")); + usage4 + (_("Warning percentage should be more than critical percentage")); } else if (warn_size < crit_size) { - usage - (_("Warning free space should be more than critical free space\n")); + usage4 + (_("Warning free space should be more than critical free space")); } return OK; } - - - void print_help (void) { @@ -482,7 +477,7 @@ print_help (void) printf (_(COPYRIGHT), copyright, email); - printf (_("Check swap space on local server.\n\n")); + printf (_("Check swap space on local machine.\n\n")); print_usage (); @@ -514,14 +509,10 @@ On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s.\n")); - void print_usage (void) { - printf (_("Usage:\n\ - %s [-av] -w %% -c %%\n\ - %s [-av] -w -c \n\ - %s (-h | --help) for detailed help\n\ - %s (-V | --version) for version information\n"), - progname, progname, progname, progname); + printf ("\ +Usage: %s [-av] -w %% -c %%\n\ + %s [-av] -w -c \n", progname, progname); }