]> granicus.if.org Git - sysstat/commitdiff
iostat: Add --compact option (#303)
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 26 Sep 2021 08:36:59 +0000 (10:36 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 26 Sep 2021 08:36:59 +0000 (10:36 +0200)
This option tells iostat to not break a report into sub-reports, as
--pretty option may do when there are many metrics to display.

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

index 6eddd8b84db74182c10023c7a7395c8b3e7b0958..515d4e6b58d640edd20df543aa24bc48ef6bd7d2 100644 (file)
--- a/iostat.c
+++ b/iostat.c
@@ -92,14 +92,14 @@ void usage(char *progname)
        fprintf(stderr, _("Options are:\n"
                          "[ -c ] [ -d ] [ -h ] [ -k | -m ] [ -N ] [ -s ] [ -t ] [ -V ] [ -x ] [ -y ] [ -z ]\n"
                          "[ { -f | +f } <directory> ] [ -j { ID | LABEL | PATH | UUID | ... } ]\n"
-                         "[ --dec={ 0 | 1 | 2 } ] [ --human ] [ --pretty ] [ -o JSON ]\n"
+                         "[ --compact ] [ --dec={ 0 | 1 | 2 } ] [ --human ] [ --pretty ] [ -o JSON ]\n"
                          "[ [ -H ] -g <group_name> ] [ -p [ <device> [,...] | ALL ] ]\n"
                          "[ <device> [...] | ALL ] [ --debuginfo ]\n"));
 #else
        fprintf(stderr, _("Options are:\n"
                          "[ -c ] [ -d ] [ -h ] [ -k | -m ] [ -N ] [ -s ] [ -t ] [ -V ] [ -x ] [ -y ] [ -z ]\n"
                          "[ { -f | +f } <directory> ] [ -j { ID | LABEL | PATH | UUID | ... } ]\n"
-                         "[ --dec={ 0 | 1 | 2 } ] [ --human ] [ --pretty ] [ -o JSON ]\n"
+                         "[ --compact ] [ --dec={ 0 | 1 | 2 } ] [ --human ] [ --pretty ] [ -o JSON ]\n"
                          "[ [ -H ] -g <group_name> ] [ -p [ <device> [,...] | ALL ] ]\n"
                          "[ <device> [...] | ALL ]\n"));
 #endif
@@ -1795,7 +1795,8 @@ void write_stats(int curr, struct tm *rectime, int skip)
                if (DISPLAY_PRETTY(flags) &&
                    DISPLAY_EXTENDED(flags) &&
                    !DISPLAY_SHORT_OUTPUT(flags) &&
-                   !DISPLAY_JSON_OUTPUT(flags)) {
+                   !DISPLAY_JSON_OUTPUT(flags) &&
+                   !DISPLAY_COMPACT(flags)) {
                        hl = 1; hh = 4;
                }
 
@@ -2126,6 +2127,11 @@ int main(int argc, char **argv)
                        opt++;
                }
 
+               else if (!strcmp(argv[opt], "--compact")) {
+                       flags |= I_D_COMPACT;
+                       opt++;
+               }
+
 #ifdef TEST
                else if (!strncmp(argv[opt], "--getenv", 8)) {
                        __env = TRUE;
index 261271c19ec0beb2dbee5094c00deb6b9f2b078c..6fff0bce30f5e41b84dc4000f5c162ba0d6d88a0 100644 (file)
--- a/iostat.h
+++ b/iostat.h
@@ -31,6 +31,7 @@
 #define I_D_ZERO_OMIT          0x080000
 #define I_D_UNIT               0x100000
 #define I_D_SHORT_OUTPUT       0x200000
+#define I_D_COMPACT            0x400000
 
 #define DISPLAY_CPU(m)                 (((m) & I_D_CPU)              == I_D_CPU)
 #define DISPLAY_DISK(m)                        (((m) & I_D_DISK)             == I_D_DISK)
@@ -54,6 +55,7 @@
 #define DISPLAY_UNIT(m)                        (((m) & I_D_UNIT)             == I_D_UNIT)
 #define DISPLAY_SHORT_OUTPUT(m)                (((m) & I_D_SHORT_OUTPUT)     == I_D_SHORT_OUTPUT)
 #define USE_ALL_DIR(m)                 (((m) & I_D_ALL_DIR)          == I_D_ALL_DIR)
+#define DISPLAY_COMPACT(m)             (((m) & I_D_COMPACT)          == I_D_COMPACT)
 
 #define T_PART         0
 #define T_DEV          1