diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-26 23:23:55 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-26 23:23:55 +0200 |
commit | efa9b0fc0841cc5fb5dde11962f9c45db9ce4815 (patch) | |
tree | 35b024c204e1c1b26b90ba1deccb0bc6d3b64c5d /plugins/check_disk.c | |
parent | fae168a68b132b3a9e32e346342d23fff2b927f2 (diff) | |
parent | a6ff5d44895deb07c7978218eec6f7e1cbdfa94a (diff) | |
download | monitoring-plugins-efa9b0fc0841cc5fb5dde11962f9c45db9ce4815.tar.gz |
Merge branch 'master' of https://github.com/bugness-chl/nagios-plugins
* 'master' of https://github.com/bugness-chl/nagios-plugins:
check_disk: option to ignore reserved space
Conflicts:
plugins/check_disk.c
Diffstat (limited to 'plugins/check_disk.c')
-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; int erronly = FALSE; int display_mntp = FALSE; int exact_match = FALSE; +int freespace_ignore_reserved = FALSE; char *warn_freespace_units = NULL; char *crit_freespace_units = NULL; char *warn_freespace_percent = NULL; @@ -431,6 +432,7 @@ process_arguments (int argc, char **argv) {"eregi-partition", required_argument, 0, 'R'}, {"ereg-path", required_argument, 0, 'r'}, {"ereg-partition", required_argument, 0, 'r'}, + {"freespace-ignore-reserved", no_argument, 0, 'f'}, {"ignore-ereg-path", required_argument, 0, 'i'}, {"ignore-ereg-partition", required_argument, 0, 'i'}, {"ignore-eregi-path", required_argument, 0, 'I'}, @@ -459,7 +461,7 @@ process_arguments (int argc, char **argv) strcpy (argv[c], "-t"); while (1) { - c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:N:mklLg:R:r:i:I:MEA", longopts, &option); + c = getopt_long (argc, argv, "+?VqhvefCt:c:w:K:W:u:p:x:X:N:mklLg:R:r:i:I:MEA", longopts, &option); if (c == -1 || c == EOF) break; @@ -616,6 +618,9 @@ process_arguments (int argc, char **argv) die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set -E before selecting paths\n")); exact_match = TRUE; break; + case 'f': + freespace_ignore_reserved = TRUE; + break; case 'g': if (path_selected) die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set group value before selecting paths\n")); @@ -881,6 +886,8 @@ print_help (void) printf (" %s\n", _("For paths or partitions specified with -p, only check for exact paths")); printf (" %s\n", "-e, --errors-only"); printf (" %s\n", _("Display only devices/mountpoints with errors")); + printf (" %s\n", "-f, --freespace-ignore-reserved"); + printf (" %s\n", _("Don't account root-reserved blocks into freespace in perfdata")); printf (" %s\n", "-g, --group=NAME"); printf (" %s\n", _("Group paths. Thresholds apply to (free-)space of all partitions together")); printf (" %s\n", "-k, --kilobytes"); @@ -933,7 +940,7 @@ print_usage (void) { printf ("%s\n", _("Usage:")); printf (" %s -w limit -c limit [-W limit] [-K limit] {-p path | -x device}\n", progname); - printf ("[-C] [-E] [-e] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n"); + 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"); } @@ -1006,13 +1013,19 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) { void get_path_stats (struct parameter_list *p, struct fs_usage *fsp) { - p->total = fsp->fsu_blocks; /* 2007-12-08 - Workaround for Gnulib reporting insanely high available * space on BSD (the actual value should be negative but fsp->fsu_bavail * is unsigned) */ p->available = fsp->fsu_bavail > fsp->fsu_bfree ? 0 : fsp->fsu_bavail; p->available_to_root = fsp->fsu_bfree; - p->used = p->total - p->available_to_root; + p->used = fsp->fsu_blocks - fsp->fsu_bfree; + if (freespace_ignore_reserved) { + /* option activated : we substract the root-reserved space from the total */ + p->total = fsp->fsu_blocks - p->available_to_root + p->available; + } else { + /* default behaviour : take all the blocks into account */ + p->total = fsp->fsu_blocks; + } p->dused_units = p->used*fsp->fsu_blocksize/mult; p->dfree_units = p->available*fsp->fsu_blocksize/mult; |