diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-03-30 23:30:51 +0200 |
|---|---|---|
| committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-03-30 23:30:51 +0200 |
| commit | a4cf2e79f75dce3828be21726f10c755f652f710 (patch) | |
| tree | e6b72e1453a026917e67030334de16c407ccbb1d /plugins/check_disk.c | |
| parent | c4fd34ed7966a197e596f3e766f58423fe9c5ddc (diff) | |
| download | monitoring-plugins-a4cf2e79f75dce3828be21726f10c755f652f710.tar.gz | |
Remove cool, comfy c23 functionality for some dirty old hacks
Diffstat (limited to 'plugins/check_disk.c')
| -rw-r--r-- | plugins/check_disk.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index ddb9ee49..ac3933a6 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
| @@ -96,6 +96,22 @@ static void print_help(void); | |||
| 96 | 96 | ||
| 97 | static int verbose = 0; | 97 | static int verbose = 0; |
| 98 | 98 | ||
| 99 | // This would not be necessary in C23!! | ||
| 100 | const byte_unit Bytes_Factor = 1; | ||
| 101 | const byte_unit KibiBytes_factor = 1024; | ||
| 102 | const byte_unit MebiBytes_factor = 1048576; | ||
| 103 | const byte_unit GibiBytes_factor = 1073741824; | ||
| 104 | const byte_unit TebiBytes_factor = 1099511627776; | ||
| 105 | const byte_unit PebiBytes_factor = 1125899906842624; | ||
| 106 | const byte_unit ExbiBytes_factor = 1152921504606846976; | ||
| 107 | const byte_unit KiloBytes_factor = 1000; | ||
| 108 | const byte_unit MegaBytes_factor = 1000000; | ||
| 109 | const byte_unit GigaBytes_factor = 1000000000; | ||
| 110 | const byte_unit TeraBytes_factor = 1000000000000; | ||
| 111 | const byte_unit PetaBytes_factor = 1000000000000000; | ||
| 112 | const byte_unit ExaBytes_factor = 1000000000000000000; | ||
| 113 | |||
| 114 | |||
| 99 | int main(int argc, char **argv) { | 115 | int main(int argc, char **argv) { |
| 100 | setlocale(LC_ALL, ""); | 116 | setlocale(LC_ALL, ""); |
| 101 | bindtextdomain(PACKAGE, LOCALEDIR); | 117 | bindtextdomain(PACKAGE, LOCALEDIR); |
| @@ -409,7 +425,7 @@ check_disk_config_wrapper process_arguments(int argc, char **argv) { | |||
| 409 | 425 | ||
| 410 | bool path_selected = false; | 426 | bool path_selected = false; |
| 411 | char *group = NULL; | 427 | char *group = NULL; |
| 412 | byte_unit unit = MebiBytes; | 428 | byte_unit unit = MebiBytes_factor; |
| 413 | 429 | ||
| 414 | result.config.mount_list = read_file_system_list(false); | 430 | result.config.mount_list = read_file_system_list(false); |
| 415 | 431 | ||
| @@ -494,25 +510,25 @@ check_disk_config_wrapper process_arguments(int argc, char **argv) { | |||
| 494 | break; | 510 | break; |
| 495 | case 'u': | 511 | case 'u': |
| 496 | if (!strcasecmp(optarg, "bytes")) { | 512 | if (!strcasecmp(optarg, "bytes")) { |
| 497 | unit = Bytes; | 513 | unit = Bytes_Factor; |
| 498 | } else if (!strcmp(optarg, "KiB")) { | 514 | } else if (!strcmp(optarg, "KiB")) { |
| 499 | unit = KibiBytes; | 515 | unit = KibiBytes_factor; |
| 500 | } else if (!strcmp(optarg, "kB")) { | 516 | } else if (!strcmp(optarg, "kB")) { |
| 501 | unit = KiloBytes; | 517 | unit = KiloBytes_factor; |
| 502 | } else if (!strcmp(optarg, "MiB")) { | 518 | } else if (!strcmp(optarg, "MiB")) { |
| 503 | unit = MebiBytes; | 519 | unit = MebiBytes_factor; |
| 504 | } else if (!strcmp(optarg, "MB")) { | 520 | } else if (!strcmp(optarg, "MB")) { |
| 505 | unit = MegaBytes; | 521 | unit = MegaBytes_factor; |
| 506 | } else if (!strcmp(optarg, "GiB")) { | 522 | } else if (!strcmp(optarg, "GiB")) { |
| 507 | unit = GibiBytes; | 523 | unit = MegaBytes_factor; |
| 508 | } else if (!strcmp(optarg, "GB")) { | 524 | } else if (!strcmp(optarg, "GB")) { |
| 509 | unit = GigaBytes; | 525 | unit = MegaBytes_factor; |
| 510 | } else if (!strcmp(optarg, "TiB")) { | 526 | } else if (!strcmp(optarg, "TiB")) { |
| 511 | unit = TebiBytes; | 527 | unit = MegaBytes_factor; |
| 512 | } else if (!strcmp(optarg, "TB")) { | 528 | } else if (!strcmp(optarg, "TB")) { |
| 513 | unit = TeraBytes; | 529 | unit = MegaBytes_factor; |
| 514 | } else if (!strcmp(optarg, "PiB")) { | 530 | } else if (!strcmp(optarg, "PiB")) { |
| 515 | unit = PebiBytes; | 531 | unit = MegaBytes_factor; |
| 516 | } else if (!strcmp(optarg, "PB")) { | 532 | } else if (!strcmp(optarg, "PB")) { |
| 517 | unit = PetaBytes; | 533 | unit = PetaBytes; |
| 518 | } else { | 534 | } else { |
| @@ -520,10 +536,10 @@ check_disk_config_wrapper process_arguments(int argc, char **argv) { | |||
| 520 | } | 536 | } |
| 521 | break; | 537 | break; |
| 522 | case 'k': | 538 | case 'k': |
| 523 | unit = KibiBytes; | 539 | unit = KibiBytes_factor; |
| 524 | break; | 540 | break; |
| 525 | case 'm': | 541 | case 'm': |
| 526 | unit = MebiBytes; | 542 | unit = MebiBytes_factor; |
| 527 | break; | 543 | break; |
| 528 | case display_unit_index: | 544 | case display_unit_index: |
| 529 | if (!strcasecmp(optarg, "bytes")) { | 545 | if (!strcasecmp(optarg, "bytes")) { |
