]> granicus.if.org Git - sysstat/commitdiff
Option -h added to iostat.
authorSebastien Godard <sysstat@orange.fr>
Thu, 5 May 2011 12:19:48 +0000 (14:19 +0200)
committerSebastien Godard <sysstat@orange.fr>
Thu, 5 May 2011 12:19:48 +0000 (14:19 +0200)
Option -h added to iostat. This option makes the device utilization
report easier to read with long device names.

Mail from Ivana Varekova (varekova@redhat.com) 02/05/2011
Subject: feature request: Resizing device column in iostat to size of larges lvm device name

Hello,
I'm sending three patches against sysstat-10.0.0:
* sysstat_1.patch
  adds -h (human readable) option to iostat tool (just to indent the row after the device name)
[...]

If you need a clarification to arbitrary of them please sent me an e-mail.
Ivana

From Fedora bugzilla: G. Michael Carter      2011-04-11 17:19:58 EDT

As far as reports go this is rather hard to read.  Can we get the Device column
to size based on the longest name?

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz
avgqu-sz   await  svctm  %util
sdb             215.50    61.75  340.00   53.75    33.38     0.42   175.78
5.72   25.39   2.51  98.92
sdc               0.00    39.00   20.50   24.50     0.06     0.21    11.98
0.07    1.54   1.46   6.55
sda               0.00     0.25   18.50    0.50     0.08     0.00     8.71
0.07    3.43   1.74   3.30
sde               0.00     0.00   15.00    0.00     0.03     0.00     4.73
0.04    2.45   0.83   1.25
sdf               0.00   218.75    5.00  324.75     0.03    33.34   207.23
0.36    1.09   0.82  27.07
LiandraStore-Home     0.00     0.00    7.25   37.25     0.03     0.13     7.51
   4.98  537.54  13.85  61.62
LiandraStore-Root     0.00     0.00    6.25    0.75     0.02     0.00     8.00
   0.01    0.89   0.75   0.53
LiandraStore-SWAP_Balanced     0.00     0.00    6.25    0.00     0.02     0.00
   8.00     0.05    8.32   5.64   3.52
LiandraStore-VirtualMachines     0.00     0.00    5.00  125.75     0.02
0.46     7.59     3.36   25.67   7.61  99.47
LiandraStore-MassMedia     0.00     0.00    5.00    0.00     0.00     0.00
1.60     0.02    3.40   1.20   0.60
LiandraStore-Old--Liandra     0.00     0.00    5.00    0.00     0.00     0.00
  1.60     0.00    0.25   0.15   0.07
LiandraStore-Backups     0.00     0.00    5.00    0.00     0.02     0.00
8.00     0.00    0.30   0.15   0.07
LiandraStore-LiveCD     0.00     0.00    5.00    0.00     0.02     0.00
8.00     0.01    2.25   0.70   0.35
LiandraStore-iTunes_Media     0.00     0.00    5.00    0.00     0.00     0.00
  1.60     0.02    4.40   1.10   0.55
LiandraStore-DVD--Working     0.00     0.00    1.50    0.00     0.00     0.00
  1.00     0.01    3.00   1.50   0.23
LiandraStore-pvmove0     0.00     0.00    7.25   37.75     0.03     0.13
7.42     4.98  531.57  13.69  61.62

CHANGES
iostat.c
iostat.h
man/iostat.in

diff --git a/CHANGES b/CHANGES
index 8345058a11752057049b650b42132e2d8ec3fb11..5989344083c78c65d6e78fa95ac89ead770b49d1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
 Changes:
 
 xxxx/xx/xx: Version 10.0.1 - Sebastien Godard (sysstat <at> orange.fr)
+       * [Ivana Varekova]: Added option -h to iostat. This option makes
+         the device utilization report easier to read with long device
+         names.
        * [Ivana Varekova]: cifsiostat didn't count open files from the
          "Posix Open" column in /proc/fs/cifs/Stats file. This is now
          fixed.
index a038815d0a0ed37e93d91929c4cc136828a3317b..d2f0f41b2405822aa5d6d7ba5bdbae7adcc422a0 100644 (file)
--- a/iostat.c
+++ b/iostat.c
@@ -81,11 +81,11 @@ void usage(char *progname)
                progname);
 #ifdef DEBUG
        fprintf(stderr, _("Options are:\n"
-                         "[ -c ] [ -d ] [ -N ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ]\n"
+                         "[ -c ] [ -d ] [ -h ] [ -N ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ]\n"
                          "[ <device> [...] | ALL ] [ -p [ <device> [,...] | ALL ] ] [ --debuginfo ]\n"));
 #else
        fprintf(stderr, _("Options are:\n"
-                         "[ -c ] [ -d ] [ -N ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ]\n"
+                         "[ -c ] [ -d ] [ -h ] [ -N ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ]\n"
                          "[ <device> [...] | ALL ] [ -p [ <device> [,...] | ALL ] ]\n"));
 #endif
        exit(1);
