- add -h optioon to iostat tool

(-h   Make the disk stats report easier to read by a human.)
This commit is contained in:
Ivana Hutarova Varekova 2011-05-02 16:09:20 +02:00
parent 1063d7765b
commit 7c18c5e27a
2 changed files with 116 additions and 1 deletions

View File

@ -0,0 +1,109 @@
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

View File

@ -1,6 +1,6 @@
Name: sysstat
Version: 10.0.0
Release: 2%{?dist}
Release: 3%{?dist}
Summary: The sar and iostat system monitoring commands
License: GPLv2+
Group: Applications/System
@ -9,6 +9,7 @@ Source: http://perso.orange.fr/sebastien.godard/%{name}-%{version}.tar.bz2
# fixes #643380
Patch11: sysstat-10.0.0-cpu.patch
Patch12: sysstat-10.0.0-makefile.patch
Patch13: sysstat-10.0.0-iostat_hr.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires: /sbin/chkconfig
@ -27,6 +28,7 @@ activity.
%setup -q
%patch11 -p1 -b .cpu
%patch12 -p1 -b .ls
%patch13 -p1 -b .hr
iconv -f windows-1252 -t utf8 CREDITS > CREDITS.aux
mv CREDITS.aux CREDITS
@ -75,6 +77,10 @@ rm -rf %{buildroot}
%{_localstatedir}/log/sa
%changelog
* Mon May 2 2011 Ivana Hutarova Varekova <varekova@redhat.com> - 10.0.0-3
- add -h optioon to iostat tool
(-h Make the disk stats report easier to read by a human.)
* Mon Apr 4 2011 Ivana Hutarova Varekova <varekova@redhat.com> - 10.0.0-2
- remove unnecessary patch