From: Sebastien Godard Date: Tue, 7 Dec 2010 10:05:35 +0000 (+0100) Subject: nfsiostat now takes into account POSIXLY_CORRECT environment variable. X-Git-Tag: v9.1.7~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65d4ecadd9907ead2302f3650e6f5612b115a66e;p=sysstat nfsiostat now takes into account POSIXLY_CORRECT environment variable. nfsiostat default output is now expressed in kB/s, unless the variable POSIXLY_CORRECT is set (in which case the output is expressed in blocks/s). --- diff --git a/CHANGES b/CHANGES index 2b8f07d..9b97825 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,10 @@ xxxx/xx/xx: Version 9.1.7 - Sebastien Godard (sysstat orange.fr) * Fixed bogus CPU statistics output, which happened when CPU user value from /proc/stat wasn't incremented whereas CPU guest value was. + * nfsiostat now takes into account POSIXLY_CORRECT environment + variable. nfsiostat default output is expressed in kB/s, + unless this variable is set (in which case the output is + expressed in blocks/s). * sar manual page updated. * Code cleaned. diff --git a/man/nfsiostat.1 b/man/nfsiostat.1 index ec667ba..d5ca985 100644 --- a/man/nfsiostat.1 +++ b/man/nfsiostat.1 @@ -1,4 +1,4 @@ -.TH NFSIOSTAT 1 "JULY 2010" Linux "Linux User's Manual" -*- nroff -*- +.TH NFSIOSTAT 1 "DECEMBER 2010" Linux "Linux User's Manual" -*- nroff -*- .SH NAME nfsiostat \- Report input/output statistics for network filesystems (NFS). .SH SYNOPSIS @@ -41,6 +41,8 @@ command generates reports continuously. .SH REPORT The Network Filesystem (NFS) report provides statistics for each mounted network filesystem. +Transfer rates are shown in 1K blocks by default, unless the environment +variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used. The report shows the following fields: .B Filesystem: @@ -132,6 +134,10 @@ command will use the ISO 8601 format (YYYY-MM-DD) instead. The timestamp displayed with option -t will also be compliant with ISO 8601 format. +.IP POSIXLY_CORRECT +When this variable is set, transfer rates are shown in 512-byte blocks instead +of the default 1K blocks. + .SH BUG .I /proc filesystem must be mounted for diff --git a/nfsiostat.c b/nfsiostat.c index 05a7dfa..f9efdbb 100644 --- a/nfsiostat.c +++ b/nfsiostat.c @@ -73,6 +73,27 @@ void usage(char *progname) exit(1); } +/* + *************************************************************************** + * Set output unit. Unit will be kB/s unless POSIXLY_CORRECT + * environment variable has been set, in which case the output will be + * expressed in blocks/s. + *************************************************************************** + */ +void set_output_unit(void) +{ + char *e; + + if (DISPLAY_KILOBYTES(flags) || DISPLAY_MEGABYTES(flags)) + return; + + /* Check POSIXLY_CORRECT environment variable */ + if ((e = getenv(ENV_POSIXLY_CORRECT)) == NULL) { + /* Variable not set: Unit is kB/s and not blocks/s */ + flags |= I_D_KILOBYTES; + } +} + /* *************************************************************************** * SIGALRM signal handler. @@ -627,6 +648,9 @@ int main(int argc, char **argv) count = 1; } + /* Select output unit (kB/s or blocks/s) */ + set_output_unit(); + /* Init structures according to machine architecture */ io_sys_init(); diff --git a/nfsiostat.h b/nfsiostat.h index 6315e89..d08f40b 100644 --- a/nfsiostat.h +++ b/nfsiostat.h @@ -24,6 +24,9 @@ #define DISPLAY_ISO(m) (((m) & I_D_ISO) == I_D_ISO) #define DISPLAY_HUMAN_READ(m) (((m) & I_D_HUMAN_READ) == I_D_HUMAN_READ) +/* Environment variable */ +#define ENV_POSIXLY_CORRECT "POSIXLY_CORRECT" + /* Preallocation constats */ #define NR_NFS_PREALLOC 2