SF.net SVN: nagiosplug: [1782] nagiosplug/trunk/plugins/check_disk.c

[email protected]
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
Revision: 1782
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=1782&view=rev
Author:   dermoth
Date:     2007-09-20 21:59:15 -0700 (Thu, 20 Sep 2007)

Log Message:
-----------
- Added some variables at verbose==3
- Removed support for verbose<0 (-q). -q was broken and tried to to the same as -e.
- -q in now an undocumented alias of -e (for backward-compatibility).
NB: Long help text for -d was already missing.
- Reordered the switches so that:
?\194?\160   a. less-important ones are in alphabetical order
    b. short and long help orders match.
- Enclosed "-p | -x" inside braces instead of brackets as one or the other is required.

Modified Paths:
--------------
    nagiosplug/trunk/plugins/check_disk.c

Modified: nagiosplug/trunk/plugins/check_disk.c
===================================================================
--- nagiosplug/trunk/plugins/check_disk.c	2007-09-17 08:19:48 UTC (rev 1781)
+++ nagiosplug/trunk/plugins/check_disk.c	2007-09-21 04:59:15 UTC (rev 1782)
@@ -319,8 +319,8 @@
       dfree_inodes_percent = 100 - dused_inodes_percent;
 
       if (verbose >= 3) {
-        printf ("For %s, used_pct=%g free_pct=%g used_units=%g free_units=%g total_units=%g used_inodes_pct=%g free_inodes_pct=%g\n", 
-          me->me_mountdir, dused_pct, dfree_pct, dused_units, dfree_units, dtotal_units, dused_inodes_percent, dfree_inodes_percent);
+        printf ("For %s, used_pct=%g free_pct=%g used_units=%g free_units=%g total_units=%g used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%lu mult=%lu\n", 
+          me->me_mountdir, dused_pct, dfree_pct, dused_units, dfree_units, dtotal_units, dused_inodes_percent, dfree_inodes_percent, fsp.fsu_blocksize, mult);
       }
 
       /* Threshold comparisons */
@@ -373,6 +373,7 @@
         critical_high_tide = abs( min( (double) critical_high_tide, (double) (1.0 - path->freespace_percent->critical->end/100)*dtotal_units ));
       }
 
