[PATCH 1/3] nfsstat: The --list option does not work on server stats.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>

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)
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux