[monitoring-plugins] check_disk: Use regex also to include fs types

Lorenz Kästle git at monitoring-plugins.org
Thu Oct 5 11:00:13 CEST 2023


 Module: monitoring-plugins
 Branch: master
 Commit: 6947a8cea9335c2eeefb8929aa663db49ecac5a1
 Author: Lorenz Kästle <12514511+RincewindsHat at users.noreply.github.com>
   Date: Sat Sep 30 12:54:21 2023 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=6947a8c

check_disk: Use regex also to include fs types

---

 plugins/check_disk.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index e7e9378..06576d8 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -97,7 +97,7 @@ static struct regex_list *fs_exclude_list = NULL;
 
 /* Linked list of filesystem types to check.
    If the list is empty, include all types.  */
-static struct name_list *fs_include_list;
+static struct regex_list *fs_include_list;
 
 static struct name_list *dp_exclude_list;
 
@@ -308,7 +308,7 @@ main (int argc, char **argv)
                 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)) {
+      } else if (fs_include_list && !np_find_regmatch(fs_include_list, me->me_type)) {
         continue;
       }
     }
@@ -723,7 +723,11 @@ process_arguments (int argc, char **argv)
       }
       break;
     case 'N':                 /* include file system type */
-      np_add_name(&fs_include_list, optarg);
+      err = np_add_regex(&fs_include_list, optarg, REG_EXTENDED);
+      if (err != 0) {
+        regerror (err, &fs_exclude_list->regex, errbuf, MAX_INPUT_BUFFER);
+        die (STATE_UNKNOWN, "DISK %s: %s - %s\n",_("UNKNOWN"), _("Could not compile regular expression"), errbuf);
+      }
       break;
     case 'v':                 /* verbose */
       verbose++;



More information about the Commits mailing list