-static unsigned int svcv4opinfo[42];/* NFSv4 call counts ([0] == 40) */
-static unsigned int svcnetinfo[5]; /* 0 # of received packets
+static unsigned int srvv4opinfo[42];/* NFSv4 call counts ([0] == 40) */
+static unsigned int srvnetinfo[5]; /* 0 # of received packets
"fsstat", "fsinfo", "pathconf", "commit"
};
"fsstat", "fsinfo", "pathconf", "commit"
};
"statfs", "readlink", "readdir", "server_caps", "delegreturn",
};
"statfs", "readlink", "readdir", "server_caps", "delegreturn",
};
"op0-unused", "op1-unused", "op2-future", "access", "close", "commit",
"create", "delegpurge", "delegreturn", "getattr", "getfh", "link",
"lock", "lockt", "locku", "lookup", "lookup_root", "nverify",
"op0-unused", "op1-unused", "op2-future", "access", "close", "commit",
"create", "delegpurge", "delegreturn", "getattr", "getfh", "link",
"lock", "lockt", "locku", "lookup", "lookup_root", "nverify",
-static statinfo svcinfo[] = {
- { "net", STRUCTSIZE(svcnetinfo), svcnetinfo },
- { "rpc", STRUCTSIZE(svcrpcinfo), svcrpcinfo },
- { "rc", STRUCTSIZE(svcrcinfo), svcrcinfo },
- { "fh", STRUCTSIZE(svcfhinfo), svcfhinfo },
- { "proc2", STRUCTSIZE(svcv2info), svcv2info },
- { "proc3", STRUCTSIZE(svcv3info), svcv3info },
- { "proc4", STRUCTSIZE(svcv4info), svcv4info },
- { "proc4ops", STRUCTSIZE(svcv4opinfo),svcv4opinfo},
+static statinfo srvinfo[] = {
+ { "net", STRUCTSIZE(srvnetinfo), srvnetinfo },
+ { "rpc", STRUCTSIZE(srvrpcinfo), srvrpcinfo },
+ { "rc", STRUCTSIZE(srvrcinfo), srvrcinfo },
+ { "fh", STRUCTSIZE(srvfhinfo), srvfhinfo },
+ { "proc2", STRUCTSIZE(srvv2info), srvv2info },
+ { "proc3", STRUCTSIZE(srvv3info), srvv3info },
+ { "proc4", STRUCTSIZE(srvv4info), srvv4info },
+ { "proc4ops", STRUCTSIZE(srvv4opinfo),srvv4opinfo},
-static int mounts(const char *);
+static int mounts(const char *);
+
+static void get_stats(const char *, statinfo *, int *, int, const char *);
+static int has_stats(const unsigned int *);
- if (opt_srv) {
- srv_info = parse_statfile(NFSSVCSTAT, svcinfo);
- if (srv_info == 0 && opt_clt == 0) {
- fprintf(stderr, "Warning: No Server Stats (%s: %m).\n", NFSSVCSTAT);
- return 2;
- }
- if (srv_info == 0)
- opt_srv = 0;
- }
-
- if (opt_clt) {
- clt_info = parse_statfile(NFSCLTSTAT, cltinfo);
- if (opt_srv == 0 && clt_info == 0) {
- fprintf(stderr, "Warning: No Client Stats (%s: %m).\n", NFSCLTSTAT);
- return 2;
- }
- if (clt_info == 0)
- opt_clt = 0;
- }
+ if (opt_srv)
+ get_stats(NFSSRVSTAT, srvinfo, &opt_srv, opt_clt, "Server");
+ if (opt_clt)
+ get_stats(NFSCLTSTAT, cltinfo, &opt_clt, opt_srv, "Client");
if (opt_srv) {
if (opt_prt & PRNT_NET) {
print_numbers(
"Server packet stats:\n"
"packets udp tcp tcpconn\n",
if (opt_srv) {
if (opt_prt & PRNT_NET) {
print_numbers(
"Server packet stats:\n"
"packets udp tcp tcpconn\n",
- if (get_stat_info("fh", svcinfo)) { /* >= 2.4 */
- int t = svcfhinfo[3];
- svcfhinfo[3]=svcfhinfo[4];
- svcfhinfo[4]=t;
+ if (get_stat_info("fh", srvinfo)) { /* >= 2.4 */
+ int t = srvfhinfo[3];
+ srvfhinfo[3]=srvfhinfo[4];
+ srvfhinfo[4]=t;
print_numbers(
"Server file handle cache:\n"
"lookup anon ncachedir ncachedir stale\n",
print_numbers(
"Server file handle cache:\n"
"lookup anon ncachedir ncachedir stale\n",
} else /* < 2.4 */
print_numbers(
"Server file handle cache:\n"
"lookup anon ncachedir ncachedir stale\n",
} else /* < 2.4 */
print_numbers(
"Server file handle cache:\n"
"lookup anon ncachedir ncachedir stale\n",
+
+static void
+get_stats(const char *file, statinfo *info, int *opt, int other_opt, const char *label)
+{
+ if (!parse_statfile(file, info)) {
+ if (!other_opt) {
+ fprintf(stderr, "Warning: No %s Stats (%s: %m). \n", label, file);
+ exit(2);
+ }
+ *opt = 0;
+ }
+}
+
+static int
+has_stats(const unsigned int *info)
+{
+ return (info[0] && info[info[0] + 1] != info[0]);
+}