Blame SOURCES/sysstat-10.1.5-nfsiostat.patch

ab3721
diff -uprN sysstat-10.1.5.orig/configure sysstat-10.1.5/configure
ab3721
--- sysstat-10.1.5.orig/configure	2013-03-13 15:28:25.000000000 +0100
ab3721
+++ sysstat-10.1.5/configure	2016-05-24 18:25:16.209668309 +0200
ab3721
@@ -5388,7 +5388,7 @@ ac_config_files="$ac_config_files man/io
ab3721
 	# File must be renamed
ab3721
 ac_config_files="$ac_config_files man/cifsiostat.1:man/cifsiostat.in"
ab3721
 	# File must be renamed
ab3721
-ac_config_files="$ac_config_files man/nfsiostat.1:man/nfsiostat.in"
ab3721
+ac_config_files="$ac_config_files man/nfsiostat-sysstat.1:man/nfsiostat-sysstat.in"
ab3721
 	# File must be renamed
ab3721
 ac_config_files="$ac_config_files contrib/isag/isag"
ab3721
  # Permissions must be changed
ab3721
@@ -6120,7 +6120,7 @@ do
ab3721
     "man/sysstat.5") CONFIG_FILES="$CONFIG_FILES man/sysstat.5:man/sysstat.in" ;;
ab3721
     "man/iostat.1") CONFIG_FILES="$CONFIG_FILES man/iostat.1:man/iostat.in" ;;
ab3721
     "man/cifsiostat.1") CONFIG_FILES="$CONFIG_FILES man/cifsiostat.1:man/cifsiostat.in" ;;
ab3721
-    "man/nfsiostat.1") CONFIG_FILES="$CONFIG_FILES man/nfsiostat.1:man/nfsiostat.in" ;;
ab3721
+    "man/nfsiostat-sysstat.1") CONFIG_FILES="$CONFIG_FILES man/nfsiostat-sysstat.1:man/nfsiostat-sysstat.in" ;;
ab3721
     "contrib/isag/isag") CONFIG_FILES="$CONFIG_FILES contrib/isag/isag" ;;
ab3721
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
ab3721
 
ab3721
diff -uprN sysstat-10.1.5.orig/configure.in sysstat-10.1.5/configure.in
ab3721
--- sysstat-10.1.5.orig/configure.in	2013-03-13 15:28:17.000000000 +0100
ab3721
+++ sysstat-10.1.5/configure.in	2016-05-24 18:25:16.209668309 +0200
ab3721
@@ -580,7 +580,7 @@ AC_CONFIG_FILES([man/sar.1:man/sar.in])
ab3721
 AC_CONFIG_FILES([man/sysstat.5:man/sysstat.in])	# File must be renamed
ab3721
 AC_CONFIG_FILES([man/iostat.1:man/iostat.in])	# File must be renamed
ab3721
 AC_CONFIG_FILES([man/cifsiostat.1:man/cifsiostat.in])	# File must be renamed
ab3721
-AC_CONFIG_FILES([man/nfsiostat.1:man/nfsiostat.in])	# File must be renamed
ab3721
+AC_CONFIG_FILES([man/nfsiostat-sysstat.1:man/nfsiostat-sysstat.in])	# File must be renamed
ab3721
 AC_CONFIG_FILES([contrib/isag/isag], [chmod +x contrib/isag/isag]) # Permissions must be changed
ab3721
 
ab3721
 AC_OUTPUT(Makefile)
ab3721
diff -uprN sysstat-10.1.5.orig/Makefile.in sysstat-10.1.5/Makefile.in
ab3721
--- sysstat-10.1.5.orig/Makefile.in	2016-05-24 18:33:48.438839524 +0200
ab3721
+++ sysstat-10.1.5/Makefile.in	2016-05-24 18:25:16.209668309 +0200
ab3721
@@ -160,7 +160,7 @@ NLSPOT= $(NLSPO:.po=.pot)
ab3721
 % : %.o
ab3721
 	$(CC) -o $@ $(CFLAGS) $^ $(LFLAGS)
ab3721
 
ab3721
-all: sadc sar sadf iostat mpstat pidstat nfsiostat cifsiostat locales
ab3721
+all: sadc sar sadf iostat mpstat pidstat nfsiostat-sysstat cifsiostat locales
ab3721
 
ab3721
 common.o: common.c version.h common.h ioconf.h sysconfig.h
ab3721
 
ab3721
@@ -229,9 +229,9 @@ mpstat.o: mpstat.c mpstat.h version.h co
ab3721
 
ab3721
 mpstat: mpstat.o librdstats.a libsyscom.a
ab3721
 
ab3721
-nfsiostat.o: nfsiostat.c nfsiostat.h version.h common.h
ab3721
+nfsiostat-sysstat.o: nfsiostat-sysstat.c nfsiostat-sysstat.h version.h common.h
ab3721
 
ab3721
-nfsiostat: nfsiostat.o librdstats.a libsyscom.a
ab3721
+nfsiostat-sysstat: nfsiostat-sysstat.o librdstats.a libsyscom.a
ab3721
 
ab3721
 cifsiostat.o: cifsiostat.c cifsiostat.h version.h common.h
ab3721
 
ab3721
@@ -273,8 +273,8 @@ ifeq ($(INSTALL_DOC),y)
ab3721
 	$(INSTALL_DATA) $(MANGRPARG) man/mpstat.1 $(DESTDIR)$(MAN1_DIR)
ab3721
 	rm -f $(DESTDIR)$(MAN1_DIR)/pidstat.1*
ab3721
 	$(INSTALL_DATA) $(MANGRPARG) man/pidstat.1 $(DESTDIR)$(MAN1_DIR)
ab3721
-	rm -f $(DESTDIR)$(MAN1_DIR)/nfsiostat.1*
ab3721
-	$(INSTALL_DATA) $(MANGRPARG) man/nfsiostat.1 $(DESTDIR)$(MAN1_DIR)
ab3721
+	rm -f $(DESTDIR)$(MAN1_DIR)/nfsiostat-sysstat.1*
ab3721
+	$(INSTALL_DATA) $(MANGRPARG) man/nfsiostat-sysstat.1 $(DESTDIR)$(MAN1_DIR)
ab3721
 	rm -f $(DESTDIR)$(MAN1_DIR)/cifsiostat.1*
ab3721
 	$(INSTALL_DATA) $(MANGRPARG) man/cifsiostat.1 $(DESTDIR)$(MAN1_DIR)
ab3721
 ifeq ($(INSTALL_ISAG),y)
ab3721
@@ -290,7 +290,7 @@ ifeq ($(COMPRESS_MANPG),y)
ab3721
 	$(ZIP) $(DESTDIR)$(MAN1_DIR)/iostat.1
ab3721
 	$(ZIP) $(DESTDIR)$(MAN1_DIR)/mpstat.1
ab3721
 	$(ZIP) $(DESTDIR)$(MAN1_DIR)/pidstat.1
ab3721
-	$(ZIP) $(DESTDIR)$(MAN1_DIR)/nfsiostat.1
ab3721
+	$(ZIP) $(DESTDIR)$(MAN1_DIR)/nfsiostat-sysstat.1
ab3721
 	$(ZIP) $(DESTDIR)$(MAN1_DIR)/cifsiostat.1
ab3721
 ifeq ($(INSTALL_ISAG),y)
ab3721
 	$(ZIP) $(DESTDIR)$(MAN1_DIR)/isag.1
ab3721
@@ -330,7 +330,7 @@ endif
ab3721
 	$(INSTALL_BIN) iostat $(DESTDIR)$(BIN_DIR)
ab3721
 	$(INSTALL_BIN) mpstat $(DESTDIR)$(BIN_DIR)
ab3721
 	$(INSTALL_BIN) pidstat $(DESTDIR)$(BIN_DIR)
ab3721
-	$(INSTALL_BIN) nfsiostat $(DESTDIR)$(BIN_DIR)
ab3721
+	$(INSTALL_BIN) nfsiostat-sysstat $(DESTDIR)$(BIN_DIR)
ab3721
 	$(INSTALL_BIN) cifsiostat $(DESTDIR)$(BIN_DIR)
ab3721
 ifeq ($(INSTALL_ISAG),y)
ab3721
 	$(INSTALL_BIN) contrib/isag/isag $(DESTDIR)$(BIN_DIR)
ab3721
@@ -397,7 +397,7 @@ ifeq ($(INSTALL_DOC),y)
ab3721
 	rm -f $(DESTDIR)$(MAN1_DIR)/iostat.1*
ab3721
 	rm -f $(DESTDIR)$(MAN1_DIR)/mpstat.1*
ab3721
 	rm -f $(DESTDIR)$(MAN1_DIR)/pidstat.1*
ab3721
-	rm -f $(DESTDIR)$(MAN1_DIR)/nfsiostat.1*
ab3721
+	rm -f $(DESTDIR)$(MAN1_DIR)/nfsiostat-sysstat.1*
ab3721
 	rm -f $(DESTDIR)$(MAN1_DIR)/cifsiostat.1*
ab3721
 ifeq ($(INSTALL_ISAG),y)
ab3721
 	rm -f $(DESTDIR)$(MAN1_DIR)/isag.1
ab3721
@@ -425,7 +425,7 @@ uninstall_base: uninstall_man uninstall_
ab3721
 	rm -f $(DESTDIR)$(BIN_DIR)/iostat
ab3721
 	rm -f $(DESTDIR)$(BIN_DIR)/mpstat
ab3721
 	rm -f $(DESTDIR)$(BIN_DIR)/pidstat
ab3721
-	rm -f $(DESTDIR)$(BIN_DIR)/nfsiostat
ab3721
+	rm -f $(DESTDIR)$(BIN_DIR)/nfsiostat-sysstat
ab3721
 	rm -f $(DESTDIR)$(BIN_DIR)/cifsiostat
ab3721
 ifeq ($(INSTALL_ISAG),y)
ab3721
 	rm -f $(DESTDIR)$(BIN_DIR)/isag
ab3721
@@ -487,7 +487,7 @@ po-files:
ab3721
 endif
ab3721
 
ab3721
 clean:
ab3721
-	rm -f sadc sar sadf iostat mpstat pidstat nfsiostat cifsiostat *.o *.a core TAGS
ab3721
+	rm -f sadc sar sadf iostat mpstat pidstat nfsiostat-sysstat cifsiostat *.o *.a core TAGS
ab3721
 	find nls -name "*.gmo" -exec rm -f {} \;
ab3721
 
ab3721
 almost-distclean: clean nls/sysstat.pot
ab3721
@@ -496,7 +496,7 @@ almost-distclean: clean nls/sysstat.pot
ab3721
 	rm -f cron/sysstat.cron.hourly cron/sysstat.crond.sample cron/sysstat.crond.sample.in
ab3721
 	rm -f contrib/isag/isag
ab3721
 	rm -f man/sa1.8 man/sa2.8 man/sadc.8 man/sadf.1 man/sar.1 man/iostat.1 man/sysstat.5
ab3721
-	rm -f man/cifsiostat.1 man/nfsiostat.1
ab3721
+	rm -f man/cifsiostat.1 man/nfsiostat-sysstat.1
ab3721
 	rm -f *.log config.status
ab3721
 	rm -rf autom4te.cache
ab3721
 	rm -f *.save *.old .*.swp data
