summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordatamuc <m@rbfh.de>2023-10-06 09:01:01 (GMT)
committerGitHub <noreply@github.com>2023-10-06 09:01:01 (GMT)
commit5886cfbcb0f9650fc538efa7d825cc4015beb5bb (patch)
tree7168db8bc00b5a3c4308004e66735ebbf382eb27
parent1ad7e163fad45d33a44f398fb2416f1b9086469a (diff)
parentbe0e475339346907c86de5d797f0fab1e071f75c (diff)
downloadmonitoring-plugins-5886cfbcb0f9650fc538efa7d825cc4015beb5bb.tar.gz
Merge branch 'master' into merge-jitter
-rw-r--r--lib/utils_disk.c61
-rw-r--r--lib/utils_disk.h8
-rw-r--r--plugins/check_disk.c32
-rw-r--r--po/de.po15
-rw-r--r--po/fr.po22
-rw-r--r--po/monitoring-plugins.pot15
6 files changed, 123 insertions, 30 deletions
diff --git a/lib/utils_disk.c b/lib/utils_disk.c
index 582d3ea..f5ac0b3 100644
--- a/lib/utils_disk.c
+++ b/lib/utils_disk.c
@@ -29,6 +29,7 @@
29#include "common.h" 29#include "common.h"
30#include "utils_disk.h" 30#include "utils_disk.h"
31#include "gl/fsusage.h" 31#include "gl/fsusage.h"
32#include <string.h>
32 33
33void 34void
34np_add_name (struct name_list **list, const char *name) 35np_add_name (struct name_list **list, const char *name)
@@ -40,6 +41,42 @@ np_add_name (struct name_list **list, const char *name)
40 *list = new_entry; 41 *list = new_entry;
41} 42}
42 43
44/* @brief Initialises a new regex at the begin of list via regcomp(3)
45 *
46 * @details if the regex fails to compile the error code of regcomp(3) is returned
47 * and list is not modified, otherwise list is modified to point to the new
48 * element
49 * @param list Pointer to a linked list of regex_list elements
50 * @param regex the string containing the regex which should be inserted into the list
51 * @param clags the cflags parameter for regcomp(3)
52 */
53int
54np_add_regex (struct regex_list **list, const char *regex, int cflags)
55{
56 struct regex_list *new_entry = (struct regex_list *) malloc (sizeof *new_entry);
57
58 if (new_entry == NULL) {
59 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
60 strerror(errno));
61 }
62
63 int regcomp_result = regcomp(&new_entry->regex, regex, cflags);
64
65 if (!regcomp_result) {
66 // regcomp succeeded
67 new_entry->next = *list;
68 *list = new_entry;
69
70 return 0;
71 } else {
72 // regcomp failed
73 free(new_entry);
74
75 return regcomp_result;
76 }
77
78}
79
43/* Initialises a new parameter at the end of list */ 80/* Initialises a new parameter at the end of list */
44struct parameter_list * 81struct parameter_list *
45np_add_parameter(struct parameter_list **list, const char *name) 82np_add_parameter(struct parameter_list **list, const char *name)
@@ -196,6 +233,30 @@ np_find_name (struct name_list *list, const char *name)
196 return FALSE; 233 return FALSE;
197} 234}
198 235
236/* Returns TRUE if name is in list */
237bool
238np_find_regmatch (struct regex_list *list, const char *name)
239{
240 int len;
241 regmatch_t m;
242
243 if (name == NULL) {
244 return false;
245 }
246
247 len = strlen(name);
248
249 for (; list; list = list->next) {
250 /* Emulate a full match as if surrounded with ^( )$
251 by checking whether the match spans the whole name */
252 if (!regexec(&list->regex, name, 1, &m, 0) && m.rm_so == 0 && m.rm_eo == len) {
253 return true;
254 }
255 }
256
257 return false;
258}
259
199int 260int
200np_seen_name(struct name_list *list, const char *name) 261np_seen_name(struct name_list *list, const char *name)
201{ 262{
diff --git a/lib/utils_disk.h b/lib/utils_disk.h
index 3b5a45f..6b83ac7 100644
--- a/lib/utils_disk.h
+++ b/lib/utils_disk.h
@@ -10,6 +10,12 @@ struct name_list
10 struct name_list *next; 10 struct name_list *next;
11}; 11};
12 12
13struct regex_list
14{
15 regex_t regex;
16 struct regex_list *next;
17};
18
13struct parameter_list 19struct parameter_list
14{ 20{
15 char *name; 21 char *name;
@@ -35,6 +41,8 @@ struct parameter_list
35void np_add_name (struct name_list **list, const char *name); 41void np_add_name (struct name_list **list, const char *name);
36int np_find_name (struct name_list *list, const char *name); 42int np_find_name (struct name_list *list, const char *name);
37int np_seen_name (struct name_list *list, const char *name); 43int np_seen_name (struct name_list *list, const char *name);
44int np_add_regex (struct regex_list **list, const char *regex, int cflags);
45bool np_find_regmatch (struct regex_list *list, const char *name);
38struct parameter_list *np_add_parameter(struct parameter_list **list, const char *name); 46struct parameter_list *np_add_parameter(struct parameter_list **list, const char *name);
39struct parameter_list *np_find_parameter(struct parameter_list *list, const char *name); 47struct parameter_list *np_find_parameter(struct parameter_list *list, const char *name);
40struct parameter_list *np_del_parameter(struct parameter_list *item, struct parameter_list *prev); 48struct parameter_list *np_del_parameter(struct parameter_list *item, struct parameter_list *prev);
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 7dc1c4b..2f066c7 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -93,11 +93,11 @@ 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. */
96static struct name_list *fs_exclude_list; 96static 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. */
100static struct name_list *fs_include_list; 100static struct regex_list *fs_include_list;
101 101
102static struct name_list *dp_exclude_list; 102static struct name_list *dp_exclude_list;
103 103
@@ -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 &&
@@ -308,7 +308,7 @@ main (int argc, char **argv)
308 np_find_name (dp_exclude_list, me->me_mountdir))) { 308 np_find_name (dp_exclude_list, me->me_mountdir))) {
309 continue; 309 continue;
310 /* Skip not included fstypes */ 310 /* Skip not included fstypes */
311 } else if (fs_include_list && !np_find_name (fs_include_list, me->me_type)) { 311 } else if (fs_include_list && !np_find_regmatch(fs_include_list, me->me_type)) {
312 continue; 312 continue;
313 } 313 }
314 } 314 }
@@ -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,10 +716,18 @@ 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 err = np_add_regex(&fs_include_list, optarg, REG_EXTENDED);
727 if (err != 0) {
728 regerror (err, &fs_exclude_list->regex, errbuf, MAX_INPUT_BUFFER);
729 die (STATE_UNKNOWN, "DISK %s: %s - %s\n",_("UNKNOWN"), _("Could not compile regular expression"), errbuf);
730 }
723 break; 731 break;
724 case 'v': /* verbose */ 732 case 'v': /* verbose */
725 verbose++; 733 verbose++;
@@ -1003,10 +1011,10 @@ print_help (void)
1003 printf (" %s\n", "-u, --units=STRING"); 1011 printf (" %s\n", "-u, --units=STRING");
1004 printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)")); 1012 printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)"));
1005 printf (UT_VERBOSE); 1013 printf (UT_VERBOSE);
1006 printf (" %s\n", "-X, --exclude-type=TYPE"); 1014 printf (" %s\n", "-X, --exclude-type=TYPE_REGEX");
1007 printf (" %s\n", _("Ignore all filesystems of indicated type (may be repeated)")); 1015 printf (" %s\n", _("Ignore all filesystems of types matching given regex(7) (may be repeated)"));
1008 printf (" %s\n", "-N, --include-type=TYPE"); 1016 printf (" %s\n", "-N, --include-type=TYPE_REGEX");
1009 printf (" %s\n", _("Check only filesystems of indicated type (may be repeated)")); 1017 printf (" %s\n", _("Check only filesystems where the type matches this given regex(7) (may be repeated)"));
1010 1018
1011 printf ("\n"); 1019 printf ("\n");
1012 printf ("%s\n", _("General usage hints:")); 1020 printf ("%s\n", _("General usage hints:"));
@@ -1037,7 +1045,7 @@ print_usage (void)
1037 printf ("%s\n", _("Usage:")); 1045 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); 1046 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"); 1047 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"); 1048 printf ("[-t timeout] [-u unit] [-v] [-X type_regex] [-N type]\n");
1041} 1049}
1042 1050
1043bool 1051bool
diff --git a/po/de.po b/po/de.po
index 3a34db4..6d79f9d 100644
--- a/po/de.po
+++ b/po/de.po
@@ -9,7 +9,7 @@ msgid ""
9msgstr "" 9msgstr ""
10"Project-Id-Version: PACKAGE VERSION\n" 10"Project-Id-Version: PACKAGE VERSION\n"
11"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n" 11"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
12"POT-Creation-Date: 2023-09-27 12:16+0200\n" 12"POT-Creation-Date: 2023-10-01 00:46+0200\n"
13"PO-Revision-Date: 2004-12-23 17:46+0100\n" 13"PO-Revision-Date: 2004-12-23 17:46+0100\n"
14"Last-Translator: \n" 14"Last-Translator: \n"
15"Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins." 15"Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins."
@@ -308,6 +308,9 @@ msgstr "UNKNOWN"
308msgid "Must set a threshold value before using -p\n" 308msgid "Must set a threshold value before using -p\n"
309msgstr "" 309msgstr ""
310 310
311msgid "Could not compile regular expression"
312msgstr ""
313
311msgid "Must set -E before selecting paths\n" 314msgid "Must set -E before selecting paths\n"
312msgstr "" 315msgstr ""
313 316
@@ -319,9 +322,6 @@ msgid ""
319"explicitly" 322"explicitly"
320msgstr "" 323msgstr ""
321 324
322msgid "Could not compile regular expression"
323msgstr ""
324
325msgid "" 325msgid ""
326"Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--" 326"Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--"
327"all)\n" 327"all)\n"
@@ -446,10 +446,13 @@ msgstr ""
446msgid "Choose bytes, kB, MB, GB, TB (default: MB)" 446msgid "Choose bytes, kB, MB, GB, TB (default: MB)"
447msgstr "" 447msgstr ""
448 448
449msgid "Ignore all filesystems of indicated type (may be repeated)" 449msgid ""
450"Ignore all filesystems of types matching given regex(7) (may be repeated)"
450msgstr "" 451msgstr ""
451 452
452msgid "Check only filesystems of indicated type (may be repeated)" 453msgid ""
454"Check only filesystems where the type matches this given regex(7) (may be "
455"repeated)"
453msgstr "" 456msgstr ""
454 457
455msgid "General usage hints:" 458msgid "General usage hints:"
diff --git a/po/fr.po b/po/fr.po
index da9cf19..c59042d 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -10,7 +10,7 @@ msgid ""
10msgstr "" 10msgstr ""
11"Project-Id-Version: PACKAGE VERSION\n" 11"Project-Id-Version: PACKAGE VERSION\n"
12"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n" 12"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
13"POT-Creation-Date: 2023-09-27 12:16+0200\n" 13"POT-Creation-Date: 2023-10-01 00:46+0200\n"
14"PO-Revision-Date: 2010-04-21 23:38-0400\n" 14"PO-Revision-Date: 2010-04-21 23:38-0400\n"
15"Last-Translator: \n" 15"Last-Translator: \n"
16"Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins." 16"Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins."
@@ -307,6 +307,9 @@ msgstr "INCONNU"
307msgid "Must set a threshold value before using -p\n" 307msgid "Must set a threshold value before using -p\n"
308msgstr "" 308msgstr ""
309 309
310msgid "Could not compile regular expression"
311msgstr "Impossible de compiler l'expression rationnelle"
312
310msgid "Must set -E before selecting paths\n" 313msgid "Must set -E before selecting paths\n"
311msgstr "" 314msgstr ""
312 315
@@ -318,9 +321,6 @@ msgid ""
318"explicitly" 321"explicitly"
319msgstr "" 322msgstr ""
320 323
321msgid "Could not compile regular expression"
322msgstr "Impossible de compiler l'expression rationnelle"
323
324msgid "" 324msgid ""
325"Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--" 325"Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--"
326"all)\n" 326"all)\n"
@@ -461,13 +461,17 @@ msgstr ""
461msgid "Choose bytes, kB, MB, GB, TB (default: MB)" 461msgid "Choose bytes, kB, MB, GB, TB (default: MB)"
462msgstr "Choisissez octets, kb, MB, GB, TB (par défaut: MB)" 462msgstr "Choisissez octets, kb, MB, GB, TB (par défaut: MB)"
463 463
464msgid "Ignore all filesystems of indicated type (may be repeated)" 464#, fuzzy
465msgid ""
466"Ignore all filesystems of types matching given regex(7) (may be repeated)"
465msgstr "" 467msgstr ""
466"Ignorer tout les systèmes de fichiers qui correspondent au type indiqué " 468"Ignorer tout les systèmes de fichiers qui correspondent au type indiqué "
467"(peut être utilisé plusieurs fois)" 469"(peut être utilisé plusieurs fois)"
468 470
469#, fuzzy 471#, fuzzy
470msgid "Check only filesystems of indicated type (may be repeated)" 472msgid ""
473"Check only filesystems where the type matches this given regex(7) (may be "
474"repeated)"
471msgstr "" 475msgstr ""
472"Ignorer tout les systèmes de fichiers qui correspondent au type indiqué " 476"Ignorer tout les systèmes de fichiers qui correspondent au type indiqué "
473"(peut être utilisé plusieurs fois)" 477"(peut être utilisé plusieurs fois)"
@@ -5359,6 +5363,12 @@ msgstr ""
5359msgid "The -v switch can be specified several times for increased verbosity." 5363msgid "The -v switch can be specified several times for increased verbosity."
5360msgstr "" 5364msgstr ""
5361 5365
5366#, fuzzy
5367#~ msgid "Check only filesystems of indicated type (may be repeated)"
5368#~ msgstr ""
5369#~ "Ignorer tout les systèmes de fichiers qui correspondent au type indiqué "
5370#~ "(peut être utilisé plusieurs fois)"
5371
5362#~ msgid "Path or partition (may be repeated)" 5372#~ msgid "Path or partition (may be repeated)"
5363#~ msgstr "Répertoire ou partition (peut être utilisé plusieurs fois)" 5373#~ msgstr "Répertoire ou partition (peut être utilisé plusieurs fois)"
5364 5374
diff --git a/po/monitoring-plugins.pot b/po/monitoring-plugins.pot
index b10e73f..90424b7 100644
--- a/po/monitoring-plugins.pot
+++ b/po/monitoring-plugins.pot
@@ -8,7 +8,7 @@ msgid ""
8msgstr "" 8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n" 9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n" 10"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
11"POT-Creation-Date: 2023-09-27 12:16+0200\n" 11"POT-Creation-Date: 2023-10-01 00:46+0200\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n" 14"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -291,6 +291,9 @@ msgstr ""
291msgid "Must set a threshold value before using -p\n" 291msgid "Must set a threshold value before using -p\n"
292msgstr "" 292msgstr ""
293 293
294msgid "Could not compile regular expression"
295msgstr ""
296
294msgid "Must set -E before selecting paths\n" 297msgid "Must set -E before selecting paths\n"
295msgstr "" 298msgstr ""
296 299
@@ -302,9 +305,6 @@ msgid ""
302"explicitly" 305"explicitly"
303msgstr "" 306msgstr ""
304 307
305msgid "Could not compile regular expression"
306msgstr ""
307
308msgid "" 308msgid ""
309"Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--" 309"Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--"
310"all)\n" 310"all)\n"
@@ -423,10 +423,13 @@ msgstr ""
423msgid "Choose bytes, kB, MB, GB, TB (default: MB)" 423msgid "Choose bytes, kB, MB, GB, TB (default: MB)"
424msgstr "" 424msgstr ""
425 425
426msgid "Ignore all filesystems of indicated type (may be repeated)" 426msgid ""
427"Ignore all filesystems of types matching given regex(7) (may be repeated)"
427msgstr "" 428msgstr ""
428 429
429msgid "Check only filesystems of indicated type (may be repeated)" 430msgid ""
431"Check only filesystems where the type matches this given regex(7) (may be "
432"repeated)"
430msgstr "" 433msgstr ""
431 434
432msgid "General usage hints:" 435msgid "General usage hints:"