2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * This file contains sample code for the rxstats interface
18 #include <afs/afs_Admin.h>
19 #include <afs/afs_AdminErrors.h>
20 #include <afs/afs_clientAdmin.h>
21 #include <afs/afs_utilAdmin.h>
22 #include <rx/rxstat.h>
23 #include <afs/afsint.h>
24 #define FSINT_COMMON_XG
25 #include <afs/afscbint.h>
26 #include <afs/kauth.h>
27 #include <afs/kautils.h>
28 #include <afs/ptint.h>
29 #include <afs/ptserver.h>
30 #include <afs/vldbint.h>
31 #include <afs/bosint.h>
32 #include <afs/volint.h>
33 #include <afs/volser.h>
34 #include <afs/bosint.h>
38 extern int RXSTATS_RetrieveProcessRPCStats();
43 "Usage: rxstat_get_process <cell> <host> <port>\n");
57 *srvrName = *(argp++);
60 *srvrPort = strtol(*(argp++), NULL, 0);
61 if (*srvrPort <= 0 || *srvrPort >= 65536)
71 const char ***funcList,
74 if (statp->s.stats_v1.remote_is_server) {
75 strcpy(ifRole, "client");
77 strcpy(ifRole, "server");
80 switch(statp->s.stats_v1.interfaceId) {
81 case RXSTATS_STATINDEX:
82 strcpy(ifName, "rxstats interface");
83 *funcList = RXSTATS_function_names;
84 *funcListLen = RXSTATS_NO_OF_STAT_FUNCS;
87 strcpy(ifName, "fileserver interface");
88 *funcList = RXAFS_function_names;
89 *funcListLen = RXAFS_NO_OF_STAT_FUNCS;
91 case RXAFSCB_STATINDEX:
92 strcpy(ifName, "callback interface");
93 *funcList = RXAFSCB_function_names;
94 *funcListLen = RXAFSCB_NO_OF_STAT_FUNCS;
97 strcpy(ifName, "ptserver interface");
98 *funcList = PR_function_names;
99 *funcListLen = PR_NO_OF_STAT_FUNCS;
102 strcpy(ifName, "ubik disk interface");
103 *funcList = DISK_function_names;
104 *funcListLen = DISK_NO_OF_STAT_FUNCS;
107 strcpy(ifName, "ubik vote interface");
108 *funcList = VOTE_function_names;
109 *funcListLen = VOTE_NO_OF_STAT_FUNCS;
112 strcpy(ifName, "volserver interface");
113 *funcList = VL_function_names;
114 *funcListLen = VL_NO_OF_STAT_FUNCS;
116 case AFSVolSTATINDEX:
117 strcpy(ifName, "volserver interface");
118 *funcList = AFSVolfunction_names;
119 *funcListLen = AFSVolNO_OF_STAT_FUNCS;
122 strcpy(ifName, "bosserver interface");
123 *funcList = BOZO_function_names;
124 *funcListLen = BOZO_NO_OF_STAT_FUNCS;
127 strcpy(ifName, "KAA interface");
128 *funcList = KAA_function_names;
129 *funcListLen = KAA_NO_OF_STAT_FUNCS;
132 strcpy(ifName, "KAM interface");
133 *funcList = KAM_function_names;
134 *funcListLen = KAM_NO_OF_STAT_FUNCS;
137 strcpy(ifName, "KAT interface");
138 *funcList = KAT_function_names;
139 *funcListLen = KAT_NO_OF_STAT_FUNCS;
142 sprintf(ifName, "interface 0x%x", statp->s.stats_v1.interfaceId);
149 int main(int argc, char *argv[])
153 struct rx_connection *conn;
158 afs_RPCStats_t stats;
161 const char **funcList;
165 ParseArgs(argc, argv, &srvrName, &srvrPort);
167 rc = afsclient_Init(&st);
169 fprintf(stderr, "afsclient_Init, status %d\n", st);
173 rc = afsclient_NullCellOpen(&cellHandle, &st);
175 fprintf(stderr, "afsclient_NullCellOpen, status %d\n", st);
179 rc = afsclient_RPCStatOpenPort(cellHandle, srvrName, srvrPort, &conn, &st);
181 fprintf(stderr, "afsclient_RPCStatOpenPort, status %d\n", st);
185 rc = util_RPCStatsGetBegin(conn, RXSTATS_RetrieveProcessRPCStats,
188 fprintf(stderr, "util_RPCStatsGetBegin, status %d\n", st);
192 while (util_RPCStatsGetNext(iterator, &stats, &st)) {
193 index = stats.s.stats_v1.func_index;
196 GetPrintStrings(&stats, ifName, role, &funcList, &funcListLen);
197 printf("\nProcess RPC stats for %s accessed as a %s\n\n",
201 if (index >= funcListLen) {
202 printf(" Function index %d\n", index);
204 printf(" %s\n", funcList[index]);
207 if (!hiszero(stats.s.stats_v1.invocations)) {
208 printf("\tinvoc (%u.%u) bytes_sent (%u.%u) bytes_rcvd (%u.%u)\n",
209 hgethi(stats.s.stats_v1.invocations),
210 hgetlo(stats.s.stats_v1.invocations),
211 hgethi(stats.s.stats_v1.bytes_sent),
212 hgetlo(stats.s.stats_v1.bytes_sent),
213 hgethi(stats.s.stats_v1.bytes_rcvd),
214 hgetlo(stats.s.stats_v1.bytes_rcvd));
215 printf("\tqsum %d.%06d qsqr %d.%06d"
216 " qmin %d.%06d qmax %d.%06d\n",
217 stats.s.stats_v1.queue_time_sum.sec,
218 stats.s.stats_v1.queue_time_sum.usec,
219 stats.s.stats_v1.queue_time_sum_sqr.sec,
220 stats.s.stats_v1.queue_time_sum_sqr.usec,
221 stats.s.stats_v1.queue_time_min.sec,
222 stats.s.stats_v1.queue_time_min.usec,
223 stats.s.stats_v1.queue_time_max.sec,
224 stats.s.stats_v1.queue_time_max.usec);
225 printf("\txsum %d.%06d xsqr %d.%06d"
226 " xmin %d.%06d xmax %d.%06d\n",
227 stats.s.stats_v1.execution_time_sum.sec,
228 stats.s.stats_v1.execution_time_sum.usec,
229 stats.s.stats_v1.execution_time_sum_sqr.sec,
230 stats.s.stats_v1.execution_time_sum_sqr.usec,
231 stats.s.stats_v1.execution_time_min.sec,
232 stats.s.stats_v1.execution_time_min.usec,
233 stats.s.stats_v1.execution_time_max.sec,
234 stats.s.stats_v1.execution_time_max.usec);
236 printf("\tNever invoked\n");
239 if (st != ADMITERATORDONE) {
240 fprintf(stderr, "util_RPCStatsGetNext, status %d\n", st);
245 rc = util_RPCStatsGetDone(iterator, &st);
247 fprintf(stderr, "util_RPCStatsGetDone, status %d\n", st);
251 rc = afsclient_RPCStatClose(conn, &st);
253 fprintf(stderr, "afsclient_RPCStatClose, status %d\n", st);
257 rc = afsclient_CellClose(cellHandle, &st);
259 fprintf(stderr, "afsclient_CellClose, status %d\n", st);