summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorSteve Dickson <steved@redhat.com>2009-04-04 06:46:09 -0400
committerSteve Dickson <steved@redhat.com>2009-04-04 06:46:09 -0400
commit524cdc4eb1663e5c10d12160e48c45dc81852568 (patch)
tree2440d0d5176ff309cdff0237fcd029126bb350eb /utils
parentd2319b9cabc67d999b16aea2077a4a3c642ec28d (diff)
downloadnfs-utils-524cdc4eb1663e5c10d12160e48c45dc81852568.tar.gz
nfs-utils-524cdc4eb1663e5c10d12160e48c45dc81852568.tar.xz
nfs-utils-524cdc4eb1663e5c10d12160e48c45dc81852568.zip
Keep the interval output quite when there is no NFS traffic.
The 'nfsstat -Z5' command continually outputs the following when there is no NFS traffic. Client rpc stats: calls retrans authrefrsh 0 0 0 This patch adds code that will keep the interval output quite so real results will not be scrolled of the screen Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/nfsstat/nfsstat.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/utils/nfsstat/nfsstat.c b/utils/nfsstat/nfsstat.c
index 453d345..7906b09 100644
--- a/utils/nfsstat/nfsstat.c
+++ b/utils/nfsstat/nfsstat.c
@@ -184,6 +184,7 @@ static int mounts(const char *);
static void get_stats(const char *, struct statinfo *, int *, int,
int);
static int has_stats(const unsigned int *);
+static int has_rpcstats(const unsigned int *, int);
static void diff_stats(struct statinfo *, struct statinfo *, int);
static void unpause(int);
static void update_old_counters(struct statinfo *, struct statinfo *);
@@ -256,6 +257,7 @@ static struct option longopts[] =
{ "since", 1, 0, 'S' },
{ NULL, 0, 0, 0 }
};
+int opt_sleep;
int
main(int argc, char **argv)
@@ -264,7 +266,6 @@ main(int argc, char **argv)
opt_srv = 0,
opt_clt = 0,
opt_prt = 0,
- opt_sleep = 0,
sleep_time = 0,
opt_since = 0;
int c;
@@ -458,12 +459,14 @@ print_server_stats(int opt_srv, int opt_prt)
printf("\n");
}
if (opt_prt & PRNT_RPC) {
- print_numbers(
- LABEL_srvrpc
- "calls badcalls badauth badclnt xdrcall\n",
- srvrpcinfo, 5
- );
- printf("\n");
+ if (!opt_sleep && !has_rpcstats(srvrpcinfo, 5)) {
+ print_numbers(
+ LABEL_srvrpc
+ "calls badcalls badauth badclnt xdrcall\n",
+ srvrpcinfo, 5
+ );
+ printf("\n");
+ }
}
if (opt_prt & PRNT_RC) {
print_numbers(
@@ -536,12 +539,14 @@ print_client_stats(int opt_clt, int opt_prt)
printf("\n");
}
if (opt_prt & PRNT_RPC) {
- print_numbers(
- LABEL_cltrpc
- "calls retrans authrefrsh\n",
- cltrpcinfo, 3
- );
- printf("\n");
+ if (!opt_sleep && !has_rpcstats(cltrpcinfo, 3)) {
+ print_numbers(
+ LABEL_cltrpc
+ "calls retrans authrefrsh\n",
+ cltrpcinfo, 3
+ );
+ printf("\n");
+ }
}
if (opt_prt & PRNT_CALLS) {
if ((opt_prt & PRNT_V2) || ((opt_prt & PRNT_AUTO) && has_stats(cltproc2info)))
@@ -836,6 +841,15 @@ has_stats(const unsigned int *info)
{
return (info[0] && info[info[0] + 1] > info[0]);
}
+static int
+has_rpcstats(const unsigned int *info, int size)
+{
+ int i, cnt;
+
+ for (i=0, cnt=0; i < size; i++)
+ cnt += info[i];
+ return cnt;
+}
/*
* take the difference of each individual stat value in 'new' and 'old'