[nagiosplug] Fixed SF.net bug 3560976, added --include-type/-N ...

Nagios Plugin Development nagios-plugins at users.sourceforge.net
Tue Mar 26 00:00:14 CET 2013


    Module: nagiosplug
    Branch: master
    Commit: 10a4de3c4cc8465ca08e0cc7b1898cc791761477
    Author: Richard Leitner <me at g0hl1n.net>
 Committer: Holger Weiss <holger at zedat.fu-berlin.de>
      Date: Fri Mar 22 16:15:49 2013 +0100
       URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=10a4de3

Fixed SF.net bug 3560976, added --include-type/-N option

---

 plugins/check_disk.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 6ba7bdf..4ea0393 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -91,9 +91,12 @@ static int stat_remote_fs = 0;
 
 /* Linked list of filesystem types to omit.
    If the list is empty, don't exclude any types.  */
-
 static struct name_list *fs_exclude_list;
 
+/* Linked list of filesystem types to check.
+   If the list is empty, include all types.  */
+static struct name_list *fs_include_list;
+
 static struct name_list *dp_exclude_list;
 
 static struct parameter_list *path_select_list = NULL;
@@ -255,6 +258,9 @@ main (int argc, char **argv)
                (np_find_name (dp_exclude_list, me->me_devname) ||
                 np_find_name (dp_exclude_list, me->me_mountdir))) {
         continue;
+      /* Skip not included fstypes */
+      } else if (fs_include_list && !np_find_name (fs_include_list, me->me_type)) {
+        continue;
       }
 
       stat_path(path);
@@ -419,6 +425,7 @@ process_arguments (int argc, char **argv)
     {"partition", required_argument, 0, 'p'},
     {"exclude_device", required_argument, 0, 'x'},
     {"exclude-type", required_argument, 0, 'X'},
+    {"include-type", required_argument, 0, 'N'},
     {"group", required_argument, 0, 'g'},
     {"eregi-path", required_argument, 0, 'R'},
     {"eregi-partition", required_argument, 0, 'R'},
@@ -452,7 +459,7 @@ process_arguments (int argc, char **argv)
       strcpy (argv[c], "-t");
 
   while (1) {
-    c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:mklLg:R:r:i:I:MEA", longopts, &option);
+    c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:N:mklLg:R:r:i:I:MEA", longopts, &option);
 
     if (c == -1 || c == EOF)
       break;
@@ -591,6 +598,9 @@ process_arguments (int argc, char **argv)
     case 'X':                 /* exclude file system type */
       np_add_name(&fs_exclude_list, optarg);
       break;
+    case 'N':                 /* include file system type */
+      np_add_name(&fs_include_list, optarg);
+      break;
     case 'v':                 /* verbose */
       verbose++;
       break;
@@ -900,6 +910,8 @@ print_help (void)
   printf (UT_VERBOSE);
   printf (" %s\n", "-X, --exclude-type=TYPE");
   printf ("    %s\n", _("Ignore all filesystems of indicated type (may be repeated)"));
+  printf (" %s\n", "-N, --include-type=TYPE");
+  printf ("    %s\n", _("Check only filesystems of indicated type (may be repeated)"));
 
   printf ("\n");
   printf ("%s\n", _("Examples:"));
@@ -922,7 +934,7 @@ print_usage (void)
   printf ("%s\n", _("Usage:"));
   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");
+  printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n");
 }
 
 void





More information about the Commits mailing list