summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2021-10-25 15:34:13 (GMT)
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2021-10-26 15:07:09 (GMT)
commit078c69d2ddf6b7dd2dfef5ca0f3013a723ec0268 (patch)
tree6e41efe0971f47971faaeaaca54612e74f18c7f0
parente79ada81a696e3c826b383e3ff7cbc8f91bf46a4 (diff)
downloadmonitoring-plugins-078c69d2ddf6b7dd2dfef5ca0f3013a723ec0268.tar.gz
Recognice IEC binary units and format accordingly to base2 (always)
-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 a273519..0786228 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -574,21 +574,24 @@ process_arguments (int argc, char **argv)
574 case 'u': 574 case 'u':
575 if (units) 575 if (units)
576 free(units); 576 free(units);
577 if (! strcmp (optarg, "bytes")) { 577 if (! strcasecmp (optarg, "bytes")) {
578 mult = (uintmax_t)1; 578 mult = (uintmax_t)1;
579 units = strdup ("B"); 579 units = strdup ("B");
580 } else if (! strcmp (optarg, "kB")) { 580 } else if ( (! strcmp (optarg, "kB")) || (!strcmp(optarg, "KiB")) ) {
581 mult = (uintmax_t)1024; 581 mult = (uintmax_t)1024;
582 units = strdup ("kB"); 582 units = strdup ("kiB");
583 } else if (! strcmp (optarg, "MB")) { 583 } else if ( (! strcmp (optarg, "MB")) || (!strcmp(optarg, "MiB")) ) {
584 mult = (uintmax_t)1024 * 1024; 584 mult = (uintmax_t)1024 * 1024;
585 units = strdup ("MB"); 585 units = strdup ("MiB");
586 } else if (! strcmp (optarg, "GB")) { 586 } else if ( (! strcmp (optarg, "GB")) || (!strcmp(optarg, "GiB")) ) {
587 mult = (uintmax_t)1024 * 1024 * 1024; 587 mult = (uintmax_t)1024 * 1024 * 1024;
588 units = strdup ("GB"); 588 units = strdup ("GiB");
589 } else if (! strcmp (optarg, "TB")) { 589 } else if ( (! strcmp (optarg, "TB")) || (!strcmp(optarg, "TiB")) ) {
590 mult = (uintmax_t)1024 * 1024 * 1024 * 1024; 590 mult = (uintmax_t)1024 * 1024 * 1024 * 1024;
591 units = strdup ("TB"); 591 units = strdup ("TiB");
592 } else if ( (! strcmp (optarg, "PB")) || (!strcmp(optarg, "PiB")) ) {
593 mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024;
594 units = strdup ("PiB");
592 } else { 595 } else {
593 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg); 596 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
594 } 597 }
@@ -599,13 +602,13 @@ process_arguments (int argc, char **argv)
599 mult = 1024; 602 mult = 1024;
600 if (units) 603 if (units)
601 free(units); 604 free(units);
602 units = strdup ("kB"); 605 units = strdup ("kiB");
603 break; 606 break;
604 case 'm': /* display mountpoint */ 607 case 'm': /* display mountpoint */
605 mult = 1024 * 1024; 608 mult = 1024 * 1024;
606 if (units) 609 if (units)
607 free(units); 610 free(units);
608 units = strdup ("MB"); 611 units = strdup ("MiB");
609 break; 612 break;
610 case 'L': 613 case 'L':
611 stat_remote_fs = 1; 614 stat_remote_fs = 1;
@@ -812,7 +815,7 @@ process_arguments (int argc, char **argv)
812 } 815 }
813 816
814 if (units == NULL) { 817 if (units == NULL) {
815 units = strdup ("MB"); 818 units = strdup ("MiB");
816 mult = (uintmax_t)1024 * 1024; 819 mult = (uintmax_t)1024 * 1024;
817 } 820 }
818 821