diff options
Diffstat (limited to 'plugins/check_disk.c')
| -rw-r--r-- | plugins/check_disk.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 6ba7bdf3..47dc0adc 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
| @@ -91,9 +91,12 @@ static int stat_remote_fs = 0; | |||
| 91 | 91 | ||
| 92 | /* Linked list of filesystem types to omit. | 92 | /* Linked list of filesystem types to omit. |
| 93 | If the list is empty, don't exclude any types. */ | 93 | If the list is empty, don't exclude any types. */ |
| 94 | |||
| 95 | static struct name_list *fs_exclude_list; | 94 | static struct name_list *fs_exclude_list; |
| 96 | 95 | ||
| 96 | /* Linked list of filesystem types to check. | ||
| 97 | If the list is empty, include all types. */ | ||
| 98 | static struct name_list *fs_include_list; | ||
| 99 | |||
| 97 | static struct name_list *dp_exclude_list; | 100 | static struct name_list *dp_exclude_list; |
| 98 | 101 | ||
| 99 | static struct parameter_list *path_select_list = NULL; | 102 | static struct parameter_list *path_select_list = NULL; |
| @@ -135,6 +138,7 @@ int verbose = 0; | |||
| 135 | int erronly = FALSE; | 138 | int erronly = FALSE; |
| 136 | int display_mntp = FALSE; | 139 | int display_mntp = FALSE; |
| 137 | int exact_match = FALSE; | 140 | int exact_match = FALSE; |
| 141 | int freespace_ignore_reserved = FALSE; | ||
| 138 | char *warn_freespace_units = NULL; | 142 | char *warn_freespace_units = NULL; |
| 139 | char *crit_freespace_units = NULL; | 143 | char *crit_freespace_units = NULL; |
| 140 | char *warn_freespace_percent = NULL; | 144 | char *warn_freespace_percent = NULL; |
| @@ -255,6 +259,9 @@ main (int argc, char **argv) | |||
| 255 | (np_find_name (dp_exclude_list, me->me_devname) || | 259 | (np_find_name (dp_exclude_list, me->me_devname) || |
| 256 | np_find_name (dp_exclude_list, me->me_mountdir))) { | 260 | np_find_name (dp_exclude_list, me->me_mountdir))) { |
| 257 | continue; | 261 | continue; |
| 262 | /* Skip not included fstypes */ | ||
| 263 | } else if (fs_include_list && !np_find_name (fs_include_list, me->me_type)) { | ||
| 264 | continue; | ||
| 258 | } | 265 | } |
| 259 | 266 | ||
| 260 | stat_path(path); | 267 | stat_path(path); |
| @@ -419,11 +426,13 @@ process_arguments (int argc, char **argv) | |||
| 419 | {"partition", required_argument, 0, 'p'}, | 426 | {"partition", required_argument, 0, 'p'}, |
| 420 | {"exclude_device", required_argument, 0, 'x'}, | 427 | {"exclude_device", required_argument, 0, 'x'}, |
| 421 | {"exclude-type", required_argument, 0, 'X'}, | 428 | {"exclude-type", required_argument, 0, 'X'}, |
| 429 | {"include-type", required_argument, 0, 'N'}, | ||
| 422 | {"group", required_argument, 0, 'g'}, | 430 | {"group", required_argument, 0, 'g'}, |
| 423 | {"eregi-path", required_argument, 0, 'R'}, | 431 | {"eregi-path", required_argument, 0, 'R'}, |
| 424 | {"eregi-partition", required_argument, 0, 'R'}, | 432 | {"eregi-partition", required_argument, 0, 'R'}, |
| 425 | {"ereg-path", required_argument, 0, 'r'}, | 433 | {"ereg-path", required_argument, 0, 'r'}, |
| 426 | {"ereg-partition", required_argument, 0, 'r'}, | 434 | {"ereg-partition", required_argument, 0, 'r'}, |
| 435 | {"freespace-ignore-reserved", no_argument, 0, 'f'}, | ||
| 427 | {"ignore-ereg-path", required_argument, 0, 'i'}, | 436 | {"ignore-ereg-path", required_argument, 0, 'i'}, |
| 428 | {"ignore-ereg-partition", required_argument, 0, 'i'}, | 437 | {"ignore-ereg-partition", required_argument, 0, 'i'}, |
| 429 | {"ignore-eregi-path", required_argument, 0, 'I'}, | 438 | {"ignore-eregi-path", required_argument, 0, 'I'}, |
| @@ -452,7 +461,7 @@ process_arguments (int argc, char **argv) | |||
| 452 | strcpy (argv[c], "-t"); | 461 | strcpy (argv[c], "-t"); |
| 453 | 462 | ||
| 454 | while (1) { | 463 | while (1) { |
| 455 | c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:mklLg:R:r:i:I:MEA", longopts, &option); | 464 | c = getopt_long (argc, argv, "+?VqhvefCt:c:w:K:W:u:p:x:X:N:mklLg:R:r:i:I:MEA", longopts, &option); |
| 456 | 465 | ||
| 457 | if (c == -1 || c == EOF) | 466 | if (c == -1 || c == EOF) |
| 458 | break; | 467 | break; |
| @@ -591,6 +600,9 @@ process_arguments (int argc, char **argv) | |||
| 591 | case 'X': /* exclude file system type */ | 600 | case 'X': /* exclude file system type */ |
| 592 | np_add_name(&fs_exclude_list, optarg); | 601 | np_add_name(&fs_exclude_list, optarg); |
| 593 | break; | 602 | break; |
| 603 | case 'N': /* include file system type */ | ||
| 604 | np_add_name(&fs_include_list, optarg); | ||
| 605 | break; | ||
| 594 | case 'v': /* verbose */ | 606 | case 'v': /* verbose */ |
| 595 | verbose++; | 607 | verbose++; |
| 596 | break; | 608 | break; |
| @@ -606,6 +618,9 @@ process_arguments (int argc, char **argv) | |||
| 606 | die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set -E before selecting paths\n")); | 618 | die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set -E before selecting paths\n")); |
| 607 | exact_match = TRUE; | 619 | exact_match = TRUE; |
| 608 | break; | 620 | break; |
| 621 | case 'f': | ||
| 622 | freespace_ignore_reserved = TRUE; | ||
| 623 | break; | ||
| 609 | case 'g': | 624 | case 'g': |
| 610 | if (path_selected) | 625 | if (path_selected) |
| 611 | die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set group value before selecting paths\n")); | 626 | die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set group value before selecting paths\n")); |
| @@ -871,6 +886,8 @@ print_help (void) | |||
| 871 | printf (" %s\n", _("For paths or partitions specified with -p, only check for exact paths")); | 886 | printf (" %s\n", _("For paths or partitions specified with -p, only check for exact paths")); |
| 872 | printf (" %s\n", "-e, --errors-only"); | 887 | printf (" %s\n", "-e, --errors-only"); |
| 873 | printf (" %s\n", _("Display only devices/mountpoints with errors")); | 888 | printf (" %s\n", _("Display only devices/mountpoints with errors")); |
| 889 | printf (" %s\n", "-f, --freespace-ignore-reserved"); | ||
| 890 | printf (" %s\n", _("Don't account root-reserved blocks into freespace in perfdata")); | ||
| 874 | printf (" %s\n", "-g, --group=NAME"); | 891 | printf (" %s\n", "-g, --group=NAME"); |
| 875 | printf (" %s\n", _("Group paths. Thresholds apply to (free-)space of all partitions together")); | 892 | printf (" %s\n", _("Group paths. Thresholds apply to (free-)space of all partitions together")); |
| 876 | printf (" %s\n", "-k, --kilobytes"); | 893 | printf (" %s\n", "-k, --kilobytes"); |
| @@ -900,6 +917,8 @@ print_help (void) | |||
| 900 | printf (UT_VERBOSE); | 917 | printf (UT_VERBOSE); |
| 901 | printf (" %s\n", "-X, --exclude-type=TYPE"); | 918 | printf (" %s\n", "-X, --exclude-type=TYPE"); |
| 902 | printf (" %s\n", _("Ignore all filesystems of indicated type (may be repeated)")); | 919 | printf (" %s\n", _("Ignore all filesystems of indicated type (may be repeated)")); |
| 920 | printf (" %s\n", "-N, --include-type=TYPE"); | ||
| 921 | printf (" %s\n", _("Check only filesystems of indicated type (may be repeated)")); | ||
| 903 | 922 | ||
| 904 | printf ("\n"); | 923 | printf ("\n"); |
| 905 | printf ("%s\n", _("Examples:")); | 924 | printf ("%s\n", _("Examples:")); |
| @@ -921,8 +940,8 @@ print_usage (void) | |||
| 921 | { | 940 | { |
| 922 | printf ("%s\n", _("Usage:")); | 941 | printf ("%s\n", _("Usage:")); |
| 923 | printf (" %s -w limit -c limit [-W limit] [-K limit] {-p path | -x device}\n", progname); | 942 | printf (" %s -w limit -c limit [-W limit] [-K limit] {-p path | -x device}\n", progname); |
| 924 | printf ("[-C] [-E] [-e] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n"); | 943 | printf ("[-C] [-E] [-e] [-f] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n"); |
| 925 | printf ("[-t timeout] [-u unit] [-v] [-X type]\n"); | 944 | printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n"); |
| 926 | } | 945 | } |
| 927 | 946 | ||
| 928 | void | 947 | void |
| @@ -994,13 +1013,19 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) { | |||
| 994 | 1013 | ||
| 995 | void | 1014 | void |
| 996 | get_path_stats (struct parameter_list *p, struct fs_usage *fsp) { | 1015 | get_path_stats (struct parameter_list *p, struct fs_usage *fsp) { |
| 997 | p->total = fsp->fsu_blocks; | ||
| 998 | /* 2007-12-08 - Workaround for Gnulib reporting insanely high available | 1016 | /* 2007-12-08 - Workaround for Gnulib reporting insanely high available |
| 999 | * space on BSD (the actual value should be negative but fsp->fsu_bavail | 1017 | * space on BSD (the actual value should be negative but fsp->fsu_bavail |
| 1000 | * is unsigned) */ | 1018 | * is unsigned) */ |
| 1001 | p->available = fsp->fsu_bavail > fsp->fsu_bfree ? 0 : fsp->fsu_bavail; | 1019 | p->available = fsp->fsu_bavail > fsp->fsu_bfree ? 0 : fsp->fsu_bavail; |
| 1002 | p->available_to_root = fsp->fsu_bfree; | 1020 | p->available_to_root = fsp->fsu_bfree; |
| 1003 | p->used = p->total - p->available_to_root; | 1021 | p->used = fsp->fsu_blocks - fsp->fsu_bfree; |
| 1022 | if (freespace_ignore_reserved) { | ||
| 1023 | /* option activated : we substract the root-reserved space from the total */ | ||
| 1024 | p->total = fsp->fsu_blocks - p->available_to_root + p->available; | ||
| 1025 | } else { | ||
| 1026 | /* default behaviour : take all the blocks into account */ | ||
| 1027 | p->total = fsp->fsu_blocks; | ||
| 1028 | } | ||
| 1004 | 1029 | ||
| 1005 | p->dused_units = p->used*fsp->fsu_blocksize/mult; | 1030 | p->dused_units = p->used*fsp->fsu_blocksize/mult; |
| 1006 | p->dfree_units = p->available*fsp->fsu_blocksize/mult; | 1031 | p->dfree_units = p->available*fsp->fsu_blocksize/mult; |