@@ -827,9 +827,16 @@ void write_ext_stat(int curr, unsigned long long itv, int fctr,
                  (ioi->wr_ticks - ioj->wr_ticks) /
                  ((double) (ioi->wr_ios - ioj->wr_ios)) : 0.0;
 
-       /*      DEV   rrq/s wrq/s   r/s   w/s  rsec  wsec  rqsz  qusz await r_await w_await svctm %util */
-       printf("%-13s %8.2f %8.2f %7.2f %7.2f %8.2f %8.2f %8.2f %8.2f %7.2f %7.2f %7.2f %6.2f %6.2f\n",
-              shi->name,
+       /* Print device name */
+       if (DISPLAY_HUMAN_READ(flags)) {
+               printf("%s\n%13s", shi->name, "");
+       }
+       else {
+               printf("%-13s", shi->name);
+       }
+
+       /*       rrq/s wrq/s   r/s   w/s  rsec  wsec  rqsz  qusz await r_await w_await svctm %util */
+       printf(" %8.2f %8.2f %7.2f %7.2f %8.2f %8.2f %8.2f %8.2f %7.2f %7.2f %7.2f %6.2f %6.2f\n",
               S_VALUE(ioj->rd_merges, ioi->rd_merges, itv),
               S_VALUE(ioj->wr_merges, ioi->wr_merges, itv),
               S_VALUE(ioj->rd_ios, ioi->rd_ios, itv),
@@ -866,7 +873,13 @@ void write_basic_stat(int curr, unsigned long long itv, int fctr,
 {
        unsigned long long rd_sec, wr_sec;
 
-       printf("%-13s", shi->name);
+       /* Print device name */
+       if (DISPLAY_HUMAN_READ(flags)) {
+               printf("%s\n%13s", shi->name, "");
+       }
+       else {
+               printf("%-13s", shi->name);
+       }
 
        /* Print stats coming from /sys or /proc/diskstats */
        rd_sec = ioi->rd_sectors - ioj->rd_sectors;
@@ -1193,6 +1206,14 @@ int main(int argc, char **argv)
                                        flags |= I_D_DISK;
                                        report_set = TRUE;
                                        break;
+                               
+                               case 'h':
+                                       /*
+                                        * Display device utilization report
+                                        * in a human readable format.
+                                        */
+                                       flags |= I_D_HUMAN_READ;
+                                       break;
 
                                case 'k':
                                        if (DISPLAY_MEGABYTES(flags)) {
index 42b8d6487577a4ae570b548000319ead81e48a74..dc7129d145a5ca0fbf7f8280bcf67f3afa22a93e 100644 (file)
--- a/iostat.h
+++ b/iostat.h
@@ -21,7 +21,7 @@
 #define I_D_MEGABYTES          0x00200
 #define I_D_PARTITIONS         0x00400
 #define I_F_HAS_DISKSTATS      0x00800
-/* Unused                      0x01000 */
+#define I_D_HUMAN_READ         0x01000
 /* Unused                      0x02000 */
 /* Unused                      0x04000 */
 /* Unused                      0x08000 */
@@ -42,6 +42,7 @@
 #define DISPLAY_UNFILTERED(m)  (((m) & I_D_UNFILTERED)    == I_D_UNFILTERED)
 #define DISPLAY_PARTITIONS(m)  (((m) & I_D_PARTITIONS)    == I_D_PARTITIONS)
 #define HAS_DISKSTATS(m)       (((m) & I_F_HAS_DISKSTATS) == I_F_HAS_DISKSTATS)
+#define DISPLAY_HUMAN_READ(m)  (((m) & I_D_HUMAN_READ)    == I_D_HUMAN_READ)
 #define DISPLAY_DEVMAP_NAME(m) (((m) & I_D_DEVMAP_NAME)   == I_D_DEVMAP_NAME)
 #define DISPLAY_ISO(m)         (((m) & I_D_ISO)           == I_D_ISO)
 #define DISPLAY_ZERO_OMIT(m)   (((m) & I_D_ZERO_OMIT)     == I_D_ZERO_OMIT)
index 3f3bd8aa5dee99e909123c20d7db0b82e700b05b..b278a43c793539bb50f16f56e2bec2e914af0a8a 100644 (file)
@@ -1,10 +1,10 @@
-.TH IOSTAT 1 "JUNE 2010" Linux "Linux User's Manual" -*- nroff -*-
+.TH IOSTAT 1 "MAY 2011" Linux "Linux User's Manual" -*- nroff -*-
 .SH NAME
 iostat \- Report Central Processing Unit (CPU) statistics and input/output
 statistics for devices and partitions.
 .SH SYNOPSIS
 .ie 'yes'@WITH_DEBUG@' \{
-.B iostat [ -c ] [ -d ] [ --debuginfo ] [ -N ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ] [
+.B iostat [ -c ] [ -d ] [ --debuginfo ] [ -h ] [ -N ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ] [
 .I device
 .B [...] | ALL ] [ -p [
 .I device
@@ -15,7 +15,7 @@ statistics for devices and partitions.
 .B ] ]
 .\}
 .el \{
-.B iostat [ -c ] [ -d ] [ -N ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ] [
+.B iostat [ -c ] [ -d ] [ -h ] [ -N ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ] [
 .I device
 .B [...] | ALL ] [ -p [
 .I device
@@ -265,6 +265,8 @@ Display the device utilization report.
 .IP --debuginfo
 Print debug output to stderr.
 .\}
+.IP -h
+Make the Device Utilization Report easier to read by a human.
 .IP -k
 Display statistics in kilobytes per second.
 .IP -m