ab3721
diff -uprN sysstat-10.1.5.orig/man/nfsiostat.in sysstat-10.1.5/man/nfsiostat.in
ab3721
--- sysstat-10.1.5.orig/man/nfsiostat.in	2012-07-13 08:48:55.000000000 +0200
ab3721
+++ sysstat-10.1.5/man/nfsiostat.in	1970-01-01 01:00:00.000000000 +0100
ab3721
@@ -1,175 +0,0 @@
ab3721
-.TH NFSIOSTAT 1 "JULY 2012" Linux "Linux User's Manual" -*- nroff -*-
ab3721
-.SH NAME
ab3721
-nfsiostat \- Report input/output statistics for network filesystems (NFS).
ab3721
-.SH SYNOPSIS
ab3721
-.ie 'yes'@WITH_DEBUG@' \{
ab3721
-.B nfsiostat [ -h ] [ -k | -m ] [ -t ] [ -V ] [ --debuginfo ] [
ab3721
-.I interval
ab3721
-.B [
ab3721
-.I count
ab3721
-.B ] ]
ab3721
-.\}
ab3721
-.el \{
ab3721
-.B nfsiostat [ -h ] [ -k | -m ] [ -t ] [ -V ] [
ab3721
-.I interval
ab3721
-.B [
ab3721
-.I count
ab3721
-.B ] ]
ab3721
-.\}
ab3721
-.SH DESCRIPTION
ab3721
-The
ab3721
-.B nfsiostat
ab3721
-command displays statistics about read and write operations
ab3721
-on NFS filesystems.
ab3721
-
ab3721
-The
ab3721
-.I interval
ab3721
-parameter specifies the amount of time in seconds between
ab3721
-each report. The first report contains statistics for the time since
ab3721
-system startup (boot). Each subsequent report contains statistics
ab3721
-collected during the interval since the previous report.
ab3721
-A report consists of an NFS header row followed by
ab3721
-a line of statistics for each network filesystem that is mounted.
ab3721
-The
ab3721
-.I count
ab3721
-parameter can be specified in conjunction with the
ab3721
-.I interval
ab3721
-parameter. If the
ab3721
-.I count
ab3721
-parameter is specified, the value of
ab3721
-.I count
ab3721
-determines the number of reports generated at
ab3721
-.I interval
ab3721
-seconds apart. If the
ab3721
-.I interval
ab3721
-parameter is specified without the
ab3721
-.I count
ab3721
-parameter, the
ab3721
-.B nfsiostat
ab3721
-command generates reports continuously.
ab3721
-
ab3721
-.SH REPORT
ab3721
-The Network Filesystem (NFS) report provides statistics for each mounted network filesystem.
ab3721
-Transfer rates are shown in 1K blocks by default, unless the environment
ab3721
-variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.
ab3721
-The report shows the following fields:
ab3721
-
ab3721
-.B Filesystem:
ab3721
-.RS
ab3721
-This columns shows the hostname of the NFS server followed by a colon and
ab3721
-by the directory name where the network filesystem is mounted.
ab3721
-
ab3721
-.RE
ab3721
-.B rBlk_nor/s (rkB_nor/s, rMB_nor)
ab3721
-.RS
ab3721
-Indicate the number of blocks (kilobytes, megabytes) read by applications
ab3721
-via the read(2) system
ab3721
-call interface. A block has a size of 512 bytes.
ab3721
-
ab3721
-.RE
ab3721
-.B wBlk_nor/s (wkB_nor/s, wMB_nor/s)
ab3721
-.RS
ab3721
-Indicate the number of blocks (kilobytes, megabytes) written by applications
ab3721
-via the write(2) system
ab3721
-call interface.
ab3721
-
ab3721
-.RE
ab3721
-.B rBlk_dir/s (rkB_dir/s, rMB_dir/s)
ab3721
-.RS
ab3721
-Indicate the number of blocks (kilobytes, megabytes) read from files
ab3721
-opened with the O_DIRECT flag.
ab3721
-
ab3721
-.RE
ab3721
-.B wBlk_dir/s (wkB_dir/s, wMB_dir/s)
ab3721
-.RS
ab3721
-Indicate the number of blocks (kilobytes, megabytes) written to files
ab3721
-opened with the O_DIRECT flag.
ab3721
-
ab3721
-.RE
ab3721
-.B rBlk_svr/s (rkB_svr/s, rMB_svr/s)
ab3721
-.RS
ab3721
-Indicate the number of blocks (kilobytes, megabytes) read from the server
ab3721
-by the NFS client via an NFS READ request.
ab3721
-
ab3721
-.RE
ab3721
-.B wBlk_svr/s (wkB_svr/s, wMB_svr/s)
ab3721
-.RS
ab3721
-Indicate the number of blocks (kilobytes, megabytes) written to the server
ab3721
-by the NFS client via an NFS WRITE request.
ab3721
-
ab3721
-.RE
ab3721
-.B ops/s
ab3721
-.RS
ab3721
-Indicate the number of operations that were issued to the filesystem per second.
ab3721
-
ab3721
-.RE
ab3721
-.B rops/s
ab3721
-.RS
ab3721
-Indicate the number of 'read' operations that were issued to the filesystem 
ab3721
-per second.
ab3721
-
ab3721
-.RE
ab3721
-.B wops/s
ab3721
-.RS
ab3721
-Indicate the number of 'write' operations that were issued to the filesystem
ab3721
-per second.
ab3721
-.RE
ab3721
-.RE
ab3721
-.SH OPTIONS
ab3721
-.if 'yes'@WITH_DEBUG@' \{
ab3721
-.IP --debuginfo
ab3721
-Print debug output to stderr.
ab3721
-.\}
ab3721
-.IP -h
ab3721
-Make the NFS report easier to read by a human.
ab3721
-.IP -k
ab3721
-Display statistics in kilobytes per second.
ab3721
-.IP -m
ab3721
-Display statistics in megabytes per second.
ab3721
-.IP -t
ab3721
-Print the time for each report displayed. The timestamp format may depend
ab3721
-on the value of the S_TIME_FORMAT environment variable (see below).
ab3721
-.IP -V
ab3721
-Print version number then exit.
ab3721
-
ab3721
-.SH ENVIRONMENT
ab3721
-The
ab3721
-.B nfsiostat
ab3721
-command takes into account the following environment variables:
ab3721
-
ab3721
-.IP S_TIME_FORMAT
ab3721
-If this variable exists and its value is
ab3721
-.BR ISO
ab3721
-then the current locale will be ignored when printing the date in the report
ab3721
-header. The
ab3721
-.B nfsiostat
ab3721
-command will use the ISO 8601 format (YYYY-MM-DD) instead.
ab3721
-The timestamp displayed with option -t will also be compliant with ISO 8601
ab3721
-format.
ab3721
-
ab3721
-.IP POSIXLY_CORRECT
ab3721
-When this variable is set, transfer rates are shown in 512-byte blocks instead
ab3721
-of the default 1K blocks.
ab3721
-
ab3721
-.SH BUG
ab3721
-.I /proc
ab3721
-filesystem must be mounted for
ab3721
-.B nfsiostat
ab3721
-to work.
ab3721
-
ab3721
-.SH FILE
ab3721
-.I /proc/self/mountstats
ab3721
-contains statistics for network filesystems.
ab3721
-.SH AUTHORS
ab3721
-Written by Ivana Varekova (varekova <at> redhat.com)
ab3721
-
ab3721
-Maintained by Sebastien Godard (sysstat <at> orange.fr)
ab3721
-.SH SEE ALSO
ab3721
-.BR sar (1),
ab3721
-.BR pidstat (1),
ab3721
-.BR mpstat (1),
ab3721
-.BR vmstat (8),
ab3721
-.BR iostat (1),
ab3721
-.BR cifsiostat (1)
ab3721
-
ab3721
-.I http://pagesperso-orange.fr/sebastien.godard/
ab3721
diff -uprN sysstat-10.1.5.orig/man/nfsiostat-sysstat.in sysstat-10.1.5/man/nfsiostat-sysstat.in
ab3721
--- sysstat-10.1.5.orig/man/nfsiostat-sysstat.in	1970-01-01 01:00:00.000000000 +0100
ab3721
+++ sysstat-10.1.5/man/nfsiostat-sysstat.in	2016-05-24 18:25:16.209668309 +0200
ab3721
@@ -0,0 +1,187 @@
ab3721
+.TH NFSIOSTAT-SYSSTAT 1 "JANUARY 2014" Linux "Linux User's Manual" -*- nroff -*-
ab3721
+.SH NAME
ab3721
+nfsiostat-sysstat (the nfsiostat command from the sysstat package) \- Report input/output statistics for network filesystems (NFS).
ab3721
+.SH SYNOPSIS
ab3721
+.ie 'yes'@WITH_DEBUG@' \{
ab3721
+.B nfsiostat-sysstat [ -h ] [ -k | -m ] [ -t ] [ -V ] [ --debuginfo ] [
ab3721
+.I interval
ab3721
+.B [
ab3721
+.I count
ab3721
+.B ] ]
ab3721
+.\}
ab3721
+.el \{
ab3721
+.B nfsiostat-sysstat [ -h ] [ -k | -m ] [ -t ] [ -V ] [
ab3721
+.I interval
ab3721
+.B [
ab3721
+.I count
ab3721
+.B ] ]
ab3721
+.\}
ab3721
+.SH DESCRIPTION
ab3721
+The
ab3721
+.B nfsiostat-sysstat
ab3721
+command displays statistics about read and write operations
ab3721
+on NFS filesystems.
ab3721
+
ab3721
+The
ab3721
+.I interval
ab3721
+parameter specifies the amount of time in seconds between
ab3721
+each report. The first report contains statistics for the time since
ab3721
+system startup (boot). Each subsequent report contains statistics
ab3721
+collected during the interval since the previous report.
ab3721
+A report consists of an NFS header row followed by
ab3721
+a line of statistics for each network filesystem that is mounted.
ab3721
+The
ab3721
+.I count
ab3721
+parameter can be specified in conjunction with the
ab3721
+.I interval
ab3721
+parameter. If the
ab3721
+.I count
ab3721
+parameter is specified, the value of
ab3721
+.I count
ab3721
+determines the number of reports generated at
ab3721
+.I interval
ab3721
+seconds apart. If the
ab3721
+.I interval
ab3721
+parameter is specified without the
ab3721
+.I count
ab3721
+parameter, the
ab3721
+.B nfsiostat-sysstat
ab3721
+command generates reports continuously.
ab3721
+
ab3721
+.SH REPORT
ab3721
+The Network Filesystem (NFS) report provides statistics for each mounted network filesystem.
ab3721
+Transfer rates are shown in 1K blocks by default, unless the environment
ab3721
+variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.
ab3721
+The report shows the following fields:
ab3721
+
ab3721
+.B Filesystem:
ab3721
+.RS
ab3721
+This columns shows the hostname of the NFS server followed by a colon and
ab3721
+by the directory name where the network filesystem is mounted.
ab3721
+
ab3721
+.RE
ab3721
+.B rBlk_nor/s (rkB_nor/s, rMB_nor)
ab3721
+.RS
ab3721
+Indicate the number of blocks (kilobytes, megabytes) read by applications
ab3721
+via the read(2) system
ab3721
+call interface. A block has a size of 512 bytes.
ab3721
+
ab3721
+.RE
ab3721
+.B wBlk_nor/s (wkB_nor/s, wMB_nor/s)
ab3721
+.RS
ab3721
+Indicate the number of blocks (kilobytes, megabytes) written by applications
ab3721
+via the write(2) system
ab3721
+call interface.
ab3721
+
ab3721
+.RE
ab3721
+.B rBlk_dir/s (rkB_dir/s, rMB_dir/s)
ab3721
+.RS
ab3721
+Indicate the number of blocks (kilobytes, megabytes) read from files
ab3721
+opened with the O_DIRECT flag.
ab3721
+
ab3721
+.RE
ab3721
+.B wBlk_dir/s (wkB_dir/s, wMB_dir/s)
ab3721
+.RS
ab3721
+Indicate the number of blocks (kilobytes, megabytes) written to files
ab3721
+opened with the O_DIRECT flag.
ab3721
+
ab3721
+.RE
ab3721
+.B rBlk_svr/s (rkB_svr/s, rMB_svr/s)
ab3721
+.RS
ab3721
+Indicate the number of blocks (kilobytes, megabytes) read from the server
ab3721
+by the NFS client via an NFS READ request.
ab3721
+
ab3721
+.RE
ab3721
+.B wBlk_svr/s (wkB_svr/s, wMB_svr/s)
ab3721
+.RS
ab3721
+Indicate the number of blocks (kilobytes, megabytes) written to the server
ab3721
+by the NFS client via an NFS WRITE request.
ab3721
+
ab3721
+.RE
ab3721
+.B ops/s
ab3721
+.RS
ab3721
+Indicate the number of operations that were issued to the filesystem per second.
ab3721
+
ab3721
+.RE
ab3721
+.B rops/s
ab3721
+.RS
ab3721
+Indicate the number of 'read' operations that were issued to the filesystem 
ab3721
+per second.
ab3721
+
ab3721
+.RE
ab3721
+.B wops/s
ab3721
+.RS
ab3721
+Indicate the number of 'write' operations that were issued to the filesystem
ab3721
+per second.
ab3721
+.RE
ab3721
+.RE
ab3721
+.SH OPTIONS
ab3721
+.if 'yes'@WITH_DEBUG@' \{
ab3721
+.IP --debuginfo
ab3721
+Print debug output to stderr.
ab3721
+.\}
ab3721
+.IP -h
ab3721
+Make the NFS report easier to read by a human.
ab3721
+.IP -k
ab3721
+Display statistics in kilobytes per second.
ab3721
+.IP -m
ab3721
+Display statistics in megabytes per second.
ab3721
+.IP -t
ab3721
+Print the time for each report displayed. The timestamp format may depend
ab3721
+on the value of the S_TIME_FORMAT environment variable (see below).
ab3721
+.IP -V
ab3721
+Print version number then exit.
ab3721
+
ab3721
+.SH ENVIRONMENT
ab3721
+The
ab3721
+.B nfsiostat-sysstat
ab3721
+command takes into account the following environment variables:
ab3721
+
ab3721
+.IP S_TIME_FORMAT
ab3721
+If this variable exists and its value is
ab3721
+.BR ISO
ab3721
+then the current locale will be ignored when printing the date in the report
ab3721
+header. The
ab3721
+.B nfsiostat-sysstat
ab3721
+command will use the ISO 8601 format (YYYY-MM-DD) instead.
ab3721
+The timestamp displayed with option -t will also be compliant with ISO 8601
ab3721
+format.
ab3721
+
ab3721
+.IP POSIXLY_CORRECT
ab3721
+When this variable is set, transfer rates are shown in 512-byte blocks instead
ab3721
+of the default 1K blocks.
ab3721
+
ab3721
+.SH BUG
ab3721
+.I /proc
ab3721
+filesystem must be mounted for
ab3721
+.B nfsiostat-sysstat
ab3721
+to work.
ab3721
+
ab3721
+.SH FILE
ab3721
+.I /proc/self/mountstats
ab3721
+contains statistics for network filesystems.
ab3721
+
ab3721
+.SH WARNING
ab3721
+The nfsiostat
ab3721
+command from the sysstat package (nfsiostat-sysstat) is now obsolete and is no longer maintained.
ab3721
+It will be removed in a future sysstat version.
ab3721
+Please use now the
ab3721
+.B nfsiostat
ab3721
+command from the
ab3721
+.I nfs-utils
ab3721
+package.
ab3721
+
ab3721
+.SH AUTHORS
ab3721
+Written by Ivana Varekova (varekova <at> redhat.com)
ab3721
+
ab3721
+Maintained by Sebastien Godard (sysstat <at> orange.fr)
ab3721
+.SH SEE ALSO
ab3721
+.BR nfsiostat (8),
ab3721
+.BR sar (1),
ab3721
+.BR pidstat (1),
ab3721
+.BR mpstat (1),
ab3721
+.BR vmstat (8),
ab3721
+.BR iostat (1),
ab3721
+.BR cifsiostat (1)
ab3721
+
ab3721
+.I http://pagesperso-orange.fr/sebastien.godard/
ab3721
diff -uprN sysstat-10.1.5.orig/nfsiostat.c sysstat-10.1.5/nfsiostat.c
ab3721
--- sysstat-10.1.5.orig/nfsiostat.c	2016-05-24 18:33:48.444839516 +0200
ab3721
+++ sysstat-10.1.5/nfsiostat.c	1970-01-01 01:00:00.000000000 +0100
ab3721
@@ -1,747 +0,0 @@
ab3721
-/*
ab3721
- * nfsiostat: Report NFS I/O statistics
ab3721
- * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved
ab3721
- * Written by Ivana Varekova <varekova@redhat.com>
ab3721
- *
ab3721
- ***************************************************************************
ab3721
- * This program is free software; you can redistribute it and/or modify it *
ab3721
- * under the terms of the GNU General Public License as published  by  the *
ab3721
- * Free Software Foundation; either version 2 of the License, or (at  your *
ab3721
- * option) any later version.                                              *
ab3721
- *                                                                         *
ab3721
- * This program is distributed in the hope that it  will  be  useful,  but *
ab3721
- * WITHOUT ANY WARRANTY; without the implied warranty  of  MERCHANTABILITY *
ab3721
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
ab3721
- * for more details.                                                       *
ab3721
- *                                                                         *
ab3721
- * You should have received a copy of the GNU General Public License along *
ab3721
- * with this program; if not, write to the Free Software Foundation, Inc., *
ab3721
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                   *
ab3721
- ***************************************************************************
ab3721
- */
ab3721
-
ab3721
-#include <stdio.h>
ab3721
-#include <string.h>
ab3721
-#include <stdlib.h>
ab3721
-#include <unistd.h>
ab3721
-#include <signal.h>
ab3721
-#include <sys/utsname.h>
ab3721
-
ab3721
-#include "version.h"
ab3721
-#include "nfsiostat.h"
ab3721
-#include "common.h"
ab3721
-
ab3721
-#ifdef USE_NLS
ab3721
-#include <locale.h>
ab3721
-#include <libintl.h>
ab3721
-#define _(string) gettext(string)
ab3721
-#else
ab3721
-#define _(string) (string)
ab3721
-#endif
ab3721
-
ab3721
-#define SCCSID "@(#)sysstat-" VERSION ": " __FILE__ " compiled " __DATE__ " " __TIME__
ab3721
-char *sccsid(void) { return (SCCSID); }
ab3721
-
ab3721
-unsigned long long uptime0[2] = {0, 0};
ab3721
-struct io_nfs_stats *st_ionfs[2];
ab3721
-struct io_hdr_stats *st_hdr_ionfs;
ab3721
-
ab3721
-int ionfs_nr = 0;	/* Nb of NFS mounted directories found */
ab3721
-int cpu_nr = 0;		/* Nb of processors on the machine */
ab3721
-int flags = 0;		/* Flag for common options and system state */
ab3721
-
ab3721
-long interval = 0;
ab3721
-char timestamp[64];
ab3721
-
ab3721
-struct sigaction alrm_act;
ab3721
-
ab3721
-/*
ab3721
- ***************************************************************************
ab3721
- * Print usage and exit.
ab3721
- *
ab3721
- * IN:
ab3721
- * @progname	Name of sysstat command.
ab3721
- ***************************************************************************
ab3721
- */
ab3721
-void usage(char *progname)
ab3721
-{
ab3721
-	fprintf(stderr, _("Usage: %s [ options ] [ <interval> [ <count> ] ]\n"),
ab3721
-		progname);
ab3721
-
ab3721
-#ifdef DEBUG
ab3721
-	fprintf(stderr, _("Options are:\n"
ab3721
-			  "[ -h ] [ -k | -m ] [ -t ] [ -V ] [ --debuginfo ]\n"));
ab3721
-#else
ab3721
-	fprintf(stderr, _("Options are:\n"
ab3721
-			  "[ -h ] [ -k | -m ] [ -t ] [ -V ]\n"));
ab3721
-#endif
ab3721
-	exit(1);
ab3721
-}
ab3721
-
ab3721
-/*
ab3721
- ***************************************************************************
ab3721
- * Set output unit. Unit will be kB/s unless POSIXLY_CORRECT
ab3721
- * environment variable has been set, in which case the output will be
ab3721
- * expressed in blocks/s.
ab3721
- ***************************************************************************
ab3721
- */
ab3721
-void set_output_unit(void)
ab3721
-{
ab3721
-	char *e;
ab3721
-
ab3721
-	if (DISPLAY_KILOBYTES(flags) || DISPLAY_MEGABYTES(flags))
ab3721
-		return;
ab3721
-
ab3721
-	/* Check POSIXLY_CORRECT environment variable */
ab3721
-	if ((e = getenv(ENV_POSIXLY_CORRECT)) == NULL) {
ab3721
-		/* Variable not set: Unit is kB/s and not blocks/s */
ab3721
-		flags |= I_D_KILOBYTES;
ab3721
-	}
ab3721
-}
ab3721
-
ab3721
-/*
ab3721
- ***************************************************************************
ab3721
- * SIGALRM signal handler.
ab3721
- *
ab3721
- * IN:
ab3721
- * @sig	Signal number.
ab3721
- ***************************************************************************
ab3721
- */
ab3721
-void alarm_handler(int sig)
ab3721
-{
ab3721
-	alarm(interval);
ab3721
-}
ab3721
-
ab3721
-/*
ab3721
- ***************************************************************************
ab3721
- * Find number of NFS-mounted points that are registered in
ab3721
- * /proc/self/mountstats.
ab3721
- *
ab3721
- * RETURNS:
ab3721
- * Number of NFS-mounted points.
ab3721
- ***************************************************************************
ab3721
- */
ab3721
-int get_nfs_mount_nr(void)
ab3721
-{
ab3721
-	FILE *fp;
ab3721
-	char line[8192];
ab3721
-	char type_name[10];
ab3721
-	unsigned int nfs = 0;
ab3721
-
ab3721
-	if ((fp = fopen(NFSMOUNTSTATS, "r")) == NULL)
ab3721
-		/* File non-existent */
ab3721
-		return 0;
ab3721
-
ab3721
-	while (fgets(line, 8192, fp) != NULL) {
ab3721
-
ab3721
-		if ((strstr(line, "mounted")) && (strstr(line, "on")) &&
ab3721
-		    (strstr(line, "with")) && (strstr(line, "fstype"))) {
ab3721
-
ab3721
-			sscanf(strstr(line, "fstype") + 6, "%9s", type_name);
ab3721
-			if ((!strncmp(type_name, "nfs", 3)) && (strncmp(type_name, "nfsd", 4))) {
ab3721
-				nfs ++;
ab3721
-			}
ab3721
-		}
ab3721
-	}
ab3721
-
ab3721
-	fclose(fp);
ab3721
-
ab3721
-	return nfs;
ab3721
-}
ab3721
-
ab3721
-/*
ab3721
- ***************************************************************************
ab3721
- * Set every nfs_io entry to inactive state (unregistered).
ab3721
- ***************************************************************************
ab3721
- */
ab3721
-void set_entries_inactive(void)
ab3721
-{
ab3721
-	int i;
ab3721
-	struct io_hdr_stats *shi = st_hdr_ionfs;
ab3721
-
ab3721
-	for (i = 0; i < ionfs_nr; i++, shi++) {
ab3721
-		shi->active = FALSE;
ab3721
-	}
ab3721
-}
ab3721
-
ab3721
-/*
ab3721
- ***************************************************************************
ab3721
- * Free inactive entries (mark them as unused).
ab3721
- ***************************************************************************
ab3721
- */
ab3721
-void free_inactive_entries(void)
ab3721
-{
ab3721
-	int i;
ab3721
-	struct io_hdr_stats *shi = st_hdr_ionfs;
ab3721
-
ab3721
-	for (i = 0; i < ionfs_nr; i++, shi++) {
ab3721
-		if (!shi->active) {
ab3721
-			shi->used = FALSE;
ab3721
-		}
ab3721
-	}
ab3721
-}
ab3721
-
ab3721
-/*
ab3721
- ***************************************************************************
ab3721
- * Allocate and init structures, according to system state.
ab3721
- ***************************************************************************
ab3721
- */
ab3721
-void io_sys_init(void)
ab3721
-{
ab3721
-	int i;
ab3721
-	
ab3721
-	/* How many processors on this machine? */
ab3721
-	cpu_nr = get_cpu_nr(~0);
ab3721
-
ab3721
-	/* Get number of NFS directories in /proc/self/mountstats */
ab3721
-	if ((ionfs_nr = get_nfs_mount_nr()) > 0) {
ab3721
-		ionfs_nr += NR_NFS_PREALLOC;
ab3721
-	}
ab3721
-	if ((st_hdr_ionfs = (struct io_hdr_stats *) calloc(ionfs_nr, IO_HDR_STATS_SIZE)) == NULL) {
ab3721
-		perror("malloc");
ab3721
-		exit(4);
ab3721
-	}
ab3721
-	
ab3721
-	/* Allocate structures for number of NFS directories found */
ab3721
-	for (i = 0; i < 2; i++) {
ab3721
-		if ((st_ionfs[i] =
ab3721
-		    (struct io_nfs_stats *) calloc(ionfs_nr, IO_NFS_STATS_SIZE)) == NULL) {
ab3721
-			perror("malloc");
ab3721
-			exit(4);
ab3721
-		}
ab3721
-	}
ab3721
-}
ab3721
-
ab3721
-/*
ab3721
- ***************************************************************************
ab3721
- * Free various structures.
ab3721
- ***************************************************************************
ab3721
-*/
ab3721
-void io_sys_free(void)
ab3721
-{
ab3721
-	int i;
ab3721
-
ab3721
-	/* Free I/O NFS directories structures */
ab3721
-	for (i = 0; i < 2; i++) {
ab3721
-
ab3721
-		if (st_ionfs[i]) {
ab3721
-			free(st_ionfs[i]);
ab3721
-		}
ab3721
-	}
ab3721
-	
ab3721
-	if (st_hdr_ionfs) {
ab3721
-		free(st_hdr_ionfs);
ab3721
-	}
ab3721
-}
ab3721
-
ab3721
-/*
ab3721
- ***************************************************************************
ab3721
- * Save stats for current NFS filesystem.
ab3721
- *
ab3721
- * IN:
ab3721
- * @name		Name of NFS filesystem.
ab3721
- * @curr		Index in array for current sample statistics.
ab3721
- * @st_io		Structure with NFS statistics to save.
ab3721
- * @ionfs_nr		Number of NFS filesystems.
ab3721
- * @st_hdr_ionfs	Pointer on structures describing an NFS filesystem.
ab3721
- *
ab3721
- * OUT:
ab3721
- * @st_hdr_ionfs	Pointer on structures describing an NFS filesystem.
ab3721
- ***************************************************************************
ab3721
- */
ab3721
-void save_stats(char *name, int curr, void *st_io)
ab3721
-{
ab3721
-	int i, j;
ab3721
-	struct io_hdr_stats *st_hdr_ionfs_i;
ab3721
-	struct io_nfs_stats *st_ionfs_i;
ab3721
-
ab3721
-	/* Look for NFS directory in data table */
ab3721
-	for (i = 0; i < ionfs_nr; i++) {
ab3721
-		st_hdr_ionfs_i = st_hdr_ionfs + i;
ab3721
-		if ((st_hdr_ionfs_i->used) &&
ab3721
-		    (!strcmp(st_hdr_ionfs_i->name, name))) {
ab3721
-			break;
ab3721
-		}
ab3721
-	}
ab3721
-
ab3721
-	if (i == ionfs_nr) {
ab3721
-		/*
ab3721
-		 * This is a new filesystem: Look for an unused entry to store it.
ab3721
-		 */
ab3721
-		for (i = 0; i < ionfs_nr; i++) {
ab3721
-			st_hdr_ionfs_i = st_hdr_ionfs + i;
ab3721
-			if (!st_hdr_ionfs_i->used) {
ab3721
-				/* Unused entry found... */
ab3721
-				st_hdr_ionfs_i->used = TRUE; /* Indicate it is now used */
ab3721
-				st_hdr_ionfs_i->active = TRUE;
ab3721
-
ab3721
-				strcpy(st_hdr_ionfs_i->name, name);
ab3721
-				st_ionfs_i = st_ionfs[curr] + i;
ab3721
-				memset(st_ionfs_i, 0, IO_NFS_STATS_SIZE);
ab3721
-				*st_ionfs_i = *((struct io_nfs_stats *) st_io);
ab3721
-				break;
ab3721
-			}
ab3721
-		}
ab3721
-		if (i == ionfs_nr) {
ab3721
-			/* All entries are used: The number has to be increased */
ab3721
-			ionfs_nr = ionfs_nr + 5;
ab3721
-
ab3721
-			/* Increase the size of st_hdr_ionfs buffer */
ab3721
-			if ((st_hdr_ionfs = (struct io_hdr_stats *)
ab3721
-				realloc(st_hdr_ionfs, ionfs_nr * IO_HDR_STATS_SIZE)) == NULL) {
ab3721
-				perror("malloc");
ab3721
-				exit(4);
ab3721
-			}
ab3721
-
ab3721
-			/* Set the new entries inactive */
ab3721
-			for (j = 0; j < 5; j++) {
ab3721
-				st_hdr_ionfs_i = st_hdr_ionfs + i + j;
ab3721
-				st_hdr_ionfs_i->used = FALSE;
ab3721
-				st_hdr_ionfs_i->active = FALSE;
ab3721
-			}
ab3721
-
ab3721
-			/* Increase the size of st_hdr_ionfs buffer */
ab3721
-			for (j = 0; j < 2; j++) {
ab3721
-				if ((st_ionfs[j] = (struct io_nfs_stats *)
ab3721
-					realloc(st_ionfs[j], ionfs_nr * IO_NFS_STATS_SIZE)) == NULL) {
ab3721
-					perror("malloc");
ab3721
-					exit(4);
ab3721
-				}
ab3721
-				memset(st_ionfs[j] + i, 0, 5 * IO_NFS_STATS_SIZE);
ab3721
-			}
ab3721
-
ab3721
-			/* Now i shows the first unused entry of the new block */
ab3721
-			st_hdr_ionfs_i = st_hdr_ionfs + i;
ab3721
-			st_hdr_ionfs_i->used = TRUE; /* Indicate it is now used */
ab3721
-			strcpy(st_hdr_ionfs_i->name, name);
ab3721
-			st_ionfs_i = st_ionfs[curr] + i;
ab3721
-			memset(st_ionfs_i, 0, IO_NFS_STATS_SIZE);
ab3721
-		}
ab3721
-	} else  {
ab3721
-		st_hdr_ionfs_i = st_hdr_ionfs + i;
ab3721
-		st_hdr_ionfs_i->used = TRUE;
ab3721
-		st_hdr_ionfs_i->active = TRUE;
ab3721
-		st_ionfs_i = st_ionfs[curr] + i;
ab3721
-		*st_ionfs_i = *((struct io_nfs_stats *) st_io);
ab3721
-	}
ab3721
-	/*
ab3721
-	 * else it was a new NFS directory
ab3721
-	 * but there was no free structure to store it.
ab3721
-	 */
ab3721
-}
ab3721
-
ab3721
-/*
ab3721
- ***************************************************************************
ab3721
- * Read NFS-mount directories stats from /proc/self/mountstats.
ab3721
- *
ab3721
- * IN:
ab3721
- * @curr	Index in array for current sample statistics.
ab3721
- ***************************************************************************
ab3721
- */
ab3721
-void read_nfs_stat(int curr)
ab3721
-{
ab3721
-	FILE *fp;
ab3721
-	int sw = 0;
ab3721
-	char line[256];
ab3721
-	char *xprt_line;
ab3721
-	char *mount_part;
ab3721
-	char nfs_name[MAX_NAME_LEN];
ab3721
-	char mount[10], on[10], prefix[10], aux[32];
ab3721
-	char operation[16];
ab3721
-	struct io_nfs_stats snfs;
ab3721
-	long int v1;
ab3721
-
ab3721
-	/* Every I/O NFS entry is potentially unregistered */
ab3721
-	set_entries_inactive();
ab3721
-
ab3721
-	if ((fp = fopen(NFSMOUNTSTATS, "r")) == NULL)
ab3721
-		return;
ab3721
-
ab3721
-	sprintf(aux, "%%%ds",
ab3721
-		MAX_NAME_LEN < 200 ? MAX_NAME_LEN-1 : 200);
ab3721
-
ab3721
-	while (fgets(line, 256, fp) != NULL) {
ab3721
-		/* Read NFS directory name */
ab3721
-		if (!strncmp(line, "device", 6)) {
ab3721
-			sw = 0;
ab3721
-			sscanf(line + 6, aux, nfs_name);
ab3721
-			mount_part = strchr(line + 7, ' ');
ab3721
-			if (mount_part != NULL) {
ab3721
-				sscanf(mount_part, "%9s %9s", mount, on);
ab3721
-				if ((!strncmp(mount, "mounted", 7)) && (!strncmp(on, "on", 2))) {
ab3721
-					sw = 1;
ab3721
-				}
ab3721
-			}
ab3721
-		}
ab3721
-
ab3721
-		sscanf(line, "%9s", prefix);
ab3721
-		if (sw && (!strncmp(prefix, "bytes:", 6))) {
ab3721
-			/* Read the stats for the last NFS-mounted directory */
ab3721
-			sscanf(strstr(line, "bytes:") + 6, "%llu %llu %llu %llu %llu %llu",
ab3721
-			       &snfs.rd_normal_bytes, &snfs.wr_normal_bytes,
ab3721
-			       &snfs.rd_direct_bytes, &snfs.wr_direct_bytes,
ab3721
-			       &snfs.rd_server_bytes, &snfs.wr_server_bytes);
ab3721
-			sw = 2;
ab3721
-		}
ab3721
-
ab3721
-		if ((sw == 2) && (!strncmp(prefix, "xprt:", 5))) {
ab3721
-			/*
ab3721
-			 * Read extended statistic for the last NFS-mounted directory
ab3721
-			 * - number of sent rpc requests.
ab3721
-			 */
ab3721
-			xprt_line = (strstr(line, "xprt:") + 6);
ab3721
-			/* udp, tcp or rdma data */
ab3721
-			if (!strncmp(xprt_line, "udp", 3)) {
ab3721
-				/* port bind_count sends recvs (bad_xids req_u bklog_u) */
ab3721
-				sscanf(strstr(xprt_line, "udp") + 4, "%*u %*u %lu",
ab3721
-				       &snfs.rpc_sends);
ab3721
-			}
ab3721
-			if (!strncmp(xprt_line, "tcp", 3)) {
ab3721
-				/*
ab3721
-				 * port bind_counter connect_count connect_time idle_time
ab3721
-				 * sends recvs (bad_xids req_u bklog_u)
ab3721
-				 */
ab3721
-				sscanf(strstr(xprt_line, "tcp") + 4,
ab3721
-				       "%*u %*u %*u %*u %*d %lu",
ab3721
-				       &snfs.rpc_sends);
ab3721
-			}
ab3721
-			if (!strncmp(xprt_line,"rdma", 4)) {
ab3721
-				/*
ab3721
-				 * 0(port) bind_count connect_count connect_time idle_time
ab3721
-				 * sends recvs (bad_xids req_u bklog_u...)
ab3721
-				 */
ab3721
-				sscanf(strstr(xprt_line, "rdma") + 5,
ab3721
-				       "%*u %*u %*u %*u %*d %lu",
ab3721
-				       &snfs.rpc_sends);
ab3721
-			}
ab3721
-			sw = 3;
ab3721
-		}
ab3721
-
ab3721
-		if ((sw == 3) && (!strncmp(prefix, "per-op", 6))) {
ab3721
-			sw = 4;
ab3721
-			while (sw == 4) {
ab3721
-				fgets(line, 256, fp);
ab3721
-				sscanf(line, "%15s %lu", operation, &v1;;
ab3721
-				if (!strncmp(operation, "READ:", 5)) {
ab3721
-					snfs.nfs_rops = v1;
ab3721
-				}
ab3721
-				else if (!strncmp(operation, "WRITE:", 6)) {
ab3721
-					snfs.nfs_wops = v1;
ab3721
-
ab3721
-					save_stats(nfs_name, curr, &snfs);
ab3721
-					sw = 0;
ab3721
-				}
ab3721
-			}
ab3721
-		}
ab3721
-	}
ab3721
-
ab3721
-	fclose(fp);
ab3721
-
ab3721
-	/* Free structures corresponding to unregistered filesystems */
ab3721
-	free_inactive_entries();
ab3721
-}
ab3721
-
ab3721
-/*
ab3721
- ***************************************************************************
ab3721
- * Display NFS stats header.
ab3721
- *
ab3721
- * OUT:
ab3721
- * @fctr	Conversion factor.
ab3721
- ***************************************************************************
ab3721
- */
ab3721
-void write_nfs_stat_header(int *fctr)
ab3721
-{
ab3721
-	printf("Filesystem:           ");
ab3721
-	if (DISPLAY_KILOBYTES(flags)) {
ab3721
-		printf("    rkB_nor/s    wkB_nor/s    rkB_dir/s    wkB_dir/s"
ab3721
-		       "    rkB_svr/s    wkB_svr/s");
ab3721
-		*fctr = 1024;
ab3721
-	}
ab3721
-	else if (DISPLAY_MEGABYTES(flags)) {
ab3721
-		printf("    rMB_nor/s    wMB_nor/s    rMB_dir/s    wMB_dir/s"
ab3721
-		       "    rMB_svr/s    wMB_svr/s");
ab3721
-		*fctr = 1024 * 1024;
ab3721
-	}
ab3721
-	else {
ab3721
-		printf("   rBlk_nor/s   wBlk_nor/s   rBlk_dir/s   wBlk_dir/s"
ab3721
-		       "   rBlk_svr/s   wBlk_svr/s");
ab3721
-		*fctr = 512;
ab3721
-	}
ab3721
-	printf("     ops/s    rops/s    wops/s\n");
ab3721
-}
ab3721
-
ab3721
-/*
ab3721
- ***************************************************************************
ab3721
- * Write NFS stats read from /proc/self/mountstats.
ab3721
- *
ab3721
- * IN:
ab3721
- * @curr	Index in array for current sample statistics.
ab3721
- * @itv		Interval of time.
ab3721
- * @fctr	Conversion factor.
ab3721
- * @shi		Structures describing the NFS filesystems.
ab3721
- * @ioi		Current sample statistics.
ab3721
- * @ioj		Previous sample statistics.
ab3721
- ***************************************************************************
ab3721
- */
ab3721
-void write_nfs_stat(int curr, unsigned long long itv, int fctr,
ab3721
-		    struct io_hdr_stats *shi, struct io_nfs_stats *ioni,
ab3721
-		    struct io_nfs_stats *ionj)
ab3721
-{
ab3721
-	if (DISPLAY_HUMAN_READ(flags)) {
ab3721
-		printf("%-22s\n%23s", shi->name, "");
ab3721
-	}
ab3721
-	else {
ab3721
-		printf("%-22s ", shi->name);
ab3721
-	}
ab3721
-	printf("%12.2f %12.2f %12.2f %12.2f %12.2f %12.2f %9.2f %9.2f %9.2f\n",
ab3721
-	       S_VALUE(ionj->rd_normal_bytes, ioni->rd_normal_bytes, itv) / fctr,
ab3721
-	       S_VALUE(ionj->wr_normal_bytes, ioni->wr_normal_bytes, itv) / fctr,
ab3721
-	       S_VALUE(ionj->rd_direct_bytes, ioni->rd_direct_bytes, itv) / fctr,
ab3721
-	       S_VALUE(ionj->wr_direct_bytes, ioni->wr_direct_bytes, itv) / fctr,
ab3721
-	       S_VALUE(ionj->rd_server_bytes, ioni->rd_server_bytes, itv) / fctr,
ab3721
-	       S_VALUE(ionj->wr_server_bytes, ioni->wr_server_bytes, itv) / fctr,
ab3721
-	       S_VALUE(ionj->rpc_sends, ioni->rpc_sends, itv),
ab3721
-	       S_VALUE(ionj->nfs_rops,  ioni->nfs_rops,  itv),
ab3721
-	       S_VALUE(ionj->nfs_wops,  ioni->nfs_wops,  itv));
ab3721
-}
ab3721
-
ab3721
-/*
ab3721
- ***************************************************************************
ab3721
- * Print everything now (stats and uptime).
ab3721
- *
ab3721
- * IN:
ab3721
- * @curr	Index in array for current sample statistics.
ab3721
- * @rectime	Current date and time.
ab3721
- ***************************************************************************
ab3721
- */
ab3721
-void write_stats(int curr, struct tm *rectime)
ab3721
-{
ab3721
-	int i, fctr = 1;
ab3721
-	unsigned long long itv;
ab3721
-	struct io_hdr_stats *shi;
ab3721
-	struct io_nfs_stats *ioni, *ionj;
ab3721
-
ab3721
-	/* Test stdout */
ab3721
-	TEST_STDOUT(STDOUT_FILENO);
ab3721
-
ab3721
-	/* Print time stamp */
ab3721
-	if (DISPLAY_TIMESTAMP(flags)) {
ab3721
-		if (DISPLAY_ISO(flags)) {
ab3721
-			strftime(timestamp, sizeof(timestamp), "%FT%T%z", rectime);
ab3721
-		}
ab3721
-		else {
ab3721
-			strftime(timestamp, sizeof(timestamp), "%x %X", rectime);
ab3721
-		}
ab3721
-		printf("%s\n", timestamp);
ab3721
-#ifdef DEBUG
ab3721
-		if (DISPLAY_DEBUG(flags)) {
ab3721
-			fprintf(stderr, "%s\n", timestamp);
ab3721
-		}
ab3721
-#endif
ab3721
-	}
ab3721
-
ab3721
-	/* Interval of time, reduced to one processor */
ab3721
-	itv = get_interval(uptime0[!curr], uptime0[curr]);
ab3721
-
ab3721
-	shi = st_hdr_ionfs;
ab3721
-
ab3721
-	/* Display NFS stats header */
ab3721
-	write_nfs_stat_header(&fctr);
ab3721
-
ab3721
-	for (i = 0; i < ionfs_nr; i++, shi++) {
ab3721
-		if (shi->used) {
ab3721
-			ioni = st_ionfs[curr]  + i;
ab3721
-			ionj = st_ionfs[!curr] + i;
ab3721
-#ifdef DEBUG
ab3721
-			if (DISPLAY_DEBUG(flags)) {
ab3721
-				/* Debug output */
ab3721
-				fprintf(stderr, "name=%s itv=%llu fctr=%d ioni{ rd_normal_bytes=%llu "
ab3721
-						"wr_normal_bytes=%llu rd_direct_bytes=%llu wr_direct_bytes=%llu rd_server_bytes=%llu "
ab3721
-						"wr_server_bytes=%llu rpc_sends=%lu nfs_rops=%lu nfs_wops=%lu }\n",
ab3721
-					shi->name, itv, fctr,
ab3721
-					ioni->rd_normal_bytes, ioni->wr_normal_bytes,
ab3721
-					ioni->rd_direct_bytes, ioni->wr_direct_bytes,
ab3721
-					ioni->rd_server_bytes, ioni->wr_server_bytes,
ab3721
-					ioni->rpc_sends,
ab3721
-					ioni->nfs_rops,        ioni->nfs_wops);
ab3721
-			}
ab3721
-#endif
ab3721
-			write_nfs_stat(curr, itv, fctr, shi, ioni, ionj);
ab3721
-		}
ab3721
-	}
ab3721
-	printf("\n");
ab3721
-}
ab3721
-
ab3721
-/*
ab3721
- ***************************************************************************
ab3721
- * Main loop: Read stats from the relevant sources and display them.
ab3721
- *
ab3721
- * IN:
ab3721
- * @count	Number of lines of stats to print.
ab3721
- * @rectime	Current date and time.
ab3721
- ***************************************************************************
ab3721
- */
ab3721
-void rw_io_stat_loop(long int count, struct tm *rectime)
ab3721
-{
ab3721
-	int curr = 1;
ab3721
-
ab3721
-	/* Don't buffer data if redirected to a pipe */
ab3721
-	setbuf(stdout, NULL);
ab3721
-	
ab3721
-	do {
ab3721
-		/* Read system uptime (reduced to one processor) */
ab3721
-		uptime0[curr] = 0;
ab3721
-		read_uptime(&(uptime0[curr]));
ab3721
-		if (!uptime0[curr])
ab3721
-			/* Cannot read system uptime (/proc/uptime doesn't exist) */
ab3721
-			exit(2);
ab3721
-
ab3721
-		/* Read NFS directories stats */
ab3721
-		read_nfs_stat(curr);
ab3721
-
ab3721
-		/* Get time */
ab3721
-		get_localtime(rectime, 0);
ab3721
-
ab3721
-		/* Print results */
ab3721
-		write_stats(curr, rectime);
ab3721
-
ab3721
-		if (count > 0) {
ab3721
-			count--;
ab3721
-		}
ab3721
-		if (count) {
ab3721
-			curr ^= 1;
ab3721
-			pause();
ab3721
-		}
ab3721
-	}
ab3721
-	while (count);
ab3721
-}
ab3721
-
ab3721
-/*
ab3721
- ***************************************************************************
ab3721
- * Main entry to the nfsiostat program.
ab3721
- ***************************************************************************
ab3721
- */
ab3721
-int main(int argc, char **argv)
ab3721
-{
ab3721
-	int it = 0;
ab3721
-	int opt = 1;
ab3721
-	int i;
ab3721
-	long count = 1;
ab3721
-	struct utsname header;
ab3721
-	struct tm rectime;
ab3721
-
ab3721
-#ifdef USE_NLS
ab3721
-	/* Init National Language Support */
ab3721
-	init_nls();
ab3721
-#endif
ab3721
-
ab3721
-	/* Get HZ */
ab3721
-	get_HZ();
ab3721
-
ab3721
-	/* Process args... */
ab3721
-	while (opt < argc) {
ab3721
-
ab3721
-#ifdef DEBUG
ab3721
-		if (!strcmp(argv[opt], "--debuginfo")) {
ab3721
-			flags |= I_D_DEBUG;
ab3721
-			opt++;
ab3721
-		} else
ab3721
-#endif
ab3721
-		if (!strncmp(argv[opt], "-", 1)) {
ab3721
-			for (i = 1; *(argv[opt] + i); i++) {
ab3721
-
ab3721
-				switch (*(argv[opt] + i)) {
ab3721
-
ab3721
-				case 'h':
ab3721
-					/* Display an easy-to-read NFS report */
ab3721
-					flags |= I_D_HUMAN_READ;
ab3721
-					break;
ab3721
-	
ab3721
-				case 'k':
ab3721
-					if (DISPLAY_MEGABYTES(flags)) {
ab3721
-						usage(argv[0]);
ab3721
-					}
ab3721
-					/* Display stats in kB/s */
ab3721
-					flags |= I_D_KILOBYTES;
ab3721
-					break;
ab3721
-
ab3721
-				case 'm':
ab3721
-					if (DISPLAY_KILOBYTES(flags)) {
ab3721
-						usage(argv[0]);
ab3721
-					}
ab3721
-					/* Display stats in MB/s */
ab3721
-					flags |= I_D_MEGABYTES;
ab3721
-					break;
ab3721
-
ab3721
-				case 't':
ab3721
-					/* Display timestamp */
ab3721
-					flags |= I_D_TIMESTAMP;
ab3721
-					break;
ab3721
-
ab3721
-				case 'V':
ab3721
-					/* Print version number and exit */
ab3721
-					print_version();
ab3721
-					break;
ab3721
-	
ab3721
-				default:
ab3721
-					usage(argv[0]);
ab3721
-				}
ab3721
-			}
ab3721
-			opt++;
ab3721
-		}
ab3721
-
ab3721
-		else if (!it) {
ab3721
-			interval = atol(argv[opt++]);
ab3721
-			if (interval < 0) {
ab3721
-				usage(argv[0]);
ab3721
-			}
ab3721
-			count = -1;
ab3721
-			it = 1;
ab3721
-		}
ab3721
-
ab3721
-		else if (it > 0) {
ab3721
-			count = atol(argv[opt++]);
ab3721
-			if ((count < 1) || !interval) {
ab3721
-				usage(argv[0]);
ab3721
-			}
ab3721
-			it = -1;
ab3721
-		}
ab3721
-		else {
ab3721
-			usage(argv[0]);
ab3721
-		}
ab3721
-	}
ab3721
-
ab3721
-	if (!interval) {
ab3721
-		count = 1;
ab3721
-	}
ab3721
-
ab3721
-	/* Select output unit (kB/s or blocks/s) */
ab3721
-	set_output_unit();
ab3721
-
ab3721
-	/* Init structures according to machine architecture */
ab3721
-	io_sys_init();
ab3721
-
ab3721
-	get_localtime(&rectime, 0);
ab3721
-
ab3721
-	/* Get system name, release number and hostname */
ab3721
-	uname(&header);
ab3721
-	if (print_gal_header(&rectime, header.sysname, header.release,
ab3721
-			     header.nodename, header.machine, cpu_nr)) {
ab3721
-		flags |= I_D_ISO;
ab3721
-	}
ab3721
-	printf("\n");
ab3721
-
ab3721
-	/* Set a handler for SIGALRM */
ab3721
-	memset(&alrm_act, 0, sizeof(alrm_act));
ab3721
-	alrm_act.sa_handler = (void *) alarm_handler;
ab3721
-	sigaction(SIGALRM, &alrm_act, NULL);
ab3721
-	alarm(interval);
ab3721
-
ab3721
-	/* Main loop */
ab3721
-	rw_io_stat_loop(count, &rectime);
ab3721
-
ab3721
-	/* Free structures */
ab3721
-	io_sys_free();
ab3721
-
ab3721
-	return 0;
ab3721
-}
ab3721
diff -uprN sysstat-10.1.5.orig/nfsiostat.h sysstat-10.1.5/nfsiostat.h
ab3721
--- sysstat-10.1.5.orig/nfsiostat.h	2013-03-23 17:31:46.000000000 +0100
ab3721
+++ sysstat-10.1.5/nfsiostat.h	1970-01-01 01:00:00.000000000 +0100
ab3721
@@ -1,57 +0,0 @@
ab3721
-/*
ab3721
- * nfsiostat: Report NFS I/O statistics
ab3721
- * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved
ab3721
- * Written by Ivana Varekova <varekova@redhat.com>
ab3721
- */
ab3721
-
ab3721
-#ifndef _NFSIOSTAT_H
ab3721
-#define _NFSIOSTAT_H
ab3721
-
ab3721
-#include "common.h"
ab3721
-
ab3721
-#define NFSMOUNTSTATS  "/proc/self/mountstats"
ab3721
-
ab3721
-/* I_: iostat - D_: Display - F_: Flag */
ab3721
-#define I_D_TIMESTAMP		0x001
ab3721
-#define I_D_KILOBYTES		0x002
ab3721
-#define I_D_MEGABYTES		0x004
ab3721
-#define I_D_ISO			0x008
ab3721
-#define I_D_HUMAN_READ		0x010
ab3721
-#define I_D_DEBUG		0x020
ab3721
-
ab3721
-#define DISPLAY_TIMESTAMP(m)	(((m) & I_D_TIMESTAMP)     == I_D_TIMESTAMP)
ab3721
-#define DISPLAY_KILOBYTES(m)	(((m) & I_D_KILOBYTES)     == I_D_KILOBYTES)
ab3721
-#define DISPLAY_MEGABYTES(m)	(((m) & I_D_MEGABYTES)     == I_D_MEGABYTES)
ab3721
-#define DISPLAY_ISO(m)		(((m) & I_D_ISO)           == I_D_ISO)
ab3721
-#define DISPLAY_HUMAN_READ(m)	(((m) & I_D_HUMAN_READ)    == I_D_HUMAN_READ)
ab3721
-#define DISPLAY_DEBUG(m)	(((m) & I_D_DEBUG)         == I_D_DEBUG)
ab3721
-
ab3721
-/* Environment variable */
ab3721
-#define ENV_POSIXLY_CORRECT	"POSIXLY_CORRECT"
ab3721
-
ab3721
-/* Preallocation constats */
ab3721
-#define NR_NFS_PREALLOC	2
ab3721
-
ab3721
-struct io_nfs_stats {
ab3721
-	unsigned long long rd_normal_bytes	__attribute__ ((aligned (8)));
ab3721
-	unsigned long long wr_normal_bytes	__attribute__ ((packed));
ab3721
-	unsigned long long rd_direct_bytes	__attribute__ ((packed));
ab3721
-	unsigned long long wr_direct_bytes	__attribute__ ((packed));
ab3721
-	unsigned long long rd_server_bytes	__attribute__ ((packed));
ab3721
-	unsigned long long wr_server_bytes	__attribute__ ((packed));
ab3721
-	unsigned long rpc_sends			__attribute__ ((packed));
ab3721
-	unsigned long nfs_rops			__attribute__ ((packed));
ab3721
-	unsigned long nfs_wops			__attribute__ ((packed));
ab3721
-};
ab3721
-
ab3721
-#define IO_NFS_STATS_SIZE	(sizeof(struct io_nfs_stats))
ab3721
-
ab3721
-struct io_hdr_stats {
ab3721
-	unsigned int active		__attribute__ ((aligned (4)));
ab3721
-	unsigned int used		__attribute__ ((packed));
ab3721
-	char name[MAX_NAME_LEN];
ab3721
-};
ab3721
-
ab3721
-#define IO_HDR_STATS_SIZE	(sizeof(struct io_hdr_stats))
ab3721
-
ab3721
-#endif  /* _NFSIOSTAT_H */
ab3721
diff -uprN sysstat-10.1.5.orig/nfsiostat-sysstat.c sysstat-10.1.5/nfsiostat-sysstat.c
ab3721
--- sysstat-10.1.5.orig/nfsiostat-sysstat.c	1970-01-01 01:00:00.000000000 +0100
ab3721
+++ sysstat-10.1.5/nfsiostat-sysstat.c	2016-05-24 18:30:06.285162523 +0200
ab3721
@@ -0,0 +1,750 @@
ab3721
+/*
ab3721
+ * nfsiostat-sysstat: Report NFS I/O statistics
ab3721
+ * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved
ab3721
+ * Written by Ivana Varekova <varekova@redhat.com>
ab3721
+ *
ab3721
+ ***************************************************************************
ab3721
+ * This program is free software; you can redistribute it and/or modify it *
ab3721
+ * under the terms of the GNU General Public License as published  by  the *
ab3721
+ * Free Software Foundation; either version 2 of the License, or (at  your *
ab3721
+ * option) any later version.                                              *
ab3721
+ *                                                                         *
ab3721
+ * This program is distributed in the hope that it  will  be  useful,  but *
ab3721
+ * WITHOUT ANY WARRANTY; without the implied warranty  of  MERCHANTABILITY *
ab3721
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
ab3721
+ * for more details.                                                       *
ab3721
+ *                                                                         *
ab3721
+ * You should have received a copy of the GNU General Public License along *
ab3721
+ * with this program; if not, write to the Free Software Foundation, Inc., *
ab3721
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                   *
ab3721
+ ***************************************************************************
ab3721
+ */
ab3721
+
ab3721
+#include <stdio.h>
ab3721
+#include <string.h>
ab3721
+#include <stdlib.h>
ab3721
+#include <unistd.h>
ab3721
+#include <signal.h>
ab3721
+#include <sys/utsname.h>
ab3721
+
ab3721
+#include "version.h"
ab3721
+#include "nfsiostat-sysstat.h"
ab3721
+#include "common.h"
ab3721
+
ab3721
+#ifdef USE_NLS
ab3721
+#include <locale.h>
ab3721
+#include <libintl.h>
ab3721
+#define _(string) gettext(string)
ab3721
+#else
ab3721
+#define _(string) (string)
ab3721
+#endif
ab3721
+
ab3721
+#define SCCSID "@(#)sysstat-" VERSION ": " __FILE__ " compiled " __DATE__ " " __TIME__
ab3721
+char *sccsid(void) { return (SCCSID); }
ab3721
+
ab3721
+unsigned long long uptime0[2] = {0, 0};
ab3721
+struct io_nfs_stats *st_ionfs[2];
ab3721
+struct io_hdr_stats *st_hdr_ionfs;
ab3721
+
ab3721
+int ionfs_nr = 0;	/* Nb of NFS mounted directories found */
ab3721
+int cpu_nr = 0;		/* Nb of processors on the machine */
ab3721
+int flags = 0;		/* Flag for common options and system state */
ab3721
+
ab3721
+long interval = 0;
ab3721
+char timestamp[64];
ab3721
+
ab3721
+struct sigaction alrm_act;
ab3721
+
ab3721
+/*
ab3721
+ ***************************************************************************
ab3721
+ * Print usage and exit.
ab3721
+ *
ab3721
+ * IN:
ab3721
+ * @progname	Name of sysstat command.
ab3721
+ ***************************************************************************
ab3721
+ */
ab3721
+void usage(char *progname)
ab3721
+{
ab3721
+	fprintf(stderr, _("Usage: %s [ options ] [ <interval> [ <count> ] ]\n"),
ab3721
+		progname);
ab3721
+
ab3721
+#ifdef DEBUG
ab3721
+	fprintf(stderr, _("Options are:\n"
ab3721
+			  "[ -h ] [ -k | -m ] [ -t ] [ -V ] [ --debuginfo ]\n"));
ab3721
+#else
ab3721
+	fprintf(stderr, _("Options are:\n"
ab3721
+			  "[ -h ] [ -k | -m ] [ -t ] [ -V ]\n"));
ab3721
+#endif
ab3721
+	exit(1);
ab3721
+}
ab3721
+
ab3721
+/*
ab3721
+ ***************************************************************************
ab3721
+ * Set output unit. Unit will be kB/s unless POSIXLY_CORRECT
ab3721
+ * environment variable has been set, in which case the output will be
ab3721
+ * expressed in blocks/s.
ab3721
+ ***************************************************************************
ab3721
+ */
ab3721
+void set_output_unit(void)
ab3721
+{
ab3721
+	char *e;
ab3721
+
ab3721
+	if (DISPLAY_KILOBYTES(flags) || DISPLAY_MEGABYTES(flags))
ab3721
+		return;
ab3721
+
ab3721
+	/* Check POSIXLY_CORRECT environment variable */
ab3721
+	if ((e = getenv(ENV_POSIXLY_CORRECT)) == NULL) {
ab3721
+		/* Variable not set: Unit is kB/s and not blocks/s */
ab3721
+		flags |= I_D_KILOBYTES;
ab3721
+	}
ab3721
+}
ab3721
+
ab3721
+/*
ab3721
+ ***************************************************************************
ab3721
+ * SIGALRM signal handler.
ab3721
+ *
ab3721
+ * IN:
ab3721
+ * @sig	Signal number.
ab3721
+ ***************************************************************************
ab3721
+ */
ab3721
+void alarm_handler(int sig)
ab3721
+{
ab3721
+	alarm(interval);
ab3721
+}
ab3721
+
ab3721
+/*
ab3721
+ ***************************************************************************
ab3721
+ * Find number of NFS-mounted points that are registered in
ab3721
+ * /proc/self/mountstats.
ab3721
+ *
ab3721
+ * RETURNS:
ab3721
+ * Number of NFS-mounted points.
ab3721
+ ***************************************************************************
ab3721
+ */
ab3721
+int get_nfs_mount_nr(void)
ab3721
+{
ab3721
+	FILE *fp;
ab3721
+	char line[8192];
ab3721
+	char type_name[10];
ab3721
+	unsigned int nfs = 0;
ab3721
+
ab3721
+	if ((fp = fopen(NFSMOUNTSTATS, "r")) == NULL)
ab3721
+		/* File non-existent */
ab3721
+		return 0;
ab3721
+
ab3721
+	while (fgets(line, 8192, fp) != NULL) {
ab3721
+
ab3721
+		if ((strstr(line, "mounted")) && (strstr(line, "on")) &&
ab3721
+		    (strstr(line, "with")) && (strstr(line, "fstype"))) {
ab3721
+
ab3721
+			sscanf(strstr(line, "fstype") + 6, "%9s", type_name);
ab3721
+			if ((!strncmp(type_name, "nfs", 3)) && (strncmp(type_name, "nfsd", 4))) {
ab3721
+				nfs ++;
ab3721
+			}
ab3721
+		}
ab3721
+	}
ab3721
+
ab3721
+	fclose(fp);
ab3721
+
ab3721
+	return nfs;
ab3721
+}
ab3721
+
ab3721
+/*
ab3721
+ ***************************************************************************
ab3721
+ * Set every nfs_io entry to inactive state (unregistered).
ab3721
+ ***************************************************************************
ab3721
+ */
ab3721
+void set_entries_inactive(void)
ab3721
+{
ab3721
+	int i;
ab3721
+	struct io_hdr_stats *shi = st_hdr_ionfs;
ab3721
+
ab3721
+	for (i = 0; i < ionfs_nr; i++, shi++) {
ab3721
+		shi->active = FALSE;
ab3721
+	}
ab3721
+}
ab3721
+
ab3721
+/*
ab3721
+ ***************************************************************************
ab3721
+ * Free inactive entries (mark them as unused).
ab3721
+ ***************************************************************************
ab3721
+ */
ab3721
+void free_inactive_entries(void)
ab3721
+{
ab3721
+	int i;
ab3721
+	struct io_hdr_stats *shi = st_hdr_ionfs;
ab3721
+
ab3721
+	for (i = 0; i < ionfs_nr; i++, shi++) {
ab3721
+		if (!shi->active) {
ab3721
+			shi->used = FALSE;
ab3721
+		}
ab3721
+	}
ab3721
+}
ab3721
+
ab3721
+/*
ab3721
+ ***************************************************************************
ab3721
+ * Allocate and init structures, according to system state.
ab3721
+ ***************************************************************************
ab3721
+ */
ab3721
+void io_sys_init(void)
ab3721
+{
ab3721
+	int i;
ab3721
+	
ab3721
+	/* How many processors on this machine? */
ab3721
+	cpu_nr = get_cpu_nr(~0);
ab3721
+
ab3721
+	/* Get number of NFS directories in /proc/self/mountstats */
ab3721
+	if ((ionfs_nr = get_nfs_mount_nr()) > 0) {
ab3721
+		ionfs_nr += NR_NFS_PREALLOC;
ab3721
+	}
ab3721
+	if ((st_hdr_ionfs = (struct io_hdr_stats *) calloc(ionfs_nr, IO_HDR_STATS_SIZE)) == NULL) {
ab3721
+		perror("malloc");
ab3721
+		exit(4);
ab3721
+	}
ab3721
+	
ab3721
+	/* Allocate structures for number of NFS directories found */
ab3721
+	for (i = 0; i < 2; i++) {
ab3721
+		if ((st_ionfs[i] =
ab3721
+		    (struct io_nfs_stats *) calloc(ionfs_nr, IO_NFS_STATS_SIZE)) == NULL) {
ab3721
+			perror("malloc");
ab3721
+			exit(4);
ab3721
+		}
ab3721
+	}
ab3721
+}
ab3721
+
ab3721
+/*
ab3721
+ ***************************************************************************
ab3721
+ * Free various structures.
ab3721
+ ***************************************************************************
ab3721
+*/
ab3721
+void io_sys_free(void)
ab3721
+{
ab3721
+	int i;
ab3721
+
ab3721
+	/* Free I/O NFS directories structures */
ab3721
+	for (i = 0; i < 2; i++) {
ab3721
+
ab3721
+		if (st_ionfs[i]) {
ab3721
+			free(st_ionfs[i]);
ab3721
+		}
ab3721
+	}
ab3721
+	
ab3721
+	if (st_hdr_ionfs) {
ab3721
+		free(st_hdr_ionfs);
ab3721
+	}
ab3721
+}
ab3721
+
ab3721
+/*
ab3721
+ ***************************************************************************
ab3721
+ * Save stats for current NFS filesystem.
ab3721
+ *
ab3721
+ * IN:
ab3721
+ * @name		Name of NFS filesystem.
ab3721
+ * @curr		Index in array for current sample statistics.
ab3721
+ * @st_io		Structure with NFS statistics to save.
ab3721
+ * @ionfs_nr		Number of NFS filesystems.
ab3721
+ * @st_hdr_ionfs	Pointer on structures describing an NFS filesystem.
ab3721
+ *
ab3721
+ * OUT:
ab3721
+ * @st_hdr_ionfs	Pointer on structures describing an NFS filesystem.
ab3721
+ ***************************************************************************
ab3721
+ */
ab3721
+void save_stats(char *name, int curr, void *st_io)
ab3721
+{
ab3721
+	int i, j;
ab3721
+	struct io_hdr_stats *st_hdr_ionfs_i;
ab3721
+	struct io_nfs_stats *st_ionfs_i;
ab3721
+
ab3721
+	/* Look for NFS directory in data table */
ab3721
+	for (i = 0; i < ionfs_nr; i++) {
ab3721
+		st_hdr_ionfs_i = st_hdr_ionfs + i;
ab3721
+		if ((st_hdr_ionfs_i->used) &&
ab3721
+		    (!strcmp(st_hdr_ionfs_i->name, name))) {
ab3721
+			break;
ab3721
+		}
ab3721
+	}
ab3721
+
ab3721
+	if (i == ionfs_nr) {
ab3721
+		/*
ab3721
+		 * This is a new filesystem: Look for an unused entry to store it.
ab3721
+		 */
ab3721
+		for (i = 0; i < ionfs_nr; i++) {
ab3721
+			st_hdr_ionfs_i = st_hdr_ionfs + i;
ab3721
+			if (!st_hdr_ionfs_i->used) {
ab3721
+				/* Unused entry found... */
ab3721
+				st_hdr_ionfs_i->used = TRUE; /* Indicate it is now used */
ab3721
+				st_hdr_ionfs_i->active = TRUE;
ab3721
+
ab3721
+				strncpy(st_hdr_ionfs_i->name, name, MAX_NAME_LEN - 1);
ab3721
+				st_hdr_ionfs_i->name[MAX_NAME_LEN - 1] = '\0';
ab3721
+				st_ionfs_i = st_ionfs[curr] + i;
ab3721
+				memset(st_ionfs_i, 0, IO_NFS_STATS_SIZE);
ab3721
+				*st_ionfs_i = *((struct io_nfs_stats *) st_io);
ab3721
+				break;
ab3721
+			}
ab3721
+		}
ab3721
+		if (i == ionfs_nr) {
ab3721
+			/* All entries are used: The number has to be increased */
ab3721
+			ionfs_nr = ionfs_nr + 5;
ab3721
+
ab3721
+			/* Increase the size of st_hdr_ionfs buffer */
ab3721
+			if ((st_hdr_ionfs = (struct io_hdr_stats *)
ab3721
+				realloc(st_hdr_ionfs, ionfs_nr * IO_HDR_STATS_SIZE)) == NULL) {
ab3721
+				perror("malloc");
ab3721
+				exit(4);
ab3721
+			}
ab3721
+
ab3721
+			/* Set the new entries inactive */
ab3721
+			for (j = 0; j < 5; j++) {
ab3721
+				st_hdr_ionfs_i = st_hdr_ionfs + i + j;
ab3721
+				st_hdr_ionfs_i->used = FALSE;
ab3721
+				st_hdr_ionfs_i->active = FALSE;
ab3721
+			}
ab3721
+
ab3721
+			/* Increase the size of st_hdr_ionfs buffer */
ab3721
+			for (j = 0; j < 2; j++) {
ab3721
+				if ((st_ionfs[j] = (struct io_nfs_stats *)
ab3721
+					realloc(st_ionfs[j], ionfs_nr * IO_NFS_STATS_SIZE)) == NULL) {
ab3721
+					perror("malloc");
ab3721
+					exit(4);
ab3721
+				}
ab3721
+				memset(st_ionfs[j] + i, 0, 5 * IO_NFS_STATS_SIZE);
ab3721
+			}
ab3721
+
ab3721
+			/* Now i shows the first unused entry of the new block */
ab3721
+			st_hdr_ionfs_i = st_hdr_ionfs + i;
ab3721
+			st_hdr_ionfs_i->used = TRUE; /* Indicate it is now used */
ab3721
+			strncpy(st_hdr_ionfs_i->name, name, MAX_NAME_LEN - 1);
ab3721
+			st_hdr_ionfs_i->name[MAX_NAME_LEN - 1] = '\0';
ab3721
+			st_ionfs_i = st_ionfs[curr] + i;
ab3721
+			memset(st_ionfs_i, 0, IO_NFS_STATS_SIZE);
ab3721
+		}
ab3721
+	} else  {
ab3721
+		st_hdr_ionfs_i = st_hdr_ionfs + i;
ab3721
+		st_hdr_ionfs_i->used = TRUE;
ab3721
+		st_hdr_ionfs_i->active = TRUE;
ab3721
+		st_ionfs_i = st_ionfs[curr] + i;
ab3721
+		*st_ionfs_i = *((struct io_nfs_stats *) st_io);
ab3721
+	}
ab3721
+	/*
ab3721
+	 * else it was a new NFS directory
ab3721
+	 * but there was no free structure to store it.
ab3721
+	 */
ab3721
+}
ab3721
+
ab3721
+/*
ab3721
+ ***************************************************************************
ab3721
+ * Read NFS-mount directories stats from /proc/self/mountstats.
ab3721
+ *
ab3721
+ * IN:
ab3721
+ * @curr	Index in array for current sample statistics.
ab3721
+ ***************************************************************************
ab3721
+ */
ab3721
+void read_nfs_stat(int curr)
ab3721
+{
ab3721
+	FILE *fp;
ab3721
+	int sw = 0;
ab3721
+	char line[256];
ab3721
+	char *xprt_line;
ab3721
+	char *mount_part;
ab3721
+	char nfs_name[MAX_NAME_LEN];
ab3721
+	char mount[10], on[10], prefix[10], aux[32];
ab3721
+	char operation[16];
ab3721
+	struct io_nfs_stats snfs;
ab3721
+	long int v1;
ab3721
+
ab3721
+	/* Every I/O NFS entry is potentially unregistered */
ab3721
+	set_entries_inactive();
ab3721
+
ab3721
+	if ((fp = fopen(NFSMOUNTSTATS, "r")) == NULL)
ab3721
+		return;
ab3721
+
ab3721
+	sprintf(aux, "%%%ds",
ab3721
+		MAX_NAME_LEN < 200 ? MAX_NAME_LEN-1 : 200);
ab3721
+
ab3721
+	while (fgets(line, 256, fp) != NULL) {
ab3721
+		/* Read NFS directory name */
ab3721
+		if (!strncmp(line, "device", 6)) {
ab3721
+			sw = 0;
ab3721
+			sscanf(line + 6, aux, nfs_name);
ab3721
+			mount_part = strchr(line + 7, ' ');
ab3721
+			if (mount_part != NULL) {
ab3721
+				sscanf(mount_part, "%9s %9s", mount, on);
ab3721
+				if ((!strncmp(mount, "mounted", 7)) && (!strncmp(on, "on", 2))) {
ab3721
+					sw = 1;
ab3721
+				}
ab3721
+			}
ab3721
+		}
ab3721
+
ab3721
+		sscanf(line, "%9s", prefix);
ab3721
+		if (sw && (!strncmp(prefix, "bytes:", 6))) {
ab3721
+			/* Read the stats for the last NFS-mounted directory */
ab3721
+			sscanf(strstr(line, "bytes:") + 6, "%llu %llu %llu %llu %llu %llu",
ab3721
+			       &snfs.rd_normal_bytes, &snfs.wr_normal_bytes,
ab3721
+			       &snfs.rd_direct_bytes, &snfs.wr_direct_bytes,
ab3721
+			       &snfs.rd_server_bytes, &snfs.wr_server_bytes);
ab3721
+			sw = 2;
ab3721
+		}
ab3721
+
ab3721
+		if ((sw == 2) && (!strncmp(prefix, "xprt:", 5))) {
ab3721
+			/*
ab3721
+			 * Read extended statistic for the last NFS-mounted directory
ab3721
+			 * - number of sent rpc requests.
ab3721
+			 */
ab3721
+			xprt_line = (strstr(line, "xprt:") + 6);
ab3721
+			/* udp, tcp or rdma data */
ab3721
+			if (!strncmp(xprt_line, "udp", 3)) {
ab3721
+				/* port bind_count sends recvs (bad_xids req_u bklog_u) */
ab3721
+				sscanf(strstr(xprt_line, "udp") + 4, "%*u %*u %lu",
ab3721
+				       &snfs.rpc_sends);
ab3721
+			}
ab3721
+			if (!strncmp(xprt_line, "tcp", 3)) {
ab3721
+				/*
ab3721
+				 * port bind_counter connect_count connect_time idle_time
ab3721
+				 * sends recvs (bad_xids req_u bklog_u)
ab3721
+				 */
ab3721
+				sscanf(strstr(xprt_line, "tcp") + 4,
ab3721
+				       "%*u %*u %*u %*u %*d %lu",
ab3721
+				       &snfs.rpc_sends);
ab3721
+			}
ab3721
+			if (!strncmp(xprt_line,"rdma", 4)) {
ab3721
+				/*
ab3721
+				 * 0(port) bind_count connect_count connect_time idle_time
ab3721
+				 * sends recvs (bad_xids req_u bklog_u...)
ab3721
+				 */
ab3721
+				sscanf(strstr(xprt_line, "rdma") + 5,
ab3721
+				       "%*u %*u %*u %*u %*d %lu",
ab3721
+				       &snfs.rpc_sends);
ab3721
+			}
ab3721
+			sw = 3;
ab3721
+		}
ab3721
+
ab3721
+		if ((sw == 3) && (!strncmp(prefix, "per-op", 6))) {
ab3721
+			sw = 4;
ab3721
+			while (sw == 4) {
ab3721
+				if (fgets(line, sizeof(line), fp) == NULL)
ab3721
+					break;
ab3721
+				sscanf(line, "%15s %lu", operation, &v1;;
ab3721
+				if (!strncmp(operation, "READ:", 5)) {
ab3721
+					snfs.nfs_rops = v1;
ab3721
+				}
ab3721
+				else if (!strncmp(operation, "WRITE:", 6)) {
ab3721
+					snfs.nfs_wops = v1;
ab3721
+
ab3721
+					save_stats(nfs_name, curr, &snfs);
ab3721
+					sw = 0;
ab3721
+				}
ab3721
+			}
ab3721
+		}
ab3721
+	}
ab3721
+
ab3721
+	fclose(fp);
ab3721
+
ab3721
+	/* Free structures corresponding to unregistered filesystems */
ab3721
+	free_inactive_entries();
ab3721
+}
ab3721
+
ab3721
+/*
ab3721
+ ***************************************************************************
ab3721
+ * Display NFS stats header.
ab3721
+ *
ab3721
+ * OUT:
ab3721
+ * @fctr	Conversion factor.
ab3721
+ ***************************************************************************
ab3721
+ */
ab3721
+void write_nfs_stat_header(int *fctr)
ab3721
+{
ab3721
+	printf("Filesystem:           ");
ab3721
+	if (DISPLAY_KILOBYTES(flags)) {
ab3721
+		printf("    rkB_nor/s    wkB_nor/s    rkB_dir/s    wkB_dir/s"
ab3721
+		       "    rkB_svr/s    wkB_svr/s");
ab3721
+		*fctr = 1024;
ab3721
+	}
ab3721
+	else if (DISPLAY_MEGABYTES(flags)) {
ab3721
+		printf("    rMB_nor/s    wMB_nor/s    rMB_dir/s    wMB_dir/s"
ab3721
+		       "    rMB_svr/s    wMB_svr/s");
ab3721
+		*fctr = 1024 * 1024;
ab3721
+	}
ab3721
+	else {
ab3721
+		printf("   rBlk_nor/s   wBlk_nor/s   rBlk_dir/s   wBlk_dir/s"
ab3721
+		       "   rBlk_svr/s   wBlk_svr/s");
ab3721
+		*fctr = 512;
ab3721
+	}
ab3721
+	printf("     ops/s    rops/s    wops/s\n");
ab3721
+}
ab3721
+
ab3721
+/*
ab3721
+ ***************************************************************************
ab3721
+ * Write NFS stats read from /proc/self/mountstats.
ab3721
+ *
ab3721
+ * IN:
ab3721
+ * @curr	Index in array for current sample statistics.
ab3721
+ * @itv		Interval of time.
ab3721
+ * @fctr	Conversion factor.
ab3721
+ * @shi		Structures describing the NFS filesystems.
ab3721
+ * @ioi		Current sample statistics.
ab3721
+ * @ioj		Previous sample statistics.
ab3721
+ ***************************************************************************
ab3721
+ */
ab3721
+void write_nfs_stat(int curr, unsigned long long itv, int fctr,
ab3721
+		    struct io_hdr_stats *shi, struct io_nfs_stats *ioni,
ab3721
+		    struct io_nfs_stats *ionj)
ab3721
+{
ab3721
+	if (DISPLAY_HUMAN_READ(flags)) {
ab3721
+		printf("%-22s\n%23s", shi->name, "");
ab3721
+	}
ab3721
+	else {
ab3721
+		printf("%-22s ", shi->name);
ab3721
+	}
ab3721
+	printf("%12.2f %12.2f %12.2f %12.2f %12.2f %12.2f %9.2f %9.2f %9.2f\n",
ab3721
+	       S_VALUE(ionj->rd_normal_bytes, ioni->rd_normal_bytes, itv) / fctr,
ab3721
+	       S_VALUE(ionj->wr_normal_bytes, ioni->wr_normal_bytes, itv) / fctr,
ab3721
+	       S_VALUE(ionj->rd_direct_bytes, ioni->rd_direct_bytes, itv) / fctr,
ab3721
+	       S_VALUE(ionj->wr_direct_bytes, ioni->wr_direct_bytes, itv) / fctr,
ab3721
+	       S_VALUE(ionj->rd_server_bytes, ioni->rd_server_bytes, itv) / fctr,
ab3721
+	       S_VALUE(ionj->wr_server_bytes, ioni->wr_server_bytes, itv) / fctr,
ab3721
+	       S_VALUE(ionj->rpc_sends, ioni->rpc_sends, itv),
ab3721
+	       S_VALUE(ionj->nfs_rops,  ioni->nfs_rops,  itv),
ab3721
+	       S_VALUE(ionj->nfs_wops,  ioni->nfs_wops,  itv));
ab3721
+}
ab3721
+
ab3721
+/*
ab3721
+ ***************************************************************************
ab3721
+ * Print everything now (stats and uptime).
ab3721
+ *
ab3721
+ * IN:
ab3721
+ * @curr	Index in array for current sample statistics.
ab3721
+ * @rectime	Current date and time.
ab3721
+ ***************************************************************************
ab3721
+ */
ab3721
+void write_stats(int curr, struct tm *rectime)
ab3721
+{
ab3721
+	int i, fctr = 1;
ab3721
+	unsigned long long itv;
ab3721
+	struct io_hdr_stats *shi;
ab3721
+	struct io_nfs_stats *ioni, *ionj;
ab3721
+
ab3721
+	/* Test stdout */
ab3721
+	TEST_STDOUT(STDOUT_FILENO);
ab3721
+
ab3721
+	/* Print time stamp */
ab3721
+	if (DISPLAY_TIMESTAMP(flags)) {
ab3721
+		if (DISPLAY_ISO(flags)) {
ab3721
+			strftime(timestamp, sizeof(timestamp), "%FT%T%z", rectime);
ab3721
+		}
ab3721
+		else {
ab3721
+			strftime(timestamp, sizeof(timestamp), "%x %X", rectime);
ab3721
+		}
ab3721
+		printf("%s\n", timestamp);
ab3721
+#ifdef DEBUG
ab3721
+		if (DISPLAY_DEBUG(flags)) {
ab3721
+			fprintf(stderr, "%s\n", timestamp);
ab3721
+		}
ab3721
+#endif
ab3721
+	}
ab3721
+
ab3721
+	/* Interval of time, reduced to one processor */
ab3721
+	itv = get_interval(uptime0[!curr], uptime0[curr]);
ab3721
+
ab3721
+	shi = st_hdr_ionfs;
ab3721
+
ab3721
+	/* Display NFS stats header */
ab3721
+	write_nfs_stat_header(&fctr);
ab3721
+
ab3721
+	for (i = 0; i < ionfs_nr; i++, shi++) {
ab3721
+		if (shi->used) {
ab3721
+			ioni = st_ionfs[curr]  + i;
ab3721
+			ionj = st_ionfs[!curr] + i;
ab3721
+#ifdef DEBUG
ab3721
+			if (DISPLAY_DEBUG(flags)) {
ab3721
+				/* Debug output */
ab3721
+				fprintf(stderr, "name=%s itv=%llu fctr=%d ioni{ rd_normal_bytes=%llu "
ab3721
+						"wr_normal_bytes=%llu rd_direct_bytes=%llu wr_direct_bytes=%llu rd_server_bytes=%llu "
ab3721
+						"wr_server_bytes=%llu rpc_sends=%lu nfs_rops=%lu nfs_wops=%lu }\n",
ab3721
+					shi->name, itv, fctr,
ab3721
+					ioni->rd_normal_bytes, ioni->wr_normal_bytes,
ab3721
+					ioni->rd_direct_bytes, ioni->wr_direct_bytes,
ab3721
+					ioni->rd_server_bytes, ioni->wr_server_bytes,
ab3721
+					ioni->rpc_sends,
ab3721
+					ioni->nfs_rops,        ioni->nfs_wops);
ab3721
+			}
ab3721
+#endif
ab3721
+			write_nfs_stat(curr, itv, fctr, shi, ioni, ionj);
ab3721
+		}
ab3721
+	}
ab3721
+	printf("\n");
ab3721
+}
ab3721
+
ab3721
+/*
ab3721
+ ***************************************************************************
ab3721
+ * Main loop: Read stats from the relevant sources and display them.
ab3721
+ *
ab3721
+ * IN:
ab3721
+ * @count	Number of lines of stats to print.
ab3721
+ * @rectime	Current date and time.
ab3721
+ ***************************************************************************
ab3721
+ */
ab3721
+void rw_io_stat_loop(long int count, struct tm *rectime)
ab3721
+{
ab3721
+	int curr = 1;
ab3721
+
ab3721
+	/* Don't buffer data if redirected to a pipe */
ab3721
+	setbuf(stdout, NULL);
ab3721
+	
ab3721
+	do {
ab3721
+		/* Read system uptime (reduced to one processor) */
ab3721
+		uptime0[curr] = 0;
ab3721
+		read_uptime(&(uptime0[curr]));
ab3721
+		if (!uptime0[curr])
ab3721
+			/* Cannot read system uptime (/proc/uptime doesn't exist) */
ab3721
+			exit(2);
ab3721
+
ab3721
+		/* Read NFS directories stats */
ab3721
+		read_nfs_stat(curr);
ab3721
+
ab3721
+		/* Get time */
ab3721
+		get_localtime(rectime, 0);
ab3721
+
ab3721
+		/* Print results */
ab3721
+		write_stats(curr, rectime);
ab3721
+
ab3721
+		if (count > 0) {
ab3721
+			count--;
ab3721
+		}
ab3721
+		if (count) {
ab3721
+			curr ^= 1;
ab3721
+			pause();
ab3721
+		}
ab3721
+	}
ab3721
+	while (count);
ab3721
+}
ab3721
+
ab3721
+/*
ab3721
+ ***************************************************************************
ab3721
+ * Main entry to the nfsiostat-sysstat program.
ab3721
+ ***************************************************************************
ab3721
+ */
ab3721
+int main(int argc, char **argv)
ab3721
+{
ab3721
+	int it = 0;
ab3721
+	int opt = 1;
ab3721
+	int i;
ab3721
+	long count = 1;
ab3721
+	struct utsname header;
ab3721
+	struct tm rectime;
ab3721
+
ab3721
+#ifdef USE_NLS
ab3721
+	/* Init National Language Support */
ab3721
+	init_nls();
ab3721
+#endif
ab3721
+
ab3721
+	/* Get HZ */
ab3721
+	get_HZ();
ab3721
+
ab3721
+	/* Process args... */
ab3721
+	while (opt < argc) {
ab3721
+
ab3721
+#ifdef DEBUG
ab3721
+		if (!strcmp(argv[opt], "--debuginfo")) {
ab3721
+			flags |= I_D_DEBUG;
ab3721
+			opt++;
ab3721
+		} else
ab3721
+#endif
ab3721
+		if (!strncmp(argv[opt], "-", 1)) {
ab3721
+			for (i = 1; *(argv[opt] + i); i++) {
ab3721
+
ab3721
+				switch (*(argv[opt] + i)) {
ab3721
+
ab3721
+				case 'h':
ab3721
+					/* Display an easy-to-read NFS report */
ab3721
+					flags |= I_D_HUMAN_READ;
ab3721
+					break;
ab3721
+	
ab3721
+				case 'k':
ab3721
+					if (DISPLAY_MEGABYTES(flags)) {
ab3721
+						usage(argv[0]);
ab3721
+					}
ab3721
+					/* Display stats in kB/s */
ab3721
+					flags |= I_D_KILOBYTES;
ab3721
+					break;
ab3721
+
ab3721
+				case 'm':
ab3721
+					if (DISPLAY_KILOBYTES(flags)) {
ab3721
+						usage(argv[0]);
ab3721
+					}
ab3721
+					/* Display stats in MB/s */
ab3721
+					flags |= I_D_MEGABYTES;
ab3721
+					break;
ab3721
+
ab3721
+				case 't':
ab3721
+					/* Display timestamp */
ab3721
+					flags |= I_D_TIMESTAMP;
ab3721
+					break;
ab3721
+
ab3721
+				case 'V':
ab3721
+					/* Print version number and exit */
ab3721
+					print_version();
ab3721
+					break;
ab3721
+	
ab3721
+				default:
ab3721
+					usage(argv[0]);
ab3721
+				}
ab3721
+			}
ab3721
+			opt++;
ab3721
+		}
ab3721
+
ab3721
+		else if (!it) {
ab3721
+			interval = atol(argv[opt++]);
ab3721
+			if (interval < 0) {
ab3721
+				usage(argv[0]);
ab3721
+			}
ab3721
+			count = -1;
ab3721
+			it = 1;
ab3721
+		}
ab3721
+
ab3721
+		else if (it > 0) {
ab3721
+			count = atol(argv[opt++]);
ab3721
+			if ((count < 1) || !interval) {
ab3721
+				usage(argv[0]);
ab3721
+			}
ab3721
+			it = -1;
ab3721
+		}
ab3721
+		else {
ab3721
+			usage(argv[0]);
ab3721
+		}
ab3721
+	}
ab3721
+
ab3721
+	if (!interval) {
ab3721
+		count = 1;
ab3721
+	}
ab3721
+
ab3721
+	/* Select output unit (kB/s or blocks/s) */
ab3721
+	set_output_unit();
ab3721
+
ab3721
+	/* Init structures according to machine architecture */
ab3721
+	io_sys_init();
ab3721
+
ab3721
+	get_localtime(&rectime, 0);
ab3721
+
ab3721
+	/* Get system name, release number and hostname */
ab3721
+	uname(&header);
ab3721
+	if (print_gal_header(&rectime, header.sysname, header.release,
ab3721
+			     header.nodename, header.machine, cpu_nr)) {
ab3721
+		flags |= I_D_ISO;
ab3721
+	}
ab3721
+	printf("\n");
ab3721
+
ab3721
+	/* Set a handler for SIGALRM */
ab3721
+	memset(&alrm_act, 0, sizeof(alrm_act));
ab3721
+	alrm_act.sa_handler = (void *) alarm_handler;
ab3721
+	sigaction(SIGALRM, &alrm_act, NULL);
ab3721
+	alarm(interval);
ab3721
+
ab3721
+	/* Main loop */
ab3721
+	rw_io_stat_loop(count, &rectime);
ab3721
+
ab3721
+	/* Free structures */
ab3721
+	io_sys_free();
ab3721
+
ab3721
+	return 0;
ab3721
+}
ab3721
diff -uprN sysstat-10.1.5.orig/nfsiostat-sysstat.h sysstat-10.1.5/nfsiostat-sysstat.h
ab3721
--- sysstat-10.1.5.orig/nfsiostat-sysstat.h	1970-01-01 01:00:00.000000000 +0100
ab3721
+++ sysstat-10.1.5/nfsiostat-sysstat.h	2016-05-24 18:25:16.210668308 +0200
ab3721
@@ -0,0 +1,57 @@
ab3721
+/*
ab3721
+ * nfsiostat-sysstat: Report NFS I/O statistics
ab3721
+ * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved
ab3721
+ * Written by Ivana Varekova <varekova@redhat.com>
ab3721
+ */
ab3721
+
ab3721
+#ifndef _NFSIOSTAT_SYSSTAT_H
ab3721
+#define _NFSIOSTAT_SYSSTAT_H
ab3721
+
ab3721
+#include "common.h"
ab3721
+
ab3721
+#define NFSMOUNTSTATS  "/proc/self/mountstats"
ab3721
+
ab3721
+/* I_: iostat - D_: Display - F_: Flag */
ab3721
+#define I_D_TIMESTAMP		0x001
ab3721
+#define I_D_KILOBYTES		0x002
ab3721
+#define I_D_MEGABYTES		0x004
ab3721
+#define I_D_ISO			0x008
ab3721
+#define I_D_HUMAN_READ		0x010
ab3721
+#define I_D_DEBUG		0x020
ab3721
+
ab3721
+#define DISPLAY_TIMESTAMP(m)	(((m) & I_D_TIMESTAMP)     == I_D_TIMESTAMP)
ab3721
+#define DISPLAY_KILOBYTES(m)	(((m) & I_D_KILOBYTES)     == I_D_KILOBYTES)
ab3721
+#define DISPLAY_MEGABYTES(m)	(((m) & I_D_MEGABYTES)     == I_D_MEGABYTES)
ab3721
+#define DISPLAY_ISO(m)		(((m) & I_D_ISO)           == I_D_ISO)
ab3721
+#define DISPLAY_HUMAN_READ(m)	(((m) & I_D_HUMAN_READ)    == I_D_HUMAN_READ)
ab3721
+#define DISPLAY_DEBUG(m)	(((m) & I_D_DEBUG)         == I_D_DEBUG)
ab3721
+
ab3721
+/* Environment variable */
ab3721
+#define ENV_POSIXLY_CORRECT	"POSIXLY_CORRECT"
ab3721
+
ab3721
+/* Preallocation constats */
ab3721
+#define NR_NFS_PREALLOC	2
ab3721
+
ab3721
+struct io_nfs_stats {
ab3721
+	unsigned long long rd_normal_bytes	__attribute__ ((aligned (8)));
ab3721
+	unsigned long long wr_normal_bytes	__attribute__ ((packed));
ab3721
+	unsigned long long rd_direct_bytes	__attribute__ ((packed));
ab3721
+	unsigned long long wr_direct_bytes	__attribute__ ((packed));
ab3721
+	unsigned long long rd_server_bytes	__attribute__ ((packed));
ab3721
+	unsigned long long wr_server_bytes	__attribute__ ((packed));
ab3721
+	unsigned long rpc_sends			__attribute__ ((packed));
ab3721
+	unsigned long nfs_rops			__attribute__ ((packed));
ab3721
+	unsigned long nfs_wops			__attribute__ ((packed));
ab3721
+};
ab3721
+
ab3721
+#define IO_NFS_STATS_SIZE	(sizeof(struct io_nfs_stats))
ab3721
+
ab3721
+struct io_hdr_stats {
ab3721
+	unsigned int active		__attribute__ ((aligned (4)));
ab3721
+	unsigned int used		__attribute__ ((packed));
ab3721
+	char name[MAX_NAME_LEN];
ab3721
+};
ab3721
+
ab3721
+#define IO_HDR_STATS_SIZE	(sizeof(struct io_hdr_stats))
ab3721
+
ab3721
+#endif  /* _NFSIOSTAT_SYSSTAT_H */