Просмотр исходного кода

Merge pull request #529 from sawolf/522-fix-units

Resolves #518 - all calculations are now done with binary units (as it was in 2.2.x).
Sebastian Wolf 6 лет назад
Родитель
Сommit
3dc3fe6f86
2 измененных файлов с 7 добавлено и 4 удалено
  1. 1 0
      NEWS
  2. 6 4
      plugins/check_disk.c

+ 1 - 0
NEWS

@@ -3,6 +3,7 @@ This file documents the major additions and syntax changes between releases.
 2.3.2 2020-??-??
 	FIXES
 	check_http: Fix host:port syntax when using -H (Isaac White)
+	check_disk: Change unit calculations to always use binary units for backward compatibility (#518)
 	check_ntp_peer: Fixed improper performance data by setting LC_NUMERIC to 'C' (#526)
 	check_ntp_time: Fixed improper performance data by setting LC_NUMERIC to 'C' (#526)
 	check_mailq: Fix nullmailer regular expression to recognize minutes and seconds properly (#522)

+ 6 - 4
plugins/check_disk.c

@@ -786,16 +786,16 @@ process_arguments (int argc, char **argv)
         mult = (uintmax_t)1;
         units = strdup ("B");
       } else if (! strcmp (optarg, "kB")) {
-        mult = (uintmax_t)1000;
+        mult = (uintmax_t)1024;
         units = strdup ("kB");
       } else if (! strcmp (optarg, "MB")) {
-        mult = (uintmax_t)1000 * 1000;
+        mult = (uintmax_t)1024 * 1024;
         units = strdup ("MB");
       } else if (! strcmp (optarg, "GB")) {
-        mult = (uintmax_t)1000 * 1000 * 1000;
+        mult = (uintmax_t)1024 * 1024 * 1024;
         units = strdup ("GB");
       } else if (! strcmp (optarg, "TB")) {
-        mult = (uintmax_t)1000 * 1000 * 1000 * 1000;
+        mult = (uintmax_t)1024 * 1024 * 1024 * 1024;
         units = strdup ("TB");
       } else if (! strcmp (optarg, "KiB")) {
         mult = (uintmax_t)1024;
@@ -1202,6 +1202,8 @@ print_help (void)
   printf (UT_PLUG_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
   printf (" %s\n", "-u, --units=STRING");
   printf ("    %s\n", _("Choose bytes, kB, MB, GB, TB, KiB, MiB, GiB, TiB (default: MiB)"));
+  printf ("    %s\n", _("Note: kB/MB/GB/TB are still calculated as their respective binary"));
+  printf ("    %s\n", _("units due to backward compatibility issues."));
   printf (UT_VERBOSE);
   printf (" %s\n", "-X, --exclude-type=TYPE");
   printf ("    %s\n", _("Ignore all filesystems of indicated type (may be repeated)"));