aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_disk.c
diff options
context:
space:
mode:
authorGravatar RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> 2021-10-25 17:34:13 +0200
committerGravatar RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> 2021-10-26 17:07:09 +0200
commit078c69d2ddf6b7dd2dfef5ca0f3013a723ec0268 (patch)
tree6e41efe0971f47971faaeaaca54612e74f18c7f0 /plugins/check_disk.c
parente79ada81a696e3c826b383e3ff7cbc8f91bf46a4 (diff)
downloadmonitoring-plugins-078c69d2ddf6b7dd2dfef5ca0f3013a723ec0268.tar.gz
Recognice IEC binary units and format accordingly to base2 (always)
Diffstat (limited to 'plugins/check_disk.c')
-rw-r--r--plugins/check_disk.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index a2735195..07862283 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -574,21 +574,24 @@ process_arguments (int argc, char **argv)
case 'u':
if (units)
free(units);
- if (! strcmp (optarg, "bytes")) {
+ if (! strcasecmp (optarg, "bytes")) {
mult = (uintmax_t)1;
units = strdup ("B");
- } else if (! strcmp (optarg, "kB")) {
+ } else if ( (! strcmp (optarg, "kB")) || (!strcmp(optarg, "KiB")) ) {
mult = (uintmax_t)1024;
- units = strdup ("kB");
- } else if (! strcmp (optarg, "MB")) {
+ units = strdup ("kiB");
+ } else if ( (! strcmp (optarg, "MB")) || (!strcmp(optarg, "MiB")) ) {
mult = (uintmax_t)1024 * 1024;
- units = strdup ("MB");
- } else if (! strcmp (optarg, "GB")) {
+ units = strdup ("MiB");
+ } else if ( (! strcmp (optarg, "GB")) || (!strcmp(optarg, "GiB")) ) {
mult = (uintmax_t)1024 * 1024 * 1024;
- units = strdup ("GB");
- } else if (! strcmp (optarg, "TB")) {
+ units = strdup ("GiB");
+ } else if ( (! strcmp (optarg, "TB")) || (!strcmp(optarg, "TiB")) ) {
mult = (uintmax_t)1024 * 1024 * 1024 * 1024;
- units = strdup ("TB");
+ units = strdup ("TiB");
+ } else if ( (! strcmp (optarg, "PB")) || (!strcmp(optarg, "PiB")) ) {
+ mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024;
+ units = strdup ("PiB");
} else {
die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
}
@@ -599,13 +602,13 @@ process_arguments (int argc, char **argv)
mult = 1024;
if (units)
free(units);
- units = strdup ("kB");
+ units = strdup ("kiB");
break;
case 'm': /* display mountpoint */
mult = 1024 * 1024;
if (units)
free(units);
- units = strdup ("MB");
+ units = strdup ("MiB");
break;
case 'L':
stat_remote_fs = 1;
@@ -812,7 +815,7 @@ process_arguments (int argc, char **argv)
}
if (units == NULL) {
- units = strdup ("MB");
+ units = strdup ("MiB");
mult = (uintmax_t)1024 * 1024;
}