diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-05-26 08:43:24 +0200 |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-05-26 08:45:00 +0200 |
commit | bf8eb6dcc7f9d1318ddeac16fe62a5b5f818524b (patch) | |
tree | 7e4ef3b705eae5efeb479fccf48cfb47787e9966 /plugins | |
parent | da8d0eb3addfa2a1f966f7feb47a7cbb8124eabc (diff) | |
download | monitoring-plugins-bf8eb6dcc7f9d1318ddeac16fe62a5b5f818524b.tar.gz |
check_disk: Display SI units correctly
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_disk.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index a99f35e3..39dc6cd2 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
@@ -626,21 +626,36 @@ process_arguments (int argc, char **argv) | |||
626 | if (! strcasecmp (optarg, "bytes")) { | 626 | if (! strcasecmp (optarg, "bytes")) { |
627 | mult = (uintmax_t)1; | 627 | mult = (uintmax_t)1; |
628 | units = strdup ("B"); | 628 | units = strdup ("B"); |
629 | } else if ( (! strcmp (optarg, "kB")) || (!strcmp(optarg, "KiB")) ) { | 629 | } else if (!strcmp(optarg, "KiB")) { |
630 | mult = (uintmax_t)1024; | 630 | mult = (uintmax_t)1024; |
631 | units = strdup ("kiB"); | 631 | units = strdup ("KiB"); |
632 | } else if ( (! strcmp (optarg, "MB")) || (!strcmp(optarg, "MiB")) ) { | 632 | } else if (! strcmp (optarg, "kB")) { |
633 | mult = (uintmax_t)1000; | ||
634 | units = strdup ("kB"); | ||
635 | } else if (!strcmp(optarg, "MiB")) { | ||
633 | mult = (uintmax_t)1024 * 1024; | 636 | mult = (uintmax_t)1024 * 1024; |
634 | units = strdup ("MiB"); | 637 | units = strdup ("MiB"); |
635 | } else if ( (! strcmp (optarg, "GB")) || (!strcmp(optarg, "GiB")) ) { | 638 | } else if (! strcmp (optarg, "MB")) { |
639 | mult = (uintmax_t)1000 * 1000; | ||
640 | units = strdup ("MB"); | ||
641 | } else if (!strcmp(optarg, "GiB")) { | ||
636 | mult = (uintmax_t)1024 * 1024 * 1024; | 642 | mult = (uintmax_t)1024 * 1024 * 1024; |
637 | units = strdup ("GiB"); | 643 | units = strdup ("GiB"); |
638 | } else if ( (! strcmp (optarg, "TB")) || (!strcmp(optarg, "TiB")) ) { | 644 | } else if (! strcmp (optarg, "GB")){ |
645 | mult = (uintmax_t)1000 * 1000 * 1000; | ||
646 | units = strdup ("GB"); | ||
647 | } else if (!strcmp(optarg, "TiB")) { | ||
639 | mult = (uintmax_t)1024 * 1024 * 1024 * 1024; | 648 | mult = (uintmax_t)1024 * 1024 * 1024 * 1024; |
640 | units = strdup ("TiB"); | 649 | units = strdup ("TiB"); |
641 | } else if ( (! strcmp (optarg, "PB")) || (!strcmp(optarg, "PiB")) ) { | 650 | } else if (! strcmp (optarg, "TB")) { |
651 | mult = (uintmax_t)1000 * 1000 * 1000 * 1000; | ||
652 | units = strdup ("TB"); | ||
653 | } else if (!strcmp(optarg, "PiB")) { | ||
642 | mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024; | 654 | mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024; |
643 | units = strdup ("PiB"); | 655 | units = strdup ("PiB"); |
656 | } else if (! strcmp (optarg, "PB")){ | ||
657 | mult = (uintmax_t)1000 * 1000 * 1000 * 1000 * 1000; | ||
658 | units = strdup ("PB"); | ||
644 | } else { | 659 | } else { |
645 | die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg); | 660 | die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg); |
646 | } | 661 | } |