Adding d/p/24_check_disk_fix_SI_units from upstream

This commit is contained in:
Jan Wagner 2023-06-12 21:29:53 +02:00
parent 555d643b55
commit 85a271e868
2 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,56 @@
From bf8eb6dcc7f9d1318ddeac16fe62a5b5f818524b Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Fri, 26 May 2023 08:43:24 +0200
Subject: [PATCH] check_disk: Display SI units correctly
---
plugins/check_disk.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index a99f35e33..39dc6cd21 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -626,21 +626,36 @@ process_arguments (int argc, char **argv)
if (! strcasecmp (optarg, "bytes")) {
mult = (uintmax_t)1;
units = strdup ("B");
- } else if ( (! strcmp (optarg, "kB")) || (!strcmp(optarg, "KiB")) ) {
+ } else if (!strcmp(optarg, "KiB")) {
mult = (uintmax_t)1024;
- units = strdup ("kiB");
- } else if ( (! strcmp (optarg, "MB")) || (!strcmp(optarg, "MiB")) ) {
+ units = strdup ("KiB");
+ } else if (! strcmp (optarg, "kB")) {
+ mult = (uintmax_t)1000;
+ units = strdup ("kB");
+ } else if (!strcmp(optarg, "MiB")) {
mult = (uintmax_t)1024 * 1024;
units = strdup ("MiB");
- } else if ( (! strcmp (optarg, "GB")) || (!strcmp(optarg, "GiB")) ) {
+ } else if (! strcmp (optarg, "MB")) {
+ mult = (uintmax_t)1000 * 1000;
+ units = strdup ("MB");
+ } else if (!strcmp(optarg, "GiB")) {
mult = (uintmax_t)1024 * 1024 * 1024;
units = strdup ("GiB");
- } else if ( (! strcmp (optarg, "TB")) || (!strcmp(optarg, "TiB")) ) {
+ } else if (! strcmp (optarg, "GB")){
+ mult = (uintmax_t)1000 * 1000 * 1000;
+ units = strdup ("GB");
+ } else if (!strcmp(optarg, "TiB")) {
mult = (uintmax_t)1024 * 1024 * 1024 * 1024;
units = strdup ("TiB");
- } else if ( (! strcmp (optarg, "PB")) || (!strcmp(optarg, "PiB")) ) {
+ } else if (! strcmp (optarg, "TB")) {
+ mult = (uintmax_t)1000 * 1000 * 1000 * 1000;
+ units = strdup ("TB");
+ } else if (!strcmp(optarg, "PiB")) {
mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024;
units = strdup ("PiB");
+ } else if (! strcmp (optarg, "PB")){
+ mult = (uintmax_t)1000 * 1000 * 1000 * 1000 * 1000;
+ units = strdup ("PB");
} else {
die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
}

View file

@ -15,6 +15,7 @@
21_check_pgsql_extra_output
22_check_disk_avoid_mount
23_check_mysql_fix_error_handling
24_check_disk_fix_SI_units
# feature patches
30_check_radius_radcli_1.3.1_support
31_checl_mailq_separate_submission_queue