summaryrefslogtreecommitdiffstats
path: root/utils/nfsstat
diff options
context:
space:
mode:
authorSteve Dickson <steved@redhat.com>2009-04-08 10:26:26 -0400
committerSteve Dickson <steved@redhat.com>2009-04-08 10:26:26 -0400
commitfa5352f78533c7ad1d8603c1a4ba08fa82768e6b (patch)
tree25450219322a99638ccaaca5d3ec176390d2f64c /utils/nfsstat
parent500fab45f73c0ba1bc442157ef3d7744f20e6b2a (diff)
downloadnfs-utils-fa5352f78533c7ad1d8603c1a4ba08fa82768e6b.tar.gz
nfs-utils-fa5352f78533c7ad1d8603c1a4ba08fa82768e6b.tar.xz
nfs-utils-fa5352f78533c7ad1d8603c1a4ba08fa82768e6b.zip
The --list option does not work on server stats.
The print_stats_list() routine was using the client's stats to decide whether to display any stats. This did not work when there was only server stats. This patch breaks up print_stats_list into two different routines allowing both server and clients stats to be listed. Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'utils/nfsstat')
-rw-r--r--utils/nfsstat/nfsstat.c109
1 files changed, 80 insertions, 29 deletions
diff --git a/utils/nfsstat/nfsstat.c b/utils/nfsstat/nfsstat.c
index 5adb571..7e9f327 100644
--- a/utils/nfsstat/nfsstat.c
+++ b/utils/nfsstat/nfsstat.c
@@ -170,7 +170,7 @@ DECLARE_CLT(cltinfo, _old);
static void print_all_stats(int, int, int);
static void print_server_stats(int, int);
static void print_client_stats(int, int);
-static void print_stats_list(int);
+static void print_stats_list(int, int, int);
static void print_numbers(const char *, unsigned int *,
unsigned int);
static void print_callstats(const char *, const char **,
@@ -436,7 +436,7 @@ main(int argc, char **argv)
diff_stats(clientinfo_tmp, clientinfo, 0);
}
if (opt_list) {
- print_stats_list(opt_prt);
+ print_stats_list(opt_srv, opt_clt, opt_prt);
} else {
print_all_stats(opt_srv, opt_clt, opt_prt);
}
@@ -451,7 +451,7 @@ main(int argc, char **argv)
}
} else {
if (opt_list) {
- print_stats_list(opt_prt);
+ print_stats_list(opt_srv, opt_clt, opt_prt);
} else {
print_all_stats(opt_srv, opt_clt, opt_prt);
}
@@ -606,7 +606,7 @@ print_client_stats(int opt_clt, int opt_prt)
if (opt_sleep && !has_stats(cltproc3info)) {
;
} else {
- print_callstats( LABEL_cltproc3,
+ print_callstats(LABEL_cltproc3,
nfsv3name, cltproc3info + 1,
sizeof(nfsv3name)/sizeof(char *));
}
@@ -625,38 +625,89 @@ print_client_stats(int opt_clt, int opt_prt)
}
static void
-print_stats_list(int opt_prt)
+print_clnt_list(int opt_prt)
{
if (opt_prt & PRNT_CALLS) {
- if ((opt_prt & PRNT_V2) || ((opt_prt & PRNT_AUTO) && has_stats(cltproc2info))) {
- print_callstats_list(
- "nfs v2 server",
- nfsv2name, srvproc2info + 1, sizeof(nfsv2name)/sizeof(char *));
- print_callstats_list(
- "nfs v2 client",
- nfsv2name, cltproc2info + 1, sizeof(nfsv2name)/sizeof(char *));
+ if ((opt_prt & PRNT_V2) ||
+ ((opt_prt & PRNT_AUTO) && has_stats(cltproc2info))) {
+ if (opt_sleep && !has_stats(cltproc2info)) {
+ ;
+ } else {
+ print_callstats_list("nfs v2 client",
+ nfsv2name, cltproc2info + 1,
+ sizeof(nfsv2name)/sizeof(char *));
+ }
+ }
+ if ((opt_prt & PRNT_V3) ||
+ ((opt_prt & PRNT_AUTO) && has_stats(cltproc3info))) {
+ if (opt_sleep && !has_stats(cltproc3info)) {
+ ;
+ } else {
+ print_callstats_list("nfs v3 client",
+ nfsv3name, cltproc3info + 1,
+ sizeof(nfsv3name)/sizeof(char *));
+ }
+ }
+ if ((opt_prt & PRNT_V4) ||
+ ((opt_prt & PRNT_AUTO) && has_stats(cltproc4info))) {
+ if (opt_sleep && !has_stats(cltproc4info)) {
+ ;
+ } else {
+ print_callstats_list("nfs v4 ops",
+ nfssrvproc4opname, srvproc4opsinfo + 1,
+ sizeof(nfssrvproc4opname)/sizeof(char *));
+ print_callstats_list("nfs v4 client",
+ nfscltproc4name, cltproc4info + 1,
+ sizeof(nfscltproc4name)/sizeof(char *));
+ }
+ }
+ }
+}
+static void
+print_serv_list(int opt_prt)
+{
+ if (opt_prt & PRNT_CALLS) {
+ if ((opt_prt & PRNT_V2) ||
+ ((opt_prt & PRNT_AUTO) && has_stats(srvproc2info))) {
+ if (opt_sleep && !has_stats(srvproc2info)) {
+ ;
+ } else {
+ print_callstats_list("nfs v2 server",
+ nfsv2name, srvproc2info + 1,
+ sizeof(nfsv2name)/sizeof(char *));
+ }
}
- if ((opt_prt & PRNT_V3) || ((opt_prt & PRNT_AUTO) && has_stats(cltproc3info))) {
- print_callstats_list(
- "nfs v3 server",
- nfsv3name, srvproc3info + 1, sizeof(nfsv3name)/sizeof(char *));
- print_callstats_list(
- "nfs v3 client",
- nfsv3name, cltproc3info + 1, sizeof(nfsv3name)/sizeof(char *));
+ if ((opt_prt & PRNT_V3) ||
+ ((opt_prt & PRNT_AUTO) && has_stats(srvproc3info))) {
+ if (opt_sleep && !has_stats(srvproc3info)) {
+ ;
+ } else {
+ print_callstats_list("nfs v3 server",
+ nfsv3name, srvproc3info + 1,
+ sizeof(nfsv3name)/sizeof(char *));
+ }
}
- if ((opt_prt & PRNT_V4) || ((opt_prt & PRNT_AUTO) && has_stats(cltproc4info))) {
- print_callstats_list(
- "nfs v4 server",
- nfssrvproc4name, srvproc4info + 1, sizeof(nfssrvproc4name)/sizeof(char *));
- print_callstats_list(
- "nfs v4 ops",
- nfssrvproc4opname, srvproc4opsinfo + 1, sizeof(nfssrvproc4opname)/sizeof(char *));
- print_callstats_list(
- "nfs v4 client",
- nfscltproc4name, cltproc4info + 1, sizeof(nfscltproc4name)/sizeof(char *));
+ if ((opt_prt & PRNT_V4) ||
+ ((opt_prt & PRNT_AUTO) && has_stats(srvproc4opsinfo))) {
+ if (opt_sleep && !has_stats(srvproc4info)) {
+ ;
+ } else {
+ print_callstats_list("nfs v4 ops",
+ nfssrvproc4opname, srvproc4opsinfo + 1,
+ sizeof(nfssrvproc4opname)/sizeof(char *));
+ }
}
}
}
+static void
+print_stats_list(int opt_srv, int opt_clt, int opt_prt)
+{
+ if (opt_srv)
+ print_serv_list(opt_prt);
+
+ if (opt_clt)
+ print_clnt_list(opt_prt);
+}
static statinfo *
get_stat_info(const char *sp, struct statinfo *statp)