summaryrefslogtreecommitdiffstats
path: root/web/attachments/71990-check_swap.diff
blob: f4434769956298cb638d3a587bb3847662dc2900 (plain)
1
*** ../nagios-plugins-1.4.0alpha1/plugins/check_swap.c  Wed Nov 12 05:37:19 2003
--- plugins/check_swap.c        Thu Jan  1 19:28:34 2004
***************
*** 82,87 ****
--- 82,95 ----
  #ifdef HAVE_PROC_MEMINFO
          fp = fopen (PROC_MEMINFO, "r");
          while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
+                 unsigned long tmp;
+                 if(sscanf(input_buffer, "%s %lu", str, &tmp)==2) {
+                         if(!strncmp(str,"SwapTotal",strlen("SwapTotal")))
+                                 total_swap+=(tmp>>10);
+                         else if(!strncmp(str,"SwapFree",strlen("SwapFree")))
+                                 free_swap+=(tmp>>10);
+                 }
+                 /*
                  if (sscanf (input_buffer, " %s %lu %lu %lu", str, &dsktotal, &dskused, &dskfree) == 4 &&
                      strstr (str, "Swap")) {
                          dsktotal = dsktotal / 1048576;
***************
*** 97,104 ****
--- 105,114 ----
                                          asprintf (&status, "%s [%lu (%d%%)]", status, dskfree, 100 - percent);
                          }
                  }
+                 */
          }
          fclose(fp);
+         used_swap=total_swap-free_swap;
  #else
  # ifdef HAVE_SWAP
          asprintf(&swap_command, "%s", SWAP_COMMAND);
***************
*** 240,246 ****
  check_swap (int usp, long unsigned int free_swap)
  {
        int result = STATE_UNKNOWN;
-       free_swap = free_swap * 1024;           /* Convert back to bytes as warn and crit specified in bytes */
        if (usp >= 0 && crit_percent != 0 && usp >= (100.0 - crit_percent))
                result = STATE_CRITICAL;
        else if (crit_size > 0 && free_swap <= crit_size)
--- 251,256 ----
***************
*** 399,411 ****
  
        printf (_("\n\
   -w, --warning=INTEGER\n\
!    Exit with WARNING status if less than INTEGER bytes of swap space are free\n\
   -w, --warning=PERCENT%%\n\
!    Exit with WARNING status if less than PERCENT of swap space has been used\n\
   -c, --critical=INTEGER\n\
!    Exit with CRITICAL status if less than INTEGER bytes of swap space are free\n\
   -c, --critical=PERCENT%%\n\
!    Exit with CRITCAL status if less than PERCENT of swap space has been used\n\
   -a, --allswaps\n\
      Conduct comparisons for all swap partitions, one by one\n"));
  
--- 410,422 ----
  
          printf (_("\n\
   -w, --warning=INTEGER\n\
!    Exit with WARNING status if less than INTEGER mega bytes of swap space are free\n\
   -w, --warning=PERCENT%%\n\
!    Exit with WARNING status if less than PERCENT of swap space are free\n\
   -c, --critical=INTEGER\n\
!    Exit with CRITICAL status if less than INTEGER mega bytes of swap space are free\n\
   -c, --critical=PERCENT%%\n\
!    Exit with CRITCAL status if less than PERCENT of swap space are free\n\
   -a, --allswaps\n\
      Conduct comparisons for all swap partitions, one by one\n"));
  
***************
*** 426,433 ****
  print_usage (void)
  {
        printf (_("Usage:\n\
!  %s [-a] -w <used_percentage>%% -c <used_percentage>%%\n\
!  %s [-a] -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);
--- 437,444 ----
  print_usage (void)
  {
          printf (_("Usage:\n\
!  %s [-a] -w <free_percentage>%% -c <free_percentage>%%\n\
!  %s [-a] -w <mega_bytes_free> -c <mega_bytes_free>\n\
   %s (-h | --help) for detailed help\n\
   %s (-V | --version) for version information\n"),
                  progname, progname, progname, progname);