+      /* Nb: *_high_tide are unset when == UINT_MAX */
       asprintf (&perf, "%s %s", perf,
                 perfdata ((!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
                           dused_units, units,
@@ -384,18 +385,16 @@
       if (disk_result==STATE_OK && erronly && !verbose)
         continue;
 
-      if (disk_result!=STATE_OK || verbose>=0) {
-        asprintf (&output, "%s %s %.0f %s (%.0f%%",
-                  output,
-                  (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
-                  dfree_units,
-                  units,
-                  dfree_pct);
-        if (dused_inodes_percent < 0) {
-          asprintf(&output, "%s inode=-);", output);
-        } else {
-          asprintf(&output, "%s inode=%.0f%%);", output, dfree_inodes_percent );
-        }
+      asprintf (&output, "%s %s %.0f %s (%.0f%%",
+                output,
+                (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
+                dfree_units,
+                units,
+                dfree_pct);
+      if (dused_inodes_percent < 0) {
+        asprintf(&output, "%s inode=-);", output);
+      } else {
+        asprintf(&output, "%s inode=%.0f%%);", output, dfree_inodes_percent );
       }
 
       /* TODO: Need to do a similar debug line
@@ -637,8 +636,9 @@
     case 'v':                 /* verbose */
       verbose++;
       break;
-    case 'q':                 /* verbose */
-      verbose--;
+    case 'q':                 /* TODO: this function should eventually go away (removed 2007-09-20) */
+      /* verbose--; **replaced by line below**. -q was only a broken way of implementing -e */
+      erronly = TRUE;
       break;
     case 'e':
       erronly = TRUE;
@@ -843,44 +843,44 @@
   printf ("    %s\n", _("Exit with WARNING status if less than INTEGER units of disk are free"));
   printf (" %s\n", "-w, --warning=PERCENT%");
   printf ("    %s\n", _("Exit with WARNING status if less than PERCENT of disk space is free"));
+  printf (" %s\n", "-c, --critical=INTEGER");
+  printf ("    %s\n", _("Exit with CRITICAL status if less than INTEGER units of disk are free"));
+  printf (" %s\n", "-c, --critical=PERCENT%");
+  printf ("    %s\n", _("Exit with CRITCAL status if less than PERCENT of disk space is free"));
   printf (" %s\n", "-W, --iwarning=PERCENT%");
   printf ("    %s\n", _("Exit with WARNING status if less than PERCENT of inode space is free"));
   printf (" %s\n", "-K, --icritical=PERCENT%");
   printf ("    %s\n", _("Exit with CRITICAL status if less than PERCENT of inode space is free"));
-  printf (" %s\n", "-c, --critical=INTEGER");
-  printf ("    %s\n", _("Exit with CRITICAL status if less than INTEGER units of disk are free"));
-  printf (" %s\n", "-c, --critical=PERCENT%");
-  printf ("    %s\n", _("Exit with CRITCAL status if less than PERCENT of disk space is free"));
+  printf (" %s\n", "-p, --path=PATH, --partition=PARTITION");
+  printf ("    %s\n", _("Path or partition (may be repeated)"));
+  printf (" %s\n", "-x, --exclude_device=PATH <STRING>");
+  printf ("    %s\n", _("Ignore device (only works if -p unspecified)"));
   printf (" %s\n", "-C, --clear");
   printf ("    %s\n", _("Clear thresholds"));
-  printf (" %s\n", "-u, --units=STRING");
-  printf ("    %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)"));
+  printf (" %s\n", "-E, --exact-match");
+  printf ("    %s\n", _("For paths or partitions specified with -p, only check for exact paths"));
+  printf (" %s\n", "-e, --errors-only");
+  printf ("    %s\n", _("Display only devices/mountpoints with errors"));
+  printf (" %s\n", "-g, --group=NAME");
+  printf ("    %s\n", _("Group pathes. Thresholds apply to (free-)space of all partitions together"));
   printf (" %s\n", "-k, --kilobytes");
   printf ("    %s\n", _("Same as '--units kB'"));
+  printf (" %s\n", "-l, --local");
+  printf ("    %s\n", _("Only check local filesystems"));
+  printf (" %s\n", "-M, --mountpoint");
+  printf ("    %s\n", _("Display the mountpoint instead of the partition"));
   printf (" %s\n", "-m, --megabytes");
   printf ("    %s\n", _("Same as '--units MB'"));
-  printf (" %s\n", "-l, --local");
-  printf ("    %s\n", _("Only check local filesystems"));
-  printf (" %s\n", "-p, --path=PATH, --partition=PARTITION");
-  printf ("    %s\n", _("Path or partition (may be repeated)"));
+  printf (" %s\n", "-R, --eregi-path=PATH, --eregi-partition=PARTITION");
+  printf ("    %s\n", _("Case insensitive regular expression for path/partition (may be repeated)"));
   printf (" %s\n", "-r, --ereg-path=PATH, --ereg-partition=PARTITION");
   printf ("    %s\n", _("Regular expression for path or partition (may be repeated)"));
-  printf (" %s\n", "-R, --eregi-path=PATH, --eregi-partition=PARTITION");
-  printf ("    %s\n", _("Case insensitive regular expression for path/partition (may be repeated)"));
-  printf (" %s\n", "-g, --group=NAME");
-  printf ("    %s\n", _("Group pathes. Thresholds apply to (free-)space of all partitions together"));
-  printf (" %s\n", "-x, --exclude_device=PATH <STRING>");
-  printf ("    %s\n", _("Ignore device (only works if -p unspecified)"));
-  printf (" %s\n", "-X, --exclude-type=TYPE <STRING>");
-  printf ("    %s\n", _("Ignore all filesystems of indicated type (may be repeated)"));
-  printf (" %s\n", "-M, --mountpoint");
-  printf ("    %s\n", _("Display the mountpoint instead of the partition"));
-  printf (" %s\n", "-E, --exact-match");
-  printf ("    %s\n", _("For paths or partitions specified with -p, only check for exact paths"));
-  printf (" %s\n", "-e, --errors-only");
-  printf ("    %s\n", _("Display only devices/mountpoints with errors"));
   printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+  printf (" %s\n", "-u, --units=STRING");
+  printf ("    %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)"));
   printf (_(UT_VERBOSE));
+  printf (" %s\n", "-X, --exclude-type=TYPE");
+  printf ("    %s\n", _("Ignore all filesystems of indicated type (may be repeated)"));
   printf ("\n");
   printf ("%s\n", _("Examples:"));
   printf (" %s\n", "check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /");
@@ -899,6 +899,7 @@
 print_usage (void)
 {
   printf (_("Usage:"));
-  printf (" %s -w limit -c limit [-p path | -x device] [-t timeout]", progname);
-  printf ("[-m] [-e] [-W limit] [-K limit] [-v] [-q] [-E]\n");
+  printf (" %s -w limit -c limit [-W limit] [-K limit] {-p path | -x device}\n", progname);
+  printf ("[-C] [-E] [-e] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n");
+  printf ("[-t timeout] [-u unit] [-v] [-X type]\n");
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.