Code

Bug Fix [ 1024735 ] check_swap providing inaccurate swap information on Sol6
[nagiosplug.git] / plugins / check_swap.c
index 608080acb6f0ab856977c47b739f3c867be08dc3..ba353bc0b89a44580860c6c94815806f61ecf2fa 100644 (file)
  *
  *****************************************************************************/
 
-#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,7 +53,7 @@ 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;
@@ -89,7 +89,7 @@ main (int argc, char **argv)
        tmp_status = strdup ("");
        perf = strdup ("");
 
-       if (process_arguments (argc, argv) != TRUE)
+       if (process_arguments (argc, argv) == ERROR)
                usage4 (_("Could not parse arguments"));
 
 #ifdef HAVE_PROC_MEMINFO
@@ -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;
@@ -479,7 +479,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,10 +514,7 @@ On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s.\n"));
 void
 print_usage (void)
 {
-       printf (_("Usage:\n\
- %s [-av] -w <percent_free>%% -c <percent_free>%%\n\
- %s [-av] -w <bytes_free> -c <bytes_free>\n\
- %s (-h | --help) for detailed help\n\
- %s (-V | --version) for version information\n"),
-               progname, progname, progname, progname);
+       printf ("\
+       Usage: %s [-av] -w <percent_free>%% -c <percent_free>%%\n\
+         %s [-av] -w <bytes_free> -c <bytes_free>\n", progname, progname);
 }