diff options
| author | Alexander A. Klimov <alexander.klimov@icinga.com> | 2023-09-12 14:55:00 +0200 |
|---|---|---|
| committer | Alexander A. Klimov <alexander.klimov@icinga.com> | 2023-09-28 13:20:24 +0200 |
| commit | 4bb444f3353fbb49086bd0e212b3cad8009761dd (patch) | |
| tree | a7b4b894f1a28e006caf52dc37a3b3336564a0cc /plugins | |
| parent | 1f694195b4a6beef30bbbbffa5835a993be97a9c (diff) | |
| download | monitoring-plugins-4bb444f3353fbb49086bd0e212b3cad8009761dd.tar.gz | |
check_disk: make -X a regex list
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/check_disk.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 7dc1c4b1..e7e9378f 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
| @@ -93,7 +93,7 @@ static int stat_remote_fs = 0; | |||
| 93 | 93 | ||
| 94 | /* Linked list of filesystem types to omit. | 94 | /* Linked list of filesystem types to omit. |
| 95 | If the list is empty, don't exclude any types. */ | 95 | If the list is empty, don't exclude any types. */ |
| 96 | static struct name_list *fs_exclude_list; | 96 | static struct regex_list *fs_exclude_list = NULL; |
| 97 | 97 | ||
| 98 | /* Linked list of filesystem types to check. | 98 | /* Linked list of filesystem types to check. |
| 99 | If the list is empty, include all types. */ | 99 | If the list is empty, include all types. */ |
| @@ -300,7 +300,7 @@ main (int argc, char **argv) | |||
| 300 | } else if (me->me_dummy && !show_all_fs) { | 300 | } else if (me->me_dummy && !show_all_fs) { |
| 301 | continue; | 301 | continue; |
| 302 | /* Skip excluded fstypes */ | 302 | /* Skip excluded fstypes */ |
| 303 | } else if (fs_exclude_list && np_find_name (fs_exclude_list, me->me_type)) { | 303 | } else if (fs_exclude_list && np_find_regmatch (fs_exclude_list, me->me_type)) { |
| 304 | continue; | 304 | continue; |
| 305 | /* Skip excluded fs's */ | 305 | /* Skip excluded fs's */ |
| 306 | } else if (dp_exclude_list && | 306 | } else if (dp_exclude_list && |
| @@ -543,7 +543,7 @@ process_arguments (int argc, char **argv) | |||
| 543 | if (argc < 2) | 543 | if (argc < 2) |
| 544 | return ERROR; | 544 | return ERROR; |
| 545 | 545 | ||
| 546 | np_add_name(&fs_exclude_list, "iso9660"); | 546 | np_add_regex(&fs_exclude_list, "iso9660", REG_EXTENDED); |
| 547 | 547 | ||
| 548 | for (c = 1; c < argc; c++) | 548 | for (c = 1; c < argc; c++) |
| 549 | if (strcmp ("-to", argv[c]) == 0) | 549 | if (strcmp ("-to", argv[c]) == 0) |
| @@ -716,7 +716,11 @@ process_arguments (int argc, char **argv) | |||
| 716 | np_add_name(&dp_exclude_list, optarg); | 716 | np_add_name(&dp_exclude_list, optarg); |
| 717 | break; | 717 | break; |
| 718 | case 'X': /* exclude file system type */ | 718 | case 'X': /* exclude file system type */ |
| 719 | np_add_name(&fs_exclude_list, optarg); | 719 | err = np_add_regex(&fs_exclude_list, optarg, REG_EXTENDED); |
| 720 | if (err != 0) { | ||
| 721 | regerror (err, &fs_exclude_list->regex, errbuf, MAX_INPUT_BUFFER); | ||
| 722 | die (STATE_UNKNOWN, "DISK %s: %s - %s\n",_("UNKNOWN"), _("Could not compile regular expression"), errbuf); | ||
| 723 | } | ||
| 720 | break; | 724 | break; |
| 721 | case 'N': /* include file system type */ | 725 | case 'N': /* include file system type */ |
| 722 | np_add_name(&fs_include_list, optarg); | 726 | np_add_name(&fs_include_list, optarg); |
| @@ -1003,8 +1007,8 @@ print_help (void) | |||
| 1003 | printf (" %s\n", "-u, --units=STRING"); | 1007 | printf (" %s\n", "-u, --units=STRING"); |
| 1004 | printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)")); | 1008 | printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)")); |
| 1005 | printf (UT_VERBOSE); | 1009 | printf (UT_VERBOSE); |
| 1006 | printf (" %s\n", "-X, --exclude-type=TYPE"); | 1010 | printf (" %s\n", "-X, --exclude-type=TYPE_REGEX"); |
| 1007 | printf (" %s\n", _("Ignore all filesystems of indicated type (may be repeated)")); | 1011 | printf (" %s\n", _("Ignore all filesystems of types matching given regex(7) (may be repeated)")); |
| 1008 | printf (" %s\n", "-N, --include-type=TYPE"); | 1012 | printf (" %s\n", "-N, --include-type=TYPE"); |
| 1009 | printf (" %s\n", _("Check only filesystems of indicated type (may be repeated)")); | 1013 | printf (" %s\n", _("Check only filesystems of indicated type (may be repeated)")); |
| 1010 | 1014 | ||
| @@ -1037,7 +1041,7 @@ print_usage (void) | |||
| 1037 | printf ("%s\n", _("Usage:")); | 1041 | printf ("%s\n", _("Usage:")); |
| 1038 | printf (" %s {-w absolute_limit |-w percentage_limit%% | -W inode_percentage_limit } {-c absolute_limit|-c percentage_limit%% | -K inode_percentage_limit } {-p path | -x device}\n", progname); | 1042 | printf (" %s {-w absolute_limit |-w percentage_limit%% | -W inode_percentage_limit } {-c absolute_limit|-c percentage_limit%% | -K inode_percentage_limit } {-p path | -x device}\n", progname); |
| 1039 | printf ("[-C] [-E] [-e] [-f] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n"); | 1043 | printf ("[-C] [-E] [-e] [-f] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n"); |
| 1040 | printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n"); | 1044 | printf ("[-t timeout] [-u unit] [-v] [-X type_regex] [-N type]\n"); |
| 1041 | } | 1045 | } |
| 1042 | 1046 | ||
| 1043 | bool | 1047 | bool |
