diff options
| -rw-r--r-- | plugins/check_disk.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 4ea03935..47dc0adc 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
| @@ -138,6 +138,7 @@ int verbose = 0; | |||
| 138 | int erronly = FALSE; | 138 | int erronly = FALSE; |
| 139 | int display_mntp = FALSE; | 139 | int display_mntp = FALSE; |
| 140 | int exact_match = FALSE; | 140 | int exact_match = FALSE; |
| 141 | int freespace_ignore_reserved = FALSE; | ||
| 141 | char *warn_freespace_units = NULL; | 142 | char *warn_freespace_units = NULL; |
| 142 | char *crit_freespace_units = NULL; | 143 | char *crit_freespace_units = NULL; |
| 143 | char *warn_freespace_percent = NULL; | 144 | char *warn_freespace_percent = NULL; |
| @@ -431,6 +432,7 @@ process_arguments (int argc, char **argv) | |||
| 431 | {"eregi-partition", required_argument, 0, 'R'}, | 432 | {"eregi-partition", required_argument, 0, 'R'}, |
| 432 | {"ereg-path", required_argument, 0, 'r'}, | 433 | {"ereg-path", required_argument, 0, 'r'}, |
| 433 | {"ereg-partition", required_argument, 0, 'r'}, | 434 | {"ereg-partition", required_argument, 0, 'r'}, |
| 435 | {"freespace-ignore-reserved", no_argument, 0, 'f'}, | ||
| 434 | {"ignore-ereg-path", required_argument, 0, 'i'}, | 436 | {"ignore-ereg-path", required_argument, 0, 'i'}, |
| 435 | {"ignore-ereg-partition", required_argument, 0, 'i'}, | 437 | {"ignore-ereg-partition", required_argument, 0, 'i'}, |
| 436 | {"ignore-eregi-path", required_argument, 0, 'I'}, | 438 | {"ignore-eregi-path", required_argument, 0, 'I'}, |
| @@ -459,7 +461,7 @@ process_arguments (int argc, char **argv) | |||
| 459 | strcpy (argv[c], "-t"); | 461 | strcpy (argv[c], "-t"); |
| 460 | 462 | ||
| 461 | while (1) { | 463 | while (1) { |
| 462 | c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:N: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); |
| 463 | 465 | ||
| 464 | if (c == -1 || c == EOF) | 466 | if (c == -1 || c == EOF) |
| 465 | break; | 467 | break; |
| @@ -616,6 +618,9 @@ process_arguments (int argc, char **argv) | |||
| 616 | 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")); |
| 617 | exact_match = TRUE; | 619 | exact_match = TRUE; |
| 618 | break; | 620 | break; |
| 621 | case 'f': | ||
| 622 | freespace_ignore_reserved = TRUE; | ||
| 623 | break; | ||
| 619 | case 'g': | 624 | case 'g': |
| 620 | if (path_selected) | 625 | if (path_selected) |
| 621 | 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")); |
| @@ -881,6 +886,8 @@ print_help (void) | |||
| 881 | 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")); |
| 882 | printf (" %s\n", "-e, --errors-only"); | 887 | printf (" %s\n", "-e, --errors-only"); |
| 883 | 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")); | ||
| 884 | printf (" %s\n", "-g, --group=NAME"); | 891 | printf (" %s\n", "-g, --group=NAME"); |
| 885 | 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")); |
| 886 | printf (" %s\n", "-k, --kilobytes"); | 893 | printf (" %s\n", "-k, --kilobytes"); |
| @@ -933,7 +940,7 @@ print_usage (void) | |||
| 933 | { | 940 | { |
| 934 | printf ("%s\n", _("Usage:")); | 941 | printf ("%s\n", _("Usage:")); |
| 935 | 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); |
| 936 | 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"); |
| 937 | printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n"); | 944 | printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n"); |
| 938 | } | 945 | } |
| 939 | 946 | ||
| @@ -1006,13 +1013,19 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) { | |||
| 1006 | 1013 | ||
| 1007 | void | 1014 | void |
| 1008 | get_path_stats (struct parameter_list *p, struct fs_usage *fsp) { | 1015 | get_path_stats (struct parameter_list *p, struct fs_usage *fsp) { |
| 1009 | p->total = fsp->fsu_blocks; | ||
| 1010 | /* 2007-12-08 - Workaround for Gnulib reporting insanely high available | 1016 | /* 2007-12-08 - Workaround for Gnulib reporting insanely high available |
| 1011 | * 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 |
| 1012 | * is unsigned) */ | 1018 | * is unsigned) */ |
| 1013 | 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; |
| 1014 | p->available_to_root = fsp->fsu_bfree; | 1020 | p->available_to_root = fsp->fsu_bfree; |
| 1015 | 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 | } | ||
| 1016 | 1029 | ||
| 1017 | p->dused_units = p->used*fsp->fsu_blocksize/mult; | 1030 | p->dused_units = p->used*fsp->fsu_blocksize/mult; |
| 1018 | p->dfree_units = p->available*fsp->fsu_blocksize/mult; | 1031 | p->dfree_units = p->available*fsp->fsu_blocksize/mult; |
