diff options
Diffstat (limited to 'plugins/check_disk.c')
-rw-r--r-- | plugins/check_disk.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 7018c6fd..8df9e7ec 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
@@ -112,7 +112,8 @@ enum | |||
112 | { | 112 | { |
113 | SYNC_OPTION = CHAR_MAX + 1, | 113 | SYNC_OPTION = CHAR_MAX + 1, |
114 | NO_SYNC_OPTION, | 114 | NO_SYNC_OPTION, |
115 | BLOCK_SIZE_OPTION | 115 | BLOCK_SIZE_OPTION, |
116 | IGNORE_MISSING | ||
116 | }; | 117 | }; |
117 | 118 | ||
118 | #ifdef _AIX | 119 | #ifdef _AIX |
@@ -140,6 +141,7 @@ int verbose = 0; | |||
140 | int erronly = FALSE; | 141 | int erronly = FALSE; |
141 | int display_mntp = FALSE; | 142 | int display_mntp = FALSE; |
142 | int exact_match = FALSE; | 143 | int exact_match = FALSE; |
144 | int ignore_missing = FALSE; | ||
143 | int freespace_ignore_reserved = FALSE; | 145 | int freespace_ignore_reserved = FALSE; |
144 | int display_inodes_perfdata = FALSE; | 146 | int display_inodes_perfdata = FALSE; |
145 | char *warn_freespace_units = NULL; | 147 | char *warn_freespace_units = NULL; |
@@ -219,7 +221,9 @@ main (int argc, char **argv) | |||
219 | temp_list = path_select_list; | 221 | temp_list = path_select_list; |
220 | 222 | ||
221 | while (temp_list) { | 223 | while (temp_list) { |
222 | if (! temp_list->best_match) { | 224 | if (! temp_list->best_match && ignore_missing == 1) { |
225 | die (STATE_OK, _("DISK %s: %s not found (ignoring)\n"), _("OK"), temp_list->name); | ||
226 | } else if (! temp_list->best_match) { | ||
223 | die (STATE_CRITICAL, _("DISK %s: %s not found\n"), _("CRITICAL"), temp_list->name); | 227 | die (STATE_CRITICAL, _("DISK %s: %s not found\n"), _("CRITICAL"), temp_list->name); |
224 | } | 228 | } |
225 | 229 | ||
@@ -481,6 +485,7 @@ process_arguments (int argc, char **argv) | |||
481 | {"ignore-ereg-partition", required_argument, 0, 'i'}, | 485 | {"ignore-ereg-partition", required_argument, 0, 'i'}, |
482 | {"ignore-eregi-path", required_argument, 0, 'I'}, | 486 | {"ignore-eregi-path", required_argument, 0, 'I'}, |
483 | {"ignore-eregi-partition", required_argument, 0, 'I'}, | 487 | {"ignore-eregi-partition", required_argument, 0, 'I'}, |
488 | {"ignore-missing", no_argument, 0, IGNORE_MISSING}, | ||
484 | {"local", no_argument, 0, 'l'}, | 489 | {"local", no_argument, 0, 'l'}, |
485 | {"stat-remote-fs", no_argument, 0, 'L'}, | 490 | {"stat-remote-fs", no_argument, 0, 'L'}, |
486 | {"iperfdata", no_argument, 0, 'P'}, | 491 | {"iperfdata", no_argument, 0, 'P'}, |
@@ -718,6 +723,9 @@ process_arguments (int argc, char **argv) | |||
718 | cflags = default_cflags; | 723 | cflags = default_cflags; |
719 | break; | 724 | break; |
720 | 725 | ||
726 | case IGNORE_MISSING: | ||
727 | ignore_missing = 1; | ||
728 | break; | ||
721 | case 'A': | 729 | case 'A': |
722 | optarg = strdup(".*"); | 730 | optarg = strdup(".*"); |
723 | // Intentional fallthrough | 731 | // Intentional fallthrough |
@@ -753,7 +761,10 @@ process_arguments (int argc, char **argv) | |||
753 | } | 761 | } |
754 | } | 762 | } |
755 | 763 | ||
756 | if (!fnd) | 764 | if (!fnd && ignore_missing == 1) |
765 | die (STATE_OK, "DISK %s: %s - %s\n",_("OK"), | ||
766 | _("Regular expression did not match any path or disk (ignoring)"), optarg); | ||
767 | else if (!fnd) | ||
757 | die (STATE_UNKNOWN, "DISK %s: %s - %s\n",_("UNKNOWN"), | 768 | die (STATE_UNKNOWN, "DISK %s: %s - %s\n",_("UNKNOWN"), |
758 | _("Regular expression did not match any path or disk"), optarg); | 769 | _("Regular expression did not match any path or disk"), optarg); |
759 | 770 | ||
@@ -923,6 +934,9 @@ print_help (void) | |||
923 | printf (" %s\n", _("Regular expression to ignore selected path/partition (case insensitive) (may be repeated)")); | 934 | printf (" %s\n", _("Regular expression to ignore selected path/partition (case insensitive) (may be repeated)")); |
924 | printf (" %s\n", "-i, --ignore-ereg-path=PATH, --ignore-ereg-partition=PARTITION"); | 935 | printf (" %s\n", "-i, --ignore-ereg-path=PATH, --ignore-ereg-partition=PARTITION"); |
925 | printf (" %s\n", _("Regular expression to ignore selected path or partition (may be repeated)")); | 936 | printf (" %s\n", _("Regular expression to ignore selected path or partition (may be repeated)")); |
937 | printf (" %s\n", "--ignore-missing"); | ||
938 | printf (" %s\n", _("Return OK if no filesystem matches, filesystem does not exist or is inaccessible.")); | ||
939 | printf (" %s\n", _("(Provide this option before -r / --ereg-path if used)")); | ||
926 | printf (UT_PLUG_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); | 940 | printf (UT_PLUG_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); |
927 | printf (" %s\n", "-u, --units=STRING"); | 941 | printf (" %s\n", "-u, --units=STRING"); |
928 | printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)")); | 942 | printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)")); |
@@ -965,8 +979,13 @@ stat_path (struct parameter_list *p) | |||
965 | if (stat (p->name, &stat_buf[0])) { | 979 | if (stat (p->name, &stat_buf[0])) { |
966 | if (verbose >= 3) | 980 | if (verbose >= 3) |
967 | printf("stat failed on %s\n", p->name); | 981 | printf("stat failed on %s\n", p->name); |
968 | printf("DISK %s - ", _("CRITICAL")); | 982 | if (ignore_missing == 1) { |
969 | die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("is not accessible"), strerror(errno)); | 983 | printf("DISK %s - ", _("OK")); |
984 | die (STATE_OK, _("%s %s: %s\n"), p->name, _("is not accessible (ignoring)"), strerror(errno)); | ||
985 | } else { | ||
986 | printf("DISK %s - ", _("CRITICAL")); | ||
987 | die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("is not accessible"), strerror(errno)); | ||
988 | } | ||
970 | } | 989 | } |
971 | } | 990 | } |
972 | 991 | ||