From 53ea2304aa8364f74e76f82430b67833fccf402f Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Tue, 12 Sep 2023 00:50:55 +0200 Subject: check_disk: Remove some dead variables --- plugins/check_disk.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'plugins/check_disk.c') diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 39dc6cd2..05e55022 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -131,9 +131,6 @@ bool stat_path (struct parameter_list *p); void get_stats (struct parameter_list *p, struct fs_usage *fsp); void get_path_stats (struct parameter_list *p, struct fs_usage *fsp); -double w_dfp = -1.0; -double c_dfp = -1.0; -char *path; char *exclude_device; char *units; uintmax_t mult = 1024 * 1024; @@ -889,7 +886,7 @@ process_arguments (int argc, char **argv) if (crit_usedspace_percent == NULL && argc > c && is_intnonneg (argv[c])) crit_usedspace_percent = argv[c++]; - if (argc > c && path == NULL) { + if (argc > c) { se = np_add_parameter(&path_select_list, strdup(argv[c++])); path_selected = TRUE; set_all_thresholds(se); -- cgit v1.2.3-74-g34f1 From 3e8fdf9b35ab750e3fe964ce289bbbdaffb3b800 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 20 Sep 2023 18:22:55 +0200 Subject: check_disk: Fix printf format string --- plugins/check_disk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/check_disk.c') diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 05e55022..6cb4cb2f 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -1027,7 +1027,7 @@ void print_usage (void) { printf ("%s\n", _("Usage:")); - 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); + 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); printf ("[-C] [-E] [-e] [-f] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n"); printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n"); } -- cgit v1.2.3-74-g34f1 From 2f916675b3b0ecb7cdeac045304607265cc57065 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 20 Sep 2023 18:23:42 +0200 Subject: check_disk: Mention -A and long options in error message about missing thresholds --- plugins/check_disk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/check_disk.c') diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 6cb4cb2f..bd641480 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -798,7 +798,7 @@ process_arguments (int argc, char **argv) crit_freespace_percent || warn_usedspace_units || crit_usedspace_units || warn_usedspace_percent || crit_usedspace_percent || warn_usedinodes_percent || crit_usedinodes_percent || warn_freeinodes_percent || crit_freeinodes_percent )) { - die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set a threshold value before using -r/-R\n")); + die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--all)\n")); } err = regcomp(&re, optarg, cflags); -- cgit v1.2.3-74-g34f1 From b01aa8c43390a4e32197abedc84af20fd8a8faf6 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 20 Sep 2023 18:24:08 +0200 Subject: check_disk: More spacing to separate examples --- plugins/check_disk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/check_disk.c') diff --git a/plugins/check_disk.c b/plugins/check_disk.c index bd641480..35fd4811 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -1011,10 +1011,10 @@ print_help (void) 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 /"); - printf (" %s\n", _("Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB")); + printf (" %s\n\n", _("Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB")); printf (" %s\n", "check_disk -w 100 -c 50 -C -w 1000 -c 500 -g sidDATA -r '^/oracle/SID/data.*$'"); printf (" %s\n", _("Checks all filesystems not matching -r at 100M and 50M. The fs matching the -r regex")); - printf (" %s\n", _("are grouped which means the freespace thresholds are applied to all disks together")); + printf (" %s\n\n", _("are grouped which means the freespace thresholds are applied to all disks together")); printf (" %s\n", "check_disk -w 100 -c 50 -C -w 1000 -c 500 -p /foo -C -w 5% -c 3% -p /bar"); printf (" %s\n", _("Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use 100M/50M")); -- cgit v1.2.3-74-g34f1 From 8faf7afad389b74d6fe67a2ece10e85b9f614a13 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Thu, 21 Sep 2023 09:00:33 +0200 Subject: check_disk: Add some general usage hints --- plugins/check_disk.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'plugins/check_disk.c') diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 35fd4811..b3edc415 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -1008,6 +1008,14 @@ print_help (void) printf (" %s\n", "-N, --include-type=TYPE"); printf (" %s\n", _("Check only filesystems of indicated type (may be repeated)")); + printf ("\n"); + printf ("%s\n", _("General usage hints:")); + printf (" %s\n", _("- Arguments are positional! \"-w 5 -c 1 -p /foo -w6 -c2 -p /bar\" is not the same as")); + printf (" %s\n", _("\"-w 5 -c 1 -p /bar w6 -c2 -p /foo\".")); + printf (" %s\n", _("- The syntax is broadly: \"{thresholds a} {paths a} {thresholds b} {thresholds b} ...\"")); + + + 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 /"); -- cgit v1.2.3-74-g34f1 From 2ef36843abf3b2ec7142aa2f52b66d5d3c7b543b Mon Sep 17 00:00:00 2001 From: Lorenz Kästle Date: Thu, 21 Sep 2023 09:50:53 +0200 Subject: Add -C to general usage hints --- plugins/check_disk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/check_disk.c') diff --git a/plugins/check_disk.c b/plugins/check_disk.c index b3edc415..7dc1c4b1 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -1012,7 +1012,7 @@ print_help (void) printf ("%s\n", _("General usage hints:")); printf (" %s\n", _("- Arguments are positional! \"-w 5 -c 1 -p /foo -w6 -c2 -p /bar\" is not the same as")); printf (" %s\n", _("\"-w 5 -c 1 -p /bar w6 -c2 -p /foo\".")); - printf (" %s\n", _("- The syntax is broadly: \"{thresholds a} {paths a} {thresholds b} {thresholds b} ...\"")); + printf (" %s\n", _("- The syntax is broadly: \"{thresholds a} {paths a} -C {thresholds b} {thresholds b} ...\"")); -- cgit v1.2.3-74-g34f1 From 4bb444f3353fbb49086bd0e212b3cad8009761dd Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 12 Sep 2023 14:55:00 +0200 Subject: check_disk: make -X a regex list --- plugins/check_disk.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'plugins/check_disk.c') 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; /* Linked list of filesystem types to omit. If the list is empty, don't exclude any types. */ -static struct name_list *fs_exclude_list; +static struct regex_list *fs_exclude_list = NULL; /* Linked list of filesystem types to check. If the list is empty, include all types. */ @@ -300,7 +300,7 @@ main (int argc, char **argv) } else if (me->me_dummy && !show_all_fs) { continue; /* Skip excluded fstypes */ - } else if (fs_exclude_list && np_find_name (fs_exclude_list, me->me_type)) { + } else if (fs_exclude_list && np_find_regmatch (fs_exclude_list, me->me_type)) { continue; /* Skip excluded fs's */ } else if (dp_exclude_list && @@ -543,7 +543,7 @@ process_arguments (int argc, char **argv) if (argc < 2) return ERROR; - np_add_name(&fs_exclude_list, "iso9660"); + np_add_regex(&fs_exclude_list, "iso9660", REG_EXTENDED); for (c = 1; c < argc; c++) if (strcmp ("-to", argv[c]) == 0) @@ -716,7 +716,11 @@ process_arguments (int argc, char **argv) np_add_name(&dp_exclude_list, optarg); break; case 'X': /* exclude file system type */ - np_add_name(&fs_exclude_list, optarg); + err = np_add_regex(&fs_exclude_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 'N': /* include file system type */ np_add_name(&fs_include_list, optarg); @@ -1003,8 +1007,8 @@ print_help (void) 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 (" %s\n", "-X, --exclude-type=TYPE_REGEX"); + printf (" %s\n", _("Ignore all filesystems of types matching given regex(7) (may be repeated)")); printf (" %s\n", "-N, --include-type=TYPE"); printf (" %s\n", _("Check only filesystems of indicated type (may be repeated)")); @@ -1037,7 +1041,7 @@ print_usage (void) printf ("%s\n", _("Usage:")); 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); printf ("[-C] [-E] [-e] [-f] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n"); - printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n"); + printf ("[-t timeout] [-u unit] [-v] [-X type_regex] [-N type]\n"); } bool -- cgit v1.2.3-74-g34f1 From 6947a8cea9335c2eeefb8929aa663db49ecac5a1 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sat, 30 Sep 2023 12:54:21 +0200 Subject: check_disk: Use regex also to include fs types --- plugins/check_disk.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'plugins/check_disk.c') diff --git a/plugins/check_disk.c b/plugins/check_disk.c index e7e9378f..06576d86 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++; -- cgit v1.2.3-74-g34f1 From 819f90b726805f50d6de72f06b58bf02744f4763 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 1 Oct 2023 00:41:55 +0200 Subject: check_disk: Change usage for --include-type to indicated regexes are now possible --- plugins/check_disk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/check_disk.c') diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 06576d86..2f066c7b 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -1013,8 +1013,8 @@ print_help (void) printf (UT_VERBOSE); printf (" %s\n", "-X, --exclude-type=TYPE_REGEX"); printf (" %s\n", _("Ignore all filesystems of types matching given regex(7) (may be repeated)")); - printf (" %s\n", "-N, --include-type=TYPE"); - printf (" %s\n", _("Check only filesystems of indicated type (may be repeated)")); + printf (" %s\n", "-N, --include-type=TYPE_REGEX"); + printf (" %s\n", _("Check only filesystems where the type matches this given regex(7) (may be repeated)")); printf ("\n"); printf ("%s\n", _("General usage hints:")); -- cgit v1.2.3-74-g34f1