sysstat/sysstat-10.0.0-iostat_hr.patch
Ivana Hutarova Varekova 7c18c5e27a - add -h optioon to iostat tool
(-h   Make the disk stats report easier to read by a human.)
2011-05-02 16:09:20 +02:00

110 lines
4.2 KiB
Diff

diff -up sysstat-10.0.0/iostat.c.pom sysstat-10.0.0/iostat.c
--- sysstat-10.0.0/iostat.c.pom 2011-03-11 18:09:57.000000000 +0100
+++ sysstat-10.0.0/iostat.c 2011-05-02 15:56:07.000000000 +0200
@@ -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,14 @@ void write_ext_stat(int curr, unsigned l
(ioi->wr_ticks - ioj->wr_ticks) /
((double) (ioi->wr_ios - ioj->wr_ios)) : 0.0;
+ if (DISPLAY_HUMAN_READ(flags)) {
+ printf("%-22s\n%13s", shi->name, "");
+ } else {
+ printf("%-13s ", shi->name);
+ }
+
/* 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,
+ 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 +871,11 @@ void write_basic_stat(int curr, unsigned
{
unsigned long long rd_sec, wr_sec;
- printf("%-13s", shi->name);
+ if (DISPLAY_HUMAN_READ(flags)) {
+ printf("%-22s\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;
@@ -1194,6 +1203,11 @@ int main(int argc, char **argv)
report_set = TRUE;
break;
+ case 'h':
+ /* Display device names in human readable format */
+ flags |= I_D_HUMAN_READ;
+ break;
+
case 'k':
if (DISPLAY_MEGABYTES(flags)) {
usage(argv[0]);
diff -up sysstat-10.0.0/iostat.h.pom sysstat-10.0.0/iostat.h
--- sysstat-10.0.0/iostat.h.pom 2011-03-11 18:09:57.000000000 +0100
+++ sysstat-10.0.0/iostat.h 2011-05-02 15:56:07.000000000 +0200
@@ -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)
diff -up sysstat-10.0.0/man/iostat.in.pom sysstat-10.0.0/man/iostat.in
--- sysstat-10.0.0/man/iostat.in.pom 2010-06-13 15:23:55.000000000 +0200
+++ sysstat-10.0.0/man/iostat.in 2011-05-02 15:56:07.000000000 +0200
@@ -4,7 +4,7 @@ iostat \- Report Central Processing Unit
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 ] [ -h ] [ --debuginfo ] [ -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 disk stats report easier to read by a human.
.IP -k
Display statistics in kilobytes per second.
.IP -m