]> granicus.if.org Git - sysstat/commitdiff
iostat: Fix wrong unit used in JSON output
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 24 Nov 2019 07:55:40 +0000 (08:55 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 24 Nov 2019 07:55:40 +0000 (08:55 +0100)
The values for the amount of data read/written or discarded were always
expressed in blocks/s in the JSON output generated by iostat. It should
take into account the unit (blocks, kB, MB) selected by the user.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
iostat.c

index 5aa7a062b93f72387ad2be0d6394d53fa04111ba..41a1dbd5b67f04b0df183df5a45590175536a97d 100644 (file)
--- a/iostat.c
+++ b/iostat.c
@@ -857,11 +857,6 @@ void write_disk_stat_header(int *fctr, int *tab, int hpart)
 {
        char *units, *spc;
 
-       if (DISPLAY_JSON_OUTPUT(flags)) {
-               xprintf((*tab)++, "\"disk\": [");
-               return;
-       }
-
        if (DISPLAY_KILOBYTES(flags)) {
                *fctr = 2;
                units = "kB";
@@ -881,6 +876,11 @@ void write_disk_stat_header(int *fctr, int *tab, int hpart)
                spc = "";
        }
 
+       if (DISPLAY_JSON_OUTPUT(flags)) {
+               xprintf((*tab)++, "\"disk\": [");
+               return;
+       }
+
        if (!DISPLAY_HUMAN_READ(flags)) {
                printf("Device       ");
        }