8a8c4bea7f74ca835db6d25515ca21401305e8f0
[openafs.git] / src / xstat / xstat_cm_test.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 /*
11  * Description:
12  *      Test of the xstat_cm module.
13  *
14  *------------------------------------------------------------------------*/
15
16 #include <afsconfig.h>
17 #include <afs/param.h>
18
19
20 #include "xstat_cm.h"           /*Interface for xstat_cm module */
21 #include <cmd.h>                /*Command line interpreter */
22 #include <time.h>
23 #include <string.h>
24
25 /*
26  * External routines that don't have explicit include file definitions.
27  */
28 extern struct hostent *hostutil_GetHostByName();
29
30 /*
31  * Command line parameter indices.
32  *      P_CM_NAMES : List of CacheManager names.
33  *      P_COLL_IDS : List of collection IDs to pick up.
34  *      P_ONESHOT  : Are we gathering exactly one round of data?
35  *      P_DEBUG    : Enable debugging output?
36  */
37 #define P_CM_NAMES      0
38 #define P_COLL_IDS      1
39 #define P_ONESHOT       2
40 #define P_FREQUENCY     3
41 #define P_PERIOD        4
42 #define P_DEBUG         5
43
44 /*
45  * Private globals.
46  */
47 static int debugging_on = 0;    /*Are we debugging? */
48 static int one_shot = 0;        /*Single round of data collection? */
49
50 static char *fsOpNames[] = {
51     "FetchData",
52     "FetchACL",
53     "FetchStatus",
54     "StoreData",
55     "StoreACL",
56     "StoreStatus",
57     "RemoveFile",
58     "CreateFile",
59     "Rename",
60     "Symlink",
61     "Link",
62     "MakeDir",
63     "RemoveDir",
64     "SetLock",
65     "ExtendLock",
66     "ReleaseLock",
67     "GetStatistics",
68     "GiveUpCallbacks",
69     "GetVolumeInfo",
70     "GetVolumeStatus",
71     "SetVolumeStatus",
72     "GetRootVolume",
73     "CheckToken",
74     "GetTime",
75     "NGetVolumeInfo",
76     "BulkStatus",
77     "XStatsVersion",
78     "GetXStats",
79     "XLookup"
80 };
81
82 static char *cmOpNames[] = {
83     "CallBack",
84     "InitCallBackState",
85     "Probe",
86     "GetLock",
87     "GetCE",
88     "XStatsVersion",
89     "GetXStats"
90 };
91
92 static char *xferOpNames[] = {
93     "FetchData",
94     "StoreData"
95 };
96
97
98 /*------------------------------------------------------------------------
99  * PrintCallInfo
100  *
101  * Description:
102  *      Print out the AFSCB_XSTATSCOLL_PERF_INFO collection we just
103  *      received.
104  *
105  * Arguments:
106  *      None.
107  *
108  * Returns:
109  *      Nothing.
110  *
111  * Environment:
112  *      All the info we need is nestled into xstat_cm_Results.
113  *
114  * Side Effects:
115  *      As advertised.
116  *------------------------------------------------------------------------*/
117
118 void
119 PrintCallInfo()
120 {                               /*PrintCallInfo */
121
122     static char rn[] = "PrintCallInfo"; /*Routine name */
123     register int i;             /*Loop variable */
124     int numInt32s;              /*# int32words returned */
125     afs_int32 *currInt32;       /*Ptr to current afs_int32 value */
126     char *printableTime;        /*Ptr to printable time string */
127     time_t probeTime = xstat_cm_Results.probeTime;
128     /*
129      * Just print out the results of the particular probe.
130      */
131     numInt32s = xstat_cm_Results.data.AFSCB_CollData_len;
132     currInt32 = (afs_int32 *) (xstat_cm_Results.data.AFSCB_CollData_val);
133     printableTime = ctime(&probeTime);
134     printableTime[strlen(printableTime) - 1] = '\0';
135
136     printf
137         ("AFSCB_XSTATSCOLL_CALL_INFO (coll %d) for CM %s\n[Poll %d, %s]\n\n",
138          xstat_cm_Results.collectionNumber, xstat_cm_Results.connP->hostName,
139          xstat_cm_Results.probeNum, printableTime);
140
141     if (debugging_on)
142         printf("\n[%d entries returned at 0x%x]\n\n", numInt32s, currInt32);
143
144     for (i = 0; i < numInt32s; i++)
145         printf("%d ", *currInt32++);
146     printf("\n");
147
148
149 }                               /*PrintCallInfo */
150
151 /* Print detailed functional call statistics */
152
153 void
154 print_cmCallStats()
155 {
156     static char rn[] = "print_cmCallStats";     /*Routine name */
157     char *printableTime;        /*Ptr to printable time string */
158     struct afs_CMStats *cmp;
159     time_t probeTime = xstat_cm_Results.probeTime;
160
161     printableTime = ctime(&probeTime);
162     printableTime[strlen(printableTime) - 1] = '\0';
163
164     printf
165         ("AFSCB_XSTATSCOLL_CALL_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
166          xstat_cm_Results.collectionNumber, xstat_cm_Results.connP->hostName,
167          xstat_cm_Results.probeNum, printableTime);
168
169     cmp = (struct afs_CMStats *)(xstat_cm_Results.data.AFSCB_CollData_val);
170
171     printf("\t%10d afs_init\n", cmp->callInfo.C_afs_init);
172     printf("\t%10d gop_rdwr\n", cmp->callInfo.C_gop_rdwr);
173     printf("\t%10d aix_gnode_rele\n", cmp->callInfo.C_aix_gnode_rele);
174     printf("\t%10d gettimeofday\n", cmp->callInfo.C_gettimeofday);
175     printf("\t%10d m_cpytoc\n", cmp->callInfo.C_m_cpytoc);
176     printf("\t%10d aix_vattr_null\n", cmp->callInfo.C_aix_vattr_null);
177     printf("\t%10d afs_gn_frunc\n", cmp->callInfo.C_afs_gn_ftrunc);
178     printf("\t%10d afs_gn_rdwr\n", cmp->callInfo.C_afs_gn_rdwr);
179     printf("\t%10d afs_gn_ioctl\n", cmp->callInfo.C_afs_gn_ioctl);
180     printf("\t%10d afs_gn_locktl\n", cmp->callInfo.C_afs_gn_lockctl);
181     printf("\t%10d afs_gn_readlink\n", cmp->callInfo.C_afs_gn_readlink);
182     printf("\t%10d afs_gn_readdir\n", cmp->callInfo.C_afs_gn_readdir);
183     printf("\t%10d afs_gn_select\n", cmp->callInfo.C_afs_gn_select);
184     printf("\t%10d afs_gn_strategy\n", cmp->callInfo.C_afs_gn_strategy);
185     printf("\t%10d afs_gn_symlink\n", cmp->callInfo.C_afs_gn_symlink);
186     printf("\t%10d afs_gn_revoke\n", cmp->callInfo.C_afs_gn_revoke);
187     printf("\t%10d afs_gn_link\n", cmp->callInfo.C_afs_gn_link);
188     printf("\t%10d afs_gn_mkdir\n", cmp->callInfo.C_afs_gn_mkdir);
189     printf("\t%10d afs_gn_mknod\n", cmp->callInfo.C_afs_gn_mknod);
190     printf("\t%10d afs_gn_remove\n", cmp->callInfo.C_afs_gn_remove);
191     printf("\t%10d afs_gn_rename\n", cmp->callInfo.C_afs_gn_rename);
192     printf("\t%10d afs_gn_rmdir\n", cmp->callInfo.C_afs_gn_rmdir);
193     printf("\t%10d afs_gn_fid\n", cmp->callInfo.C_afs_gn_fid);
194     printf("\t%10d afs_gn_lookup\n", cmp->callInfo.C_afs_gn_lookup);
195     printf("\t%10d afs_gn_open\n", cmp->callInfo.C_afs_gn_open);
196     printf("\t%10d afs_gn_create\n", cmp->callInfo.C_afs_gn_create);
197     printf("\t%10d afs_gn_hold\n", cmp->callInfo.C_afs_gn_hold);
198     printf("\t%10d afs_gn_rele\n", cmp->callInfo.C_afs_gn_rele);
199     printf("\t%10d afs_gn_unmap\n", cmp->callInfo.C_afs_gn_unmap);
200     printf("\t%10d afs_gn_access\n", cmp->callInfo.C_afs_gn_access);
201     printf("\t%10d afs_gn_getattr\n", cmp->callInfo.C_afs_gn_getattr);
202     printf("\t%10d afs_gn_setattr\n", cmp->callInfo.C_afs_gn_setattr);
203     printf("\t%10d afs_gn_fclear\n", cmp->callInfo.C_afs_gn_fclear);
204     printf("\t%10d afs_gn_fsync\n", cmp->callInfo.C_afs_gn_fsync);
205     printf("\t%10d phash\n", cmp->callInfo.C_pHash);
206     printf("\t%10d DInit\n", cmp->callInfo.C_DInit);
207     printf("\t%10d DRead\n", cmp->callInfo.C_DRead);
208     printf("\t%10d FixupBucket\n", cmp->callInfo.C_FixupBucket);
209     printf("\t%10d afs_newslot\n", cmp->callInfo.C_afs_newslot);
210     printf("\t%10d DRelease\n", cmp->callInfo.C_DRelease);
211     printf("\t%10d DFlush\n", cmp->callInfo.C_DFlush);
212     printf("\t%10d DFlushEntry\n", cmp->callInfo.C_DFlushEntry);
213     printf("\t%10d DVOffset\n", cmp->callInfo.C_DVOffset);
214     printf("\t%10d DZap\n", cmp->callInfo.C_DZap);
215     printf("\t%10d DNew\n", cmp->callInfo.C_DNew);
216     printf("\t%10d afs_RemoveVCB\n", cmp->callInfo.C_afs_RemoveVCB);
217     printf("\t%10d afs_NewVCache\n", cmp->callInfo.C_afs_NewVCache);
218     printf("\t%10d afs_FlushActiveVcaches\n",
219            cmp->callInfo.C_afs_FlushActiveVcaches);
220     printf("\t%10d afs_VerifyVCache\n", cmp->callInfo.C_afs_VerifyVCache);
221     printf("\t%10d afs_WriteVCache\n", cmp->callInfo.C_afs_WriteVCache);
222     printf("\t%10d afs_GetVCache\n", cmp->callInfo.C_afs_GetVCache);
223     printf("\t%10d afs_StuffVcache\n", cmp->callInfo.C_afs_StuffVcache);
224     printf("\t%10d afs_FindVCache\n", cmp->callInfo.C_afs_FindVCache);
225     printf("\t%10d afs_PutDCache\n", cmp->callInfo.C_afs_PutDCache);
226     printf("\t%10d afs_PutVCache\n", cmp->callInfo.C_afs_PutVCache);
227     printf("\t%10d CacheStoreProc\n", cmp->callInfo.C_CacheStoreProc);
228     printf("\t%10d afs_FindDcache\n", cmp->callInfo.C_afs_FindDCache);
229     printf("\t%10d afs_TryToSmush\n", cmp->callInfo.C_afs_TryToSmush);
230     printf("\t%10d afs_AdjustSize\n", cmp->callInfo.C_afs_AdjustSize);
231     printf("\t%10d afs_CheckSize\n", cmp->callInfo.C_afs_CheckSize);
232     printf("\t%10d afs_StoreWarn\n", cmp->callInfo.C_afs_StoreWarn);
233     printf("\t%10d CacheFetchProc\n", cmp->callInfo.C_CacheFetchProc);
234     printf("\t%10d UFS_CacheStoreProc\n", cmp->callInfo.C_UFS_CacheStoreProc);
235     printf("\t%10d UFS_CacheFetchProc\n", cmp->callInfo.C_UFS_CacheFetchProc);
236     printf("\t%10d afs_GetDCache\n", cmp->callInfo.C_afs_GetDCache);
237     printf("\t%10d afs_SimpleVStat\n", cmp->callInfo.C_afs_SimpleVStat);
238     printf("\t%10d afs_ProcessFS\n", cmp->callInfo.C_afs_ProcessFS);
239     printf("\t%10d afs_InitCacheInfo\n", cmp->callInfo.C_afs_InitCacheInfo);
240     printf("\t%10d afs_InitVolumeInfo\n", cmp->callInfo.C_afs_InitVolumeInfo);
241     printf("\t%10d afs_InitCacheFile\n", cmp->callInfo.C_afs_InitCacheFile);
242     printf("\t%10d afs_CacheInit\n", cmp->callInfo.C_afs_CacheInit);
243     printf("\t%10d afs_GetDSlot\n", cmp->callInfo.C_afs_GetDSlot);
244     printf("\t%10d afs_WriteThroughDSlots\n",
245            cmp->callInfo.C_afs_WriteThroughDSlots);
246     printf("\t%10d afs_MemGetDSlot\n", cmp->callInfo.C_afs_MemGetDSlot);
247     printf("\t%10d afs_UFSGetDSlot\n", cmp->callInfo.C_afs_UFSGetDSlot);
248     printf("\t%10d afs_StoreDCache\n", cmp->callInfo.C_afs_StoreDCache);
249     printf("\t%10d afs_StoreMini\n", cmp->callInfo.C_afs_StoreMini);
250     printf("\t%10d afs_StoreAllSegments\n",
251            cmp->callInfo.C_afs_StoreAllSegments);
252     printf("\t%10d afs_InvalidateAllSegments\n",
253            cmp->callInfo.C_afs_InvalidateAllSegments);
254     printf("\t%10d afs_TruncateAllSegments\n",
255            cmp->callInfo.C_afs_TruncateAllSegments);
256     printf("\t%10d afs_CheckVolSync\n", cmp->callInfo.C_afs_CheckVolSync);
257     printf("\t%10d afs_wakeup\n", cmp->callInfo.C_afs_wakeup);
258     printf("\t%10d afs_CFileOpen\n", cmp->callInfo.C_afs_CFileOpen);
259     printf("\t%10d afs_CFileTruncate\n", cmp->callInfo.C_afs_CFileTruncate);
260     printf("\t%10d afs_GetDownD\n", cmp->callInfo.C_afs_GetDownD);
261     printf("\t%10d afs_WriteDCache\n", cmp->callInfo.C_afs_WriteDCache);
262     printf("\t%10d afs_FlushDCache\n", cmp->callInfo.C_afs_FlushDCache);
263     printf("\t%10d afs_GetDownDSlot\n", cmp->callInfo.C_afs_GetDownDSlot);
264     printf("\t%10d afs_FlushVCache\n", cmp->callInfo.C_afs_FlushVCache);
265     printf("\t%10d afs_GetDownV\n", cmp->callInfo.C_afs_GetDownV);
266     printf("\t%10d afs_QueueVCB\n", cmp->callInfo.C_afs_QueueVCB);
267     printf("\t%10d afs_call\n", cmp->callInfo.C_afs_call);
268     printf("\t%10d afs_syscall_call\n", cmp->callInfo.C_afs_syscall_call);
269     printf("\t%10d afs_syscall_icreate\n",
270            cmp->callInfo.C_afs_syscall_icreate);
271     printf("\t%10d afs_syscall_iopen\n", cmp->callInfo.C_afs_syscall_iopen);
272     printf("\t%10d afs_syscall_iincdec\n",
273            cmp->callInfo.C_afs_syscall_iincdec);
274     printf("\t%10d afs_syscall_ireadwrite\n",
275            cmp->callInfo.C_afs_syscall_ireadwrite);
276     printf("\t%10d afs_syscall\n", cmp->callInfo.C_afs_syscall);
277     printf("\t%10d lpioctl\n", cmp->callInfo.C_lpioctl);
278     printf("\t%10d lsetpag\n", cmp->callInfo.C_lsetpag);
279     printf("\t%10d afs_CheckInit\n", cmp->callInfo.C_afs_CheckInit);
280     printf("\t%10d ClearCallback\n", cmp->callInfo.C_ClearCallBack);
281     printf("\t%10d SRXAFSCB_GetCE\n", cmp->callInfo.C_SRXAFSCB_GetCE);
282     printf("\t%10d SRXAFSCB_GetLock\n", cmp->callInfo.C_SRXAFSCB_GetLock);
283     printf("\t%10d SRXAFSCB_CallBack\n", cmp->callInfo.C_SRXAFSCB_CallBack);
284     printf("\t%10d SRXAFSCB_InitCallBackState\n",
285            cmp->callInfo.C_SRXAFSCB_InitCallBackState);
286     printf("\t%10d SRXAFSCB_Probe\n", cmp->callInfo.C_SRXAFSCB_Probe);
287     printf("\t%10d afs_Chunk\n", cmp->callInfo.C_afs_Chunk);
288     printf("\t%10d afs_ChunkBase\n", cmp->callInfo.C_afs_ChunkBase);
289     printf("\t%10d afs_ChunkOffset\n", cmp->callInfo.C_afs_ChunkOffset);
290     printf("\t%10d afs_ChunkSize\n", cmp->callInfo.C_afs_ChunkSize);
291     printf("\t%10d afs_ChunkToBase\n", cmp->callInfo.C_afs_ChunkToBase);
292     printf("\t%10d afs_ChunkToSize\n", cmp->callInfo.C_afs_ChunkToSize);
293     printf("\t%10d afs_SetChunkSize\n", cmp->callInfo.C_afs_SetChunkSize);
294     printf("\t%10d afs_config\n", cmp->callInfo.C_afs_config);
295     printf("\t%10d mem_freebytes\n", cmp->callInfo.C_mem_freebytes);
296     printf("\t%10d mem_getbytes\n", cmp->callInfo.C_mem_getbytes);
297     printf("\t%10d afs_Daemon\n", cmp->callInfo.C_afs_Daemon);
298     printf("\t%10d afs_CheckRootVolume\n",
299            cmp->callInfo.C_afs_CheckRootVolume);
300     printf("\t%10d BPath\n", cmp->callInfo.C_BPath);
301     printf("\t%10d BPrefetch\n", cmp->callInfo.C_BPrefetch);
302     printf("\t%10d BStore\n", cmp->callInfo.C_BStore);
303     printf("\t%10d afs_BBusy\n", cmp->callInfo.C_afs_BBusy);
304     printf("\t%10d afs_BQueue\n", cmp->callInfo.C_afs_BQueue);
305     printf("\t%10d afs_BRelease\n", cmp->callInfo.C_afs_BRelease);
306     printf("\t%10d afs_BackgroundDaemon\n",
307            cmp->callInfo.C_afs_BackgroundDaemon);
308     printf("\t%10d exporter_add\n", cmp->callInfo.C_exporter_add);
309     printf("\t%10d exporter_find\n", cmp->callInfo.C_exporter_find);
310     printf("\t%10d afs_gfs_kalloc\n", cmp->callInfo.C_afs_gfs_kalloc);
311     printf("\t%10d afs_gfs_kfree\n", cmp->callInfo.C_afs_gfs_kfree);
312     printf("\t%10d gop_lookupname\n", cmp->callInfo.C_gop_lookupname);
313     printf("\t%10d afs_uniqtime\n", cmp->callInfo.C_afs_uniqtime);
314     printf("\t%10d gfs_vattr_null\n", cmp->callInfo.C_gfs_vattr_null);
315     printf("\t%10d afs_lock\n", cmp->callInfo.C_afs_lock);
316     printf("\t%10d afs_unlock\n", cmp->callInfo.C_afs_unlock);
317     printf("\t%10d afs_update\n", cmp->callInfo.C_afs_update);
318     printf("\t%10d afs_gclose\n", cmp->callInfo.C_afs_gclose);
319     printf("\t%10d afs_gopen\n", cmp->callInfo.C_afs_gopen);
320     printf("\t%10d afs_greadlink\n", cmp->callInfo.C_afs_greadlink);
321     printf("\t%10d afs_select\n", cmp->callInfo.C_afs_select);
322     printf("\t%10d afs_gbmap\n", cmp->callInfo.C_afs_gbmap);
323     printf("\t%10d afs_getfsdata\n", cmp->callInfo.C_afs_getfsdata);
324     printf("\t%10d afs_gsymlink\n", cmp->callInfo.C_afs_gsymlink);
325     printf("\t%10d afs_namei\n", cmp->callInfo.C_afs_namei);
326     printf("\t%10d afs_gmount\n", cmp->callInfo.C_afs_gmount);
327     printf("\t%10d afs_gget\n", cmp->callInfo.C_afs_gget);
328     printf("\t%10d afs_glink\n", cmp->callInfo.C_afs_glink);
329     printf("\t%10d afs_gmkdir\n", cmp->callInfo.C_afs_gmkdir);
330     printf("\t%10d afs_unlink\n", cmp->callInfo.C_afs_unlink);
331     printf("\t%10d afs_grmdir\n", cmp->callInfo.C_afs_grmdir);
332     printf("\t%10d afs_makenode\n", cmp->callInfo.C_afs_makenode);
333     printf("\t%10d afs_grename\n", cmp->callInfo.C_afs_grename);
334     printf("\t%10d afs_rele\n", cmp->callInfo.C_afs_rele);
335     printf("\t%10d afs_syncgp\n", cmp->callInfo.C_afs_syncgp);
336     printf("\t%10d afs_getval\n", cmp->callInfo.C_afs_getval);
337     printf("\t%10d afs_trunc\n", cmp->callInfo.C_afs_trunc);
338     printf("\t%10d afs_rwgp\n", cmp->callInfo.C_afs_rwgp);
339     printf("\t%10d afs_stat\n", cmp->callInfo.C_afs_stat);
340     printf("\t%10d afsc_link\n", cmp->callInfo.C_afsc_link);
341     printf("\t%10d afs_vfs_mount\n", cmp->callInfo.C_afs_vfs_mount);
342     printf("\t%10d afs_uniqtime\n", cmp->callInfo.C_afs_uniqtime);
343     printf("\t%10d iopen\n", cmp->callInfo.C_iopen);
344     printf("\t%10d idec\n", cmp->callInfo.C_idec);
345     printf("\t%10d iinc\n", cmp->callInfo.C_iinc);
346     printf("\t%10d ireadwrite\n", cmp->callInfo.C_ireadwrite);
347     printf("\t%10d iread\n", cmp->callInfo.C_iread);
348     printf("\t%10d iwrite\n", cmp->callInfo.C_iwrite);
349     printf("\t%10d iforget\n", cmp->callInfo.C_iforget);
350     printf("\t%10d icreate\n", cmp->callInfo.C_icreate);
351     printf("\t%10d igetinode\n", cmp->callInfo.C_igetinode);
352     printf("\t%10d osi_SleepR\n", cmp->callInfo.C_osi_SleepR);
353     printf("\t%10d osi_SleepS\n", cmp->callInfo.C_osi_SleepS);
354     printf("\t%10d osi_SleepW\n", cmp->callInfo.C_osi_SleepW);
355     printf("\t%10d osi_Sleep\n", cmp->callInfo.C_osi_Sleep);
356     printf("\t%10d afs_LookupMCE\n", cmp->callInfo.C_afs_LookupMCE);
357     printf("\t%10d afs_MemReadBlk\n", cmp->callInfo.C_afs_MemReadBlk);
358     printf("\t%10d afs_MemReadUIO\n", cmp->callInfo.C_afs_MemReadUIO);
359     printf("\t%10d afs_MemWriteBlk\n", cmp->callInfo.C_afs_MemWriteBlk);
360     printf("\t%10d afs_MemWriteUIO\n", cmp->callInfo.C_afs_MemWriteUIO);
361     printf("\t%10d afs_MemCacheStoreProc\n",
362            cmp->callInfo.C_afs_MemCacheStoreProc);
363     printf("\t%10d afs_MemCacheFetchProc\n",
364            cmp->callInfo.C_afs_MemCacheFetchProc);
365     printf("\t%10d afs_MemCacheTruncate\n",
366            cmp->callInfo.C_afs_MemCacheTruncate);
367     printf("\t%10d afs_MemCacheStoreProc\n",
368            cmp->callInfo.C_afs_MemCacheStoreProc);
369     printf("\t%10d afs_GetNfsClientPag\n",
370            cmp->callInfo.C_afs_GetNfsClientPag);
371     printf("\t%10d afs_FindNfsClientPag\n",
372            cmp->callInfo.C_afs_FindNfsClientPag);
373     printf("\t%10d afs_PutNfsClientPag\n",
374            cmp->callInfo.C_afs_PutNfsClientPag);
375     printf("\t%10d afs_nfsclient_reqhandler\n",
376            cmp->callInfo.C_afs_nfsclient_reqhandler);
377     printf("\t%10d afs_nfsclient_GC\n", cmp->callInfo.C_afs_nfsclient_GC);
378     printf("\t%10d afs_nfsclient_hold\n", cmp->callInfo.C_afs_nfsclient_hold);
379     printf("\t%10d afs_nfsclient_stats\n",
380            cmp->callInfo.C_afs_nfsclient_stats);
381     printf("\t%10d afs_nfsclient_sysname\n",
382            cmp->callInfo.C_afs_nfsclient_sysname);
383     printf("\t%10d afs_rfs_dispatch\n", cmp->callInfo.C_afs_rfs_dispatch);
384     printf("\t%10d afs_nfs2afscall\n", cmp->callInfo.C_Nfs2AfsCall);
385     printf("\t%10d afs_sun_xuntext\n", cmp->callInfo.C_afs_sun_xuntext);
386     printf("\t%10d osi_Active\n", cmp->callInfo.C_osi_Active);
387     printf("\t%10d osi_FlushPages\n", cmp->callInfo.C_osi_FlushPages);
388     printf("\t%10d osi_FlushText\n", cmp->callInfo.C_osi_FlushText);
389     printf("\t%10d osi_CallProc\n", cmp->callInfo.C_osi_CallProc);
390     printf("\t%10d osi_CancelProc\n", cmp->callInfo.C_osi_CancelProc);
391     printf("\t%10d osi_Invisible\n", cmp->callInfo.C_osi_Invisible);
392     printf("\t%10d osi_Time\n", cmp->callInfo.C_osi_Time);
393     printf("\t%10d osi_Alloc\n", cmp->callInfo.C_osi_Alloc);
394     printf("\t%10d osi_SetTime\n", cmp->callInfo.C_osi_SetTime);
395     printf("\t%10d osi_Dump\n", cmp->callInfo.C_osi_Dump);
396     printf("\t%10d osi_Free\n", cmp->callInfo.C_osi_Free);
397     printf("\t%10d osi_UFSOpen\n", cmp->callInfo.C_osi_UFSOpen);
398     printf("\t%10d osi_Close\n", cmp->callInfo.C_osi_Close);
399     printf("\t%10d osi_Stat\n", cmp->callInfo.C_osi_Stat);
400     printf("\t%10d osi_Truncate\n", cmp->callInfo.C_osi_Truncate);
401     printf("\t%10d osi_Read\n", cmp->callInfo.C_osi_Read);
402     printf("\t%10d osi_Write\n", cmp->callInfo.C_osi_Write);
403     printf("\t%10d osi_MapStrategy\n", cmp->callInfo.C_osi_MapStrategy);
404     printf("\t%10d osi_AllocLargeSpace\n",
405            cmp->callInfo.C_osi_AllocLargeSpace);
406     printf("\t%10d osi_FreeLargeSpace\n", cmp->callInfo.C_osi_FreeLargeSpace);
407     printf("\t%10d osi_AllocSmallSpace\n",
408            cmp->callInfo.C_osi_AllocSmallSpace);
409     printf("\t%10d osi_FreeSmallSpace\n", cmp->callInfo.C_osi_FreeSmallSpace);
410     printf("\t%10d osi_CloseToTheEdge\n", cmp->callInfo.C_osi_CloseToTheEdge);
411     printf("\t%10d osi_xgreedy\n", cmp->callInfo.C_osi_xgreedy);
412     printf("\t%10d osi_FreeSocket\n", cmp->callInfo.C_osi_FreeSocket);
413     printf("\t%10d osi_NewSocket\n", cmp->callInfo.C_osi_NewSocket);
414     printf("\t%10d osi_NetSend\n", cmp->callInfo.C_osi_NetSend);
415     printf("\t%10d WaitHack\n", cmp->callInfo.C_WaitHack);
416     printf("\t%10d osi_CancelWait\n", cmp->callInfo.C_osi_CancelWait);
417     printf("\t%10d osi_Wakeup\n", cmp->callInfo.C_osi_Wakeup);
418     printf("\t%10d osi_Wait\n", cmp->callInfo.C_osi_Wait);
419     printf("\t%10d dirp_Read\n", cmp->callInfo.C_dirp_Read);
420     printf("\t%10d dirp_Cpy\n", cmp->callInfo.C_dirp_Cpy);
421     printf("\t%10d dirp_Eq\n", cmp->callInfo.C_dirp_Eq);
422     printf("\t%10d dirp_Write\n", cmp->callInfo.C_dirp_Write);
423     printf("\t%10d dirp_Zap\n", cmp->callInfo.C_dirp_Zap);
424     printf("\t%10d afs_ioctl\n", cmp->callInfo.C_afs_ioctl);
425     printf("\t%10d handleIoctl\n", cmp->callInfo.C_HandleIoctl);
426     printf("\t%10d afs_xioctl\n", cmp->callInfo.C_afs_xioctl);
427     printf("\t%10d afs_pioctl\n", cmp->callInfo.C_afs_pioctl);
428     printf("\t%10d HandlePioctl\n", cmp->callInfo.C_HandlePioctl);
429     printf("\t%10d PGetVolumeStatus\n", cmp->callInfo.C_PGetVolumeStatus);
430     printf("\t%10d PSetVolumeStatus\n", cmp->callInfo.C_PSetVolumeStatus);
431     printf("\t%10d PFlush\n", cmp->callInfo.C_PFlush);
432     printf("\t%10d PFlushVolumeData\n", cmp->callInfo.C_PFlushVolumeData);
433     printf("\t%10d PNewStatMount\n", cmp->callInfo.C_PNewStatMount);
434     printf("\t%10d PGetTokens\n", cmp->callInfo.C_PGetTokens);
435     printf("\t%10d PSetTokens\n", cmp->callInfo.C_PSetTokens);
436     printf("\t%10d PUnlog\n", cmp->callInfo.C_PUnlog);
437     printf("\t%10d PCheckServers\n", cmp->callInfo.C_PCheckServers);
438     printf("\t%10d PCheckAuth\n", cmp->callInfo.C_PCheckAuth);
439     printf("\t%10d PCheckVolNames\n", cmp->callInfo.C_PCheckVolNames);
440     printf("\t%10d PFindVolume\n", cmp->callInfo.C_PFindVolume);
441     printf("\t%10d Prefetch\n", cmp->callInfo.C_Prefetch);
442     printf("\t%10d PGetCacheSize\n", cmp->callInfo.C_PGetCacheSize);
443     printf("\t%10d PSetCacheSize\n", cmp->callInfo.C_PSetCacheSize);
444     printf("\t%10d PSetSysName\n", cmp->callInfo.C_PSetSysName);
445     printf("\t%10d PExportAfs\n", cmp->callInfo.C_PExportAfs);
446     printf("\t%10d HandleClientContext\n",
447            cmp->callInfo.C_HandleClientContext);
448     printf("\t%10d PViceAccess\n", cmp->callInfo.C_PViceAccess);
449     printf("\t%10d PRemoveCallBack\n", cmp->callInfo.C_PRemoveCallBack);
450     printf("\t%10d PRemoveMount\n", cmp->callInfo.C_PRemoveMount);
451     printf("\t%10d PSetVolumeStatus\n", cmp->callInfo.C_PSetVolumeStatus);
452     printf("\t%10d PListCells\n", cmp->callInfo.C_PListCells);
453     printf("\t%10d PNewCell\n", cmp->callInfo.C_PNewCell);
454     printf("\t%10d PGetUserCell\n", cmp->callInfo.C_PGetUserCell);
455     printf("\t%10d PGetCellStatus\n", cmp->callInfo.C_PGetCellStatus);
456     printf("\t%10d PSetCellStatus\n", cmp->callInfo.C_PSetCellStatus);
457     printf("\t%10d PVenusLogging\n", cmp->callInfo.C_PVenusLogging);
458     printf("\t%10d PGetAcl\n", cmp->callInfo.C_PGetAcl);
459     printf("\t%10d PGetFID\n", cmp->callInfo.C_PGetFID);
460     printf("\t%10d PSetAcl\n", cmp->callInfo.C_PSetAcl);
461     printf("\t%10d PGetFileCell\n", cmp->callInfo.C_PGetFileCell);
462     printf("\t%10d PGetWSCell\n", cmp->callInfo.C_PGetWSCell);
463     printf("\t%10d PGetSPrefs\n", cmp->callInfo.C_PGetSPrefs);
464     printf("\t%10d PSetSPrefs\n", cmp->callInfo.C_PSetSPrefs);
465     printf("\t%10d afs_ResetAccessCache\n",
466            cmp->callInfo.C_afs_ResetAccessCache);
467     printf("\t%10d afs_FindUser\n", cmp->callInfo.C_afs_FindUser);
468     printf("\t%10d afs_GetUser\n", cmp->callInfo.C_afs_GetUser);
469     printf("\t%10d afs_GCUserData\n", cmp->callInfo.C_afs_GCUserData);
470     printf("\t%10d afs_PutUser\n", cmp->callInfo.C_afs_PutUser);
471     printf("\t%10d afs_SetPrimary\n", cmp->callInfo.C_afs_SetPrimary);
472     printf("\t%10d afs_ResetUserConns\n", cmp->callInfo.C_afs_ResetUserConns);
473     printf("\t%10d afs_RemoveUserConns\n", cmp->callInfo.C_RemoveUserConns);
474     printf("\t%10d afs_ResourceInit\n", cmp->callInfo.C_afs_ResourceInit);
475     printf("\t%10d afs_GetCell\n", cmp->callInfo.C_afs_GetCell);
476     printf("\t%10d afs_GetCellByIndex\n", cmp->callInfo.C_afs_GetCellByIndex);
477     printf("\t%10d afs_GetCellByName\n", cmp->callInfo.C_afs_GetCellByName);
478     printf("\t%10d afs_GetRealCellByIndex\n",
479            cmp->callInfo.C_afs_GetRealCellByIndex);
480     printf("\t%10d afs_NewCell\n", cmp->callInfo.C_afs_NewCell);
481     printf("\t%10d CheckVLDB\n", cmp->callInfo.C_CheckVLDB);
482     printf("\t%10d afs_GetVolume\n", cmp->callInfo.C_afs_GetVolume);
483     printf("\t%10d afs_PutVolume\n", cmp->callInfo.C_afs_PutVolume);
484     printf("\t%10d afs_GetVolumeByName\n",
485            cmp->callInfo.C_afs_GetVolumeByName);
486     printf("\t%10d afs_random\n", cmp->callInfo.C_afs_random);
487     printf("\t%10d InstallVolumeEntry\n", cmp->callInfo.C_InstallVolumeEntry);
488     printf("\t%10d InstallVolumeInfo\n", cmp->callInfo.C_InstallVolumeInfo);
489     printf("\t%10d afs_ResetVolumeInfo\n",
490            cmp->callInfo.C_afs_ResetVolumeInfo);
491     printf("\t%10d afs_FindServer\n", cmp->callInfo.C_afs_FindServer);
492     printf("\t%10d afs_GetServer\n", cmp->callInfo.C_afs_GetServer);
493     printf("\t%10d afs_SortServers\n", cmp->callInfo.C_afs_SortServers);
494     printf("\t%10d afs_CheckServers\n", cmp->callInfo.C_afs_CheckServers);
495     printf("\t%10d ServerDown\n", cmp->callInfo.C_ServerDown);
496     printf("\t%10d afs_Conn\n", cmp->callInfo.C_afs_Conn);
497     printf("\t%10d afs_PutConn\n", cmp->callInfo.C_afs_PutConn);
498     printf("\t%10d afs_ConnByHost\n", cmp->callInfo.C_afs_ConnByHost);
499     printf("\t%10d afs_ConnByMHosts\n", cmp->callInfo.C_afs_ConnByMHosts);
500     printf("\t%10d afs_Analyze\n", cmp->callInfo.C_afs_Analyze);
501     printf("\t%10d afs_CheckLocks\n", cmp->callInfo.C_afs_CheckLocks);
502     printf("\t%10d CheckVLServer\n", cmp->callInfo.C_CheckVLServer);
503     printf("\t%10d afs_CheckCacheResets\n",
504            cmp->callInfo.C_afs_CheckCacheResets);
505     printf("\t%10d afs_CheckVolumeNames\n",
506            cmp->callInfo.C_afs_CheckVolumeNames);
507     printf("\t%10d afs_CheckCode\n", cmp->callInfo.C_afs_CheckCode);
508     printf("\t%10d afs_CopyError\n", cmp->callInfo.C_afs_CopyError);
509     printf("\t%10d afs_FinalizeReq\n", cmp->callInfo.C_afs_FinalizeReq);
510     printf("\t%10d afs_GetVolCache\n", cmp->callInfo.C_afs_GetVolCache);
511     printf("\t%10d afs_GetVolSlot\n", cmp->callInfo.C_afs_GetVolSlot);
512     printf("\t%10d afs_UFSGetVolSlot\n", cmp->callInfo.C_afs_UFSGetVolSlot);
513     printf("\t%10d afs_MemGetVolSlot\n", cmp->callInfo.C_afs_MemGetVolSlot);
514     printf("\t%10d afs_WriteVolCache\n", cmp->callInfo.C_afs_WriteVolCache);
515     printf("\t%10d haveCallbacksfrom\n", cmp->callInfo.C_HaveCallBacksFrom);
516     printf("\t%10d afs_getpage\n", cmp->callInfo.C_afs_getpage);
517     printf("\t%10d afs_putpage\n", cmp->callInfo.C_afs_putpage);
518     printf("\t%10d afs_nfsrdwr\n", cmp->callInfo.C_afs_nfsrdwr);
519     printf("\t%10d afs_map\n", cmp->callInfo.C_afs_map);
520     printf("\t%10d afs_cmp\n", cmp->callInfo.C_afs_cmp);
521     printf("\t%10d afs_PageLeft\n", cmp->callInfo.C_afs_PageLeft);
522     printf("\t%10d afs_mount\n", cmp->callInfo.C_afs_mount);
523     printf("\t%10d afs_unmount\n", cmp->callInfo.C_afs_unmount);
524     printf("\t%10d afs_root\n", cmp->callInfo.C_afs_root);
525     printf("\t%10d afs_statfs\n", cmp->callInfo.C_afs_statfs);
526     printf("\t%10d afs_sync\n", cmp->callInfo.C_afs_sync);
527     printf("\t%10d afs_vget\n", cmp->callInfo.C_afs_vget);
528     printf("\t%10d afs_index\n", cmp->callInfo.C_afs_index);
529     printf("\t%10d afs_setpag\n", cmp->callInfo.C_afs_setpag);
530     printf("\t%10d genpag\n", cmp->callInfo.C_genpag);
531     printf("\t%10d getpag\n", cmp->callInfo.C_getpag);
532     printf("\t%10d genpag\n", cmp->callInfo.C_genpag);
533     printf("\t%10d afs_GetMariner\n", cmp->callInfo.C_afs_GetMariner);
534     printf("\t%10d afs_AddMarinerName\n", cmp->callInfo.C_afs_AddMarinerName);
535     printf("\t%10d afs_open\n", cmp->callInfo.C_afs_open);
536     printf("\t%10d afs_close\n", cmp->callInfo.C_afs_close);
537     printf("\t%10d afs_closex\n", cmp->callInfo.C_afs_closex);
538     printf("\t%10d afs_write\n", cmp->callInfo.C_afs_write);
539     printf("\t%10d afs_UFSwrite\n", cmp->callInfo.C_afs_UFSWrite);
540     printf("\t%10d afs_Memwrite\n", cmp->callInfo.C_afs_MemWrite);
541     printf("\t%10d afs_rdwr\n", cmp->callInfo.C_afs_rdwr);
542     printf("\t%10d afs_read\n", cmp->callInfo.C_afs_read);
543     printf("\t%10d afs_UFSread\n", cmp->callInfo.C_afs_UFSRead);
544     printf("\t%10d afs_Memread\n", cmp->callInfo.C_afs_MemRead);
545     printf("\t%10d afs_CopyOutAttrs\n", cmp->callInfo.C_afs_CopyOutAttrs);
546     printf("\t%10d afs_access\n", cmp->callInfo.C_afs_access);
547     printf("\t%10d afs_getattr\n", cmp->callInfo.C_afs_getattr);
548     printf("\t%10d afs_setattr\n", cmp->callInfo.C_afs_setattr);
549     printf("\t%10d afs_VAttrToAS\n", cmp->callInfo.C_afs_VAttrToAS);
550     printf("\t%10d EvalMountPoint\n", cmp->callInfo.C_EvalMountPoint);
551     printf("\t%10d afs_lookup\n", cmp->callInfo.C_afs_lookup);
552     printf("\t%10d afs_create\n", cmp->callInfo.C_afs_create);
553     printf("\t%10d afs_LocalHero\n", cmp->callInfo.C_afs_LocalHero);
554     printf("\t%10d afs_remove\n", cmp->callInfo.C_afs_remove);
555     printf("\t%10d afs_link\n", cmp->callInfo.C_afs_link);
556     printf("\t%10d afs_rename\n", cmp->callInfo.C_afs_rename);
557     printf("\t%10d afs_InitReq\n", cmp->callInfo.C_afs_InitReq);
558     printf("\t%10d afs_mkdir\n", cmp->callInfo.C_afs_mkdir);
559     printf("\t%10d afs_rmdir\n", cmp->callInfo.C_afs_rmdir);
560     printf("\t%10d afs_readdir\n", cmp->callInfo.C_afs_readdir);
561     printf("\t%10d afs_read1dir\n", cmp->callInfo.C_afs_read1dir);
562     printf("\t%10d afs_readdir_move\n", cmp->callInfo.C_afs_readdir_move);
563     printf("\t%10d afs_readdir_iter\n", cmp->callInfo.C_afs_readdir_iter);
564     printf("\t%10d afs_symlink\n", cmp->callInfo.C_afs_symlink);
565     printf("\t%10d afs_HandleLink\n", cmp->callInfo.C_afs_HandleLink);
566     printf("\t%10d afs_MemHandleLink\n", cmp->callInfo.C_afs_MemHandleLink);
567     printf("\t%10d afs_UFSHandleLink\n", cmp->callInfo.C_afs_UFSHandleLink);
568     printf("\t%10d HandleFlock\n", cmp->callInfo.C_HandleFlock);
569     printf("\t%10d afs_readlink\n", cmp->callInfo.C_afs_readlink);
570     printf("\t%10d afs_fsync\n", cmp->callInfo.C_afs_fsync);
571     printf("\t%10d afs_inactive\n", cmp->callInfo.C_afs_inactive);
572     printf("\t%10d afs_ustrategy\n", cmp->callInfo.C_afs_ustrategy);
573     printf("\t%10d afs_strategy\n", cmp->callInfo.C_afs_strategy);
574     printf("\t%10d afs_bread\n", cmp->callInfo.C_afs_bread);
575     printf("\t%10d afs_brelse\n", cmp->callInfo.C_afs_brelse);
576     printf("\t%10d afs_bmap\n", cmp->callInfo.C_afs_bmap);
577     printf("\t%10d afs_fid\n", cmp->callInfo.C_afs_fid);
578     printf("\t%10d afs_FakeOpen\n", cmp->callInfo.C_afs_FakeOpen);
579     printf("\t%10d afs_FakeClose\n", cmp->callInfo.C_afs_FakeClose);
580     printf("\t%10d afs_StoreOnLastReference\n",
581            cmp->callInfo.C_afs_StoreOnLastReference);
582     printf("\t%10d afs_AccessOK\n", cmp->callInfo.C_afs_AccessOK);
583     printf("\t%10d afs_GetAccessBits\n", cmp->callInfo.C_afs_GetAccessBits);
584     printf("\t%10d afsio_copy\n", cmp->callInfo.C_afsio_copy);
585     printf("\t%10d afsio_trim\n", cmp->callInfo.C_afsio_trim);
586     printf("\t%10d afsio_skip\n", cmp->callInfo.C_afsio_skip);
587     printf("\t%10d afs_page_read\n", cmp->callInfo.C_afs_page_read);
588     printf("\t%10d afs_page_write\n", cmp->callInfo.C_afs_page_write);
589     printf("\t%10d afs_page_read\n", cmp->callInfo.C_afs_page_read);
590     printf("\t%10d afs_get_groups_from_pag\n",
591            cmp->callInfo.C_afs_get_groups_from_pag);
592     printf("\t%10d afs_get_pag_from_groups\n",
593            cmp->callInfo.C_afs_get_pag_from_groups);
594     printf("\t%10d AddPag\n", cmp->callInfo.C_AddPag);
595     printf("\t%10d PagInCred\n", cmp->callInfo.C_PagInCred);
596     printf("\t%10d afs_getgroups\n", cmp->callInfo.C_afs_getgroups);
597     printf("\t%10d afs_page_in\n", cmp->callInfo.C_afs_page_in);
598     printf("\t%10d afs_page_out\n", cmp->callInfo.C_afs_page_out);
599     printf("\t%10d afs_AdvanceFD\n", cmp->callInfo.C_afs_AdvanceFD);
600     printf("\t%10d afs_lockf\n", cmp->callInfo.C_afs_lockf);
601     printf("\t%10d afs_xsetgroups\n", cmp->callInfo.C_afs_xsetgroups);
602     printf("\t%10d afs_nlinks\n", cmp->callInfo.C_afs_nlinks);
603     printf("\t%10d afs_lockctl\n", cmp->callInfo.C_afs_lockctl);
604     printf("\t%10d afs_xflock\n", cmp->callInfo.C_afs_xflock);
605     printf("\t%10d PGetCPrefs\n", cmp->callInfo.C_PGetCPrefs);
606     printf("\t%10d PSetCPrefs\n", cmp->callInfo.C_PSetCPrefs);
607 #ifdef  AFS_HPUX_ENV
608     printf("\t%10d afs_pagein\n", cmp->callInfo.C_afs_pagein);
609     printf("\t%10d afs_pageout\n", cmp->callInfo.C_afs_pageout);
610     printf("\t%10d afs_hp_strategy\n", cmp->callInfo.C_afs_hp_strategy);
611 #endif
612     printf("\t%10d PFlushMount\n", cmp->callInfo.C_PFlushMount);
613 }
614
615
616 /*------------------------------------------------------------------------
617  * PrintUpDownStats
618  *
619  * Description:
620  *      Print the up/downtime stats for the given class of server records
621  *      provided.
622  *
623  * Arguments:
624  *      a_upDownP : Ptr to the server up/down info.
625  *
626  * Returns:
627  *      Nothing.
628  *
629  * Environment:
630  *      Nothing interesting.
631  *
632  * Side Effects:
633  *      As advertised.
634  *------------------------------------------------------------------------*/
635
636 void
637 PrintUpDownStats(a_upDownP)
638      struct afs_stats_SrvUpDownInfo *a_upDownP; /*Ptr to server up/down info */
639
640 {                               /*PrintUpDownStats */
641
642     /*
643      * First, print the simple values.
644      */
645     printf("\t\t%10d numTtlRecords\n", a_upDownP->numTtlRecords);
646     printf("\t\t%10d numUpRecords\n", a_upDownP->numUpRecords);
647     printf("\t\t%10d numDownRecords\n", a_upDownP->numDownRecords);
648     printf("\t\t%10d sumOfRecordAges\n", a_upDownP->sumOfRecordAges);
649     printf("\t\t%10d ageOfYoungestRecord\n", a_upDownP->ageOfYoungestRecord);
650     printf("\t\t%10d ageOfOldestRecord\n", a_upDownP->ageOfOldestRecord);
651     printf("\t\t%10d numDowntimeIncidents\n",
652            a_upDownP->numDowntimeIncidents);
653     printf("\t\t%10d numRecordsNeverDown\n", a_upDownP->numRecordsNeverDown);
654     printf("\t\t%10d maxDowntimesInARecord\n",
655            a_upDownP->maxDowntimesInARecord);
656     printf("\t\t%10d sumOfDowntimes\n", a_upDownP->sumOfDowntimes);
657     printf("\t\t%10d shortestDowntime\n", a_upDownP->shortestDowntime);
658     printf("\t\t%10d longestDowntime\n", a_upDownP->longestDowntime);
659
660     /*
661      * Now, print the array values.
662      */
663     printf("\t\tDowntime duration distribution:\n");
664     printf("\t\t\t%8d: 0 min .. 10 min\n", a_upDownP->downDurations[0]);
665     printf("\t\t\t%8d: 10 min .. 30 min\n", a_upDownP->downDurations[1]);
666     printf("\t\t\t%8d: 30 min .. 1 hr\n", a_upDownP->downDurations[2]);
667     printf("\t\t\t%8d: 1 hr .. 2 hr\n", a_upDownP->downDurations[3]);
668     printf("\t\t\t%8d: 2 hr .. 4 hr\n", a_upDownP->downDurations[4]);
669     printf("\t\t\t%8d: 4 hr .. 8 hr\n", a_upDownP->downDurations[5]);
670     printf("\t\t\t%8d: > 8 hr\n", a_upDownP->downDurations[6]);
671
672     printf("\t\tDowntime incident distribution:\n");
673     printf("\t\t\t%8d: 0 times\n", a_upDownP->downIncidents[0]);
674     printf("\t\t\t%8d: 1 time\n", a_upDownP->downIncidents[1]);
675     printf("\t\t\t%8d: 2 .. 5 times\n", a_upDownP->downIncidents[2]);
676     printf("\t\t\t%8d: 6 .. 10 times\n", a_upDownP->downIncidents[3]);
677     printf("\t\t\t%8d: 10 .. 50 times\n", a_upDownP->downIncidents[4]);
678     printf("\t\t\t%8d: > 50 times\n", a_upDownP->downIncidents[5]);
679
680 }                               /*PrintUpDownStats */
681
682
683 /*------------------------------------------------------------------------
684  * PrintOverallPerfInfo
685  *
686  * Description:
687  *      Print out overall performance numbers.
688  *
689  * Arguments:
690  *      a_ovP : Ptr to the overall performance numbers.
691  *
692  * Returns:
693  *      Nothing.
694  *
695  * Environment:
696  *      All the info we need is nestled into xstat_cm_Results.
697  *
698  * Side Effects:
699  *      As advertised.
700  *------------------------------------------------------------------------*/
701
702 void
703 PrintOverallPerfInfo(a_ovP)
704      struct afs_stats_CMPerf *a_ovP;
705
706 {                               /*PrintOverallPerfInfo */
707
708     printf("\t%10d numPerfCalls\n", a_ovP->numPerfCalls);
709
710     printf("\t%10d epoch\n", a_ovP->epoch);
711     printf("\t%10d numCellsVisible\n", a_ovP->numCellsVisible);
712     printf("\t%10d numCellsContacted\n", a_ovP->numCellsContacted);
713     printf("\t%10d dlocalAccesses\n", a_ovP->dlocalAccesses);
714     printf("\t%10d vlocalAccesses\n", a_ovP->vlocalAccesses);
715     printf("\t%10d dremoteAccesses\n", a_ovP->dremoteAccesses);
716     printf("\t%10d vremoteAccesses\n", a_ovP->vremoteAccesses);
717     printf("\t%10d cacheNumEntries\n", a_ovP->cacheNumEntries);
718     printf("\t%10d cacheBlocksTotal\n", a_ovP->cacheBlocksTotal);
719     printf("\t%10d cacheBlocksInUse\n", a_ovP->cacheBlocksInUse);
720     printf("\t%10d cacheBlocksOrig\n", a_ovP->cacheBlocksOrig);
721     printf("\t%10d cacheMaxDirtyChunks\n", a_ovP->cacheMaxDirtyChunks);
722     printf("\t%10d cacheCurrDirtyChunks\n", a_ovP->cacheCurrDirtyChunks);
723     printf("\t%10d dcacheHits\n", a_ovP->dcacheHits);
724     printf("\t%10d vcacheHits\n", a_ovP->vcacheHits);
725     printf("\t%10d dcacheMisses\n", a_ovP->dcacheMisses);
726     printf("\t%10d vcacheMisses\n", a_ovP->vcacheMisses);
727     printf("\t%10d cacheFilesReused\n", a_ovP->cacheFilesReused);
728     printf("\t%10d vcacheXAllocs\n", a_ovP->vcacheXAllocs);
729     printf("\t%10d dcacheXAllocs\n", a_ovP->dcacheXAllocs);
730
731     printf("\t%10d bufAlloced\n", a_ovP->bufAlloced);
732     printf("\t%10d bufHits\n", a_ovP->bufHits);
733     printf("\t%10d bufMisses\n", a_ovP->bufMisses);
734     printf("\t%10d bufFlushDirty\n", a_ovP->bufFlushDirty);
735
736     printf("\t%10d LargeBlocksActive\n", a_ovP->LargeBlocksActive);
737     printf("\t%10d LargeBlocksAlloced\n", a_ovP->LargeBlocksAlloced);
738     printf("\t%10d SmallBlocksActive\n", a_ovP->SmallBlocksActive);
739     printf("\t%10d SmallBlocksAlloced\n", a_ovP->SmallBlocksAlloced);
740     printf("\t%10d OutStandingMemUsage\n", a_ovP->OutStandingMemUsage);
741     printf("\t%10d OutStandingAllocs\n", a_ovP->OutStandingAllocs);
742     printf("\t%10d CallBackAlloced\n", a_ovP->CallBackAlloced);
743     printf("\t%10d CallBackFlushes\n", a_ovP->CallBackFlushes);
744     printf("\t%10d CallBackLoops\n", a_ovP->cbloops);
745
746     printf("\t%10d srvRecords\n", a_ovP->srvRecords);
747     printf("\t%10d srvNumBuckets\n", a_ovP->srvNumBuckets);
748     printf("\t%10d srvMaxChainLength\n", a_ovP->srvMaxChainLength);
749     printf("\t%10d srvMaxChainLengthHWM\n", a_ovP->srvMaxChainLengthHWM);
750     printf("\t%10d srvRecordsHWM\n", a_ovP->srvRecordsHWM);
751
752     printf("\t%10d cacheBucket0_Discarded\n",  a_ovP->cacheBucket0_Discarded);
753     printf("\t%10d cacheBucket1_Discarded\n",  a_ovP->cacheBucket1_Discarded);
754     printf("\t%10d cacheBucket2_Discarded\n",  a_ovP->cacheBucket2_Discarded);
755
756     printf("\t%10d sysName_ID\n", a_ovP->sysName_ID);
757
758     printf("\tFile Server up/downtimes, same cell:\n");
759     PrintUpDownStats(&(a_ovP->fs_UpDown[0]));
760
761     printf("\tFile Server up/downtimes, diff cell:\n");
762     PrintUpDownStats(&(a_ovP->fs_UpDown[1]));
763
764     printf("\tVL Server up/downtimes, same cell:\n");
765     PrintUpDownStats(&(a_ovP->vl_UpDown[0]));
766
767     printf("\tVL Server up/downtimes, diff cell:\n");
768     PrintUpDownStats(&(a_ovP->vl_UpDown[1]));
769
770 }                               /*PrintOverallPerfInfo */
771
772
773 /*------------------------------------------------------------------------
774  * PrintPerfInfo
775  *
776  * Description:
777  *      Print out the AFSCB_XSTATSCOLL_PERF_INFO collection we just
778  *      received.
779  *
780  * Arguments:
781  *      None.
782  *
783  * Returns:
784  *      Nothing.
785  *
786  * Environment:
787  *      All the info we need is nestled into xstat_cm_Results.
788  *
789  * Side Effects:
790  *      As advertised.
791  *------------------------------------------------------------------------*/
792
793 void
794 PrintPerfInfo()
795 {                               /*PrintPerfInfo */
796
797     static char rn[] = "PrintPerfInfo"; /*Routine name */
798     static afs_int32 perfInt32s = (sizeof(struct afs_stats_CMPerf) >> 2);       /*Correct # int32s to rcv */
799     afs_int32 numInt32s;        /*# int32words received */
800     struct afs_stats_CMPerf *perfP;     /*Ptr to performance stats */
801     char *printableTime;        /*Ptr to printable time string */
802     time_t probeTime = xstat_cm_Results.probeTime;
803
804     numInt32s = xstat_cm_Results.data.AFSCB_CollData_len;
805     if (numInt32s != perfInt32s) {
806         printf("** Data size mismatch in performance collection!");
807         printf("** Expecting %d, got %d\n", perfInt32s, numInt32s);
808         printf("** Version mismatch with Cache Manager\n");
809         return;
810     }
811
812     printableTime = ctime(&probeTime);
813     printableTime[strlen(printableTime) - 1] = '\0';
814     perfP = (struct afs_stats_CMPerf *)
815         (xstat_cm_Results.data.AFSCB_CollData_val);
816
817     printf
818         ("AFSCB_XSTATSCOLL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
819          xstat_cm_Results.collectionNumber, xstat_cm_Results.connP->hostName,
820          xstat_cm_Results.probeNum, printableTime);
821
822     PrintOverallPerfInfo(perfP);
823
824 }                               /*PrintPerfInfo */
825
826
827 /*------------------------------------------------------------------------
828  * PrintOpTiming
829  *
830  * Description:
831  *      Print out the contents of an FS RPC op timing structure.
832  *
833  * Arguments:
834  *      a_opIdx   : Index of the AFS operation we're printing number on.
835  *      a_opNames : Ptr to table of operaton names.
836  *      a_opTimeP : Ptr to the op timing structure to print.
837  *
838  * Returns:
839  *      Nothing.
840  *
841  * Environment:
842  *      Nothing interesting.
843  *
844  * Side Effects:
845  *      As advertised.
846  *------------------------------------------------------------------------*/
847
848 void
849 PrintOpTiming(a_opIdx, a_opNames, a_opTimeP)
850      int a_opIdx;
851      char *a_opNames[];
852      struct afs_stats_opTimingData *a_opTimeP;
853
854 {                               /*PrintOpTiming */
855
856     printf
857         ("%15s: %d ops (%d OK); sum=%d.%06d, sqr=%d.%06d, min=%d.%06d, max=%d.%06d\n",
858          a_opNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses,
859          a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
860          a_opTimeP->sqrTime.tv_sec, a_opTimeP->sqrTime.tv_usec,
861          a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
862          a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
863
864 }                               /*PrintOpTiming */
865
866
867 /*------------------------------------------------------------------------
868  * PrintXferTiming
869  *
870  * Description:
871  *      Print out the contents of a data transfer structure.
872  *
873  * Arguments:
874  *      a_opIdx : Index of the AFS operation we're printing number on.
875  *      a_opNames : Ptr to table of operation names.
876  *      a_xferP : Ptr to the data transfer structure to print.
877  *
878  * Returns:
879  *      Nothing.
880  *
881  * Environment:
882  *      Nothing interesting.
883  *
884  * Side Effects:
885  *      As advertised.
886  *------------------------------------------------------------------------*/
887
888 void
889 PrintXferTiming(a_opIdx, a_opNames, a_xferP)
890      int a_opIdx;
891      char *a_opNames[];
892      struct afs_stats_xferData *a_xferP;
893
894 {                               /*PrintXferTiming */
895
896     printf
897         ("%s: %d xfers (%d OK), time sum=%d.%06d, sqr=%d.%06d, min=%d.%06d, max=%d.%06d\n",
898          a_opNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses,
899          a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
900          a_xferP->sqrTime.tv_sec, a_xferP->sqrTime.tv_usec,
901          a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
902          a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
903     printf("\t[bytes: sum=%d, min=%d, max=%d]\n", a_xferP->sumBytes,
904            a_xferP->minBytes, a_xferP->maxBytes);
905     printf
906         ("\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d, 6: %d, 7: %d, 8: %d]\n",
907          a_xferP->count[0], a_xferP->count[1], a_xferP->count[2],
908          a_xferP->count[3], a_xferP->count[4], a_xferP->count[5],
909          a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]);
910
911
912 }                               /*PrintXferTiming */
913
914
915 /*------------------------------------------------------------------------
916  * PrintErrInfo
917  *
918  * Description:
919  *      Print out the contents of an FS RPC error info structure.
920  *
921  * Arguments:
922  *      a_opIdx   : Index of the AFS operation we're printing.
923  *      a_opNames : Ptr to table of operation names.
924  *      a_opErrP  : Ptr to the op timing structure to print.
925  *
926  * Returns:
927  *      Nothing.
928  *
929  * Environment:
930  *      Nothing interesting.
931  *
932  * Side Effects:
933  *      As advertised.
934  *------------------------------------------------------------------------*/
935
936 void
937 PrintErrInfo(a_opIdx, a_opNames, a_opErrP)
938      int a_opIdx;
939      char *a_opNames[];
940      struct afs_stats_RPCErrors *a_opErrP;
941
942 {                               /*PrintErrInfo */
943
944     printf
945         ("%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n",
946          a_opNames[a_opIdx], a_opErrP->err_Server, a_opErrP->err_Network,
947          a_opErrP->err_Protection, a_opErrP->err_Volume,
948          a_opErrP->err_VolumeBusies, a_opErrP->err_Other);
949
950 }                               /*PrintErrInfo */
951
952
953 /*------------------------------------------------------------------------
954  * PrintRPCPerfInfo
955  *
956  * Description:
957  *      Print out a set of RPC performance numbers.
958  *
959  * Arguments:
960  *      a_rpcP : Ptr to RPC perf numbers to print.
961  *
962  * Returns:
963  *      Nothing.
964  *
965  * Environment:
966  *      Nothing interesting.
967  *
968  * Side Effects:
969  *      As advertised.
970  *------------------------------------------------------------------------*/
971
972 void
973 PrintRPCPerfInfo(a_rpcP)
974      struct afs_stats_RPCOpInfo *a_rpcP;
975
976 {                               /*PrintRPCPerfInfo */
977
978     int currIdx;                /*Loop variable */
979
980     /*
981      * Print the contents of each of the opcode-related arrays.
982      */
983     printf("FS Operation Timings:\n---------------------\n");
984     for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
985         PrintOpTiming(currIdx, fsOpNames, &(a_rpcP->fsRPCTimes[currIdx]));
986
987     printf("\nError Info:\n-----------\n");
988     for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
989         PrintErrInfo(currIdx, fsOpNames, &(a_rpcP->fsRPCErrors[currIdx]));
990
991     printf("\nTransfer timings:\n-----------------\n");
992     for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++)
993         PrintXferTiming(currIdx, xferOpNames,
994                         &(a_rpcP->fsXferTimes[currIdx]));
995
996     printf("\nCM Operation Timings:\n---------------------\n");
997     for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++)
998         PrintOpTiming(currIdx, cmOpNames, &(a_rpcP->cmRPCTimes[currIdx]));
999
1000 }                               /*PrintRPCPerfInfo */
1001
1002
1003 /*------------------------------------------------------------------------
1004  * PrintFullPerfInfo
1005  *
1006  * Description:
1007  *      Print out a set of full performance numbers.
1008  *
1009  * Arguments:
1010  *      None.
1011  *
1012  * Returns:
1013  *      Nothing.
1014  *
1015  * Environment:
1016  *      Nothing interesting.
1017  *
1018  * Side Effects:
1019  *      As advertised.
1020  *------------------------------------------------------------------------*/
1021
1022 void
1023 PrintFullPerfInfo()
1024 {                               /*PrintFullPerfInfo */
1025
1026     struct afs_stats_AuthentInfo *authentP;     /*Ptr to authentication stats */
1027     struct afs_stats_AccessInfo *accessinfP;    /*Ptr to access stats */
1028     struct afs_stats_AuthorInfo *authorP;       /*Ptr to authorship stats */
1029     static afs_int32 fullPerfInt32s = (sizeof(struct afs_stats_CMFullPerf) >> 2);       /*Correct #int32s */
1030     afs_int32 numInt32s;        /*# int32s actually received */
1031     struct afs_stats_CMFullPerf *fullP; /*Ptr to full perf info */
1032
1033     char *printableTime;        /*Ptr to printable time string */
1034     time_t probeTime = xstat_cm_Results.probeTime;
1035
1036     numInt32s = xstat_cm_Results.data.AFSCB_CollData_len;
1037     if (numInt32s != fullPerfInt32s) {
1038         printf("** Data size mismatch in performance collection!");
1039         printf("** Expecting %d, got %d\n", fullPerfInt32s, numInt32s);
1040         printf("** Version mismatch with Cache Manager\n");
1041         return;
1042     }
1043
1044     printableTime = ctime(&probeTime);
1045     printableTime[strlen(printableTime) - 1] = '\0';
1046     fullP = (struct afs_stats_CMFullPerf *)
1047         (xstat_cm_Results.data.AFSCB_CollData_val);
1048
1049     printf
1050         ("AFSCB_XSTATSCOLL_FULL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
1051          xstat_cm_Results.collectionNumber, xstat_cm_Results.connP->hostName,
1052          xstat_cm_Results.probeNum, printableTime);
1053
1054     /*
1055      * Print the overall numbers first, followed by all of the RPC numbers,
1056      * then each of the other groupings.
1057      */
1058     printf("Overall Performance Info:\n-------------------------\n");
1059     PrintOverallPerfInfo(&(fullP->perf));
1060     printf("\n");
1061     PrintRPCPerfInfo(&(fullP->rpc));
1062
1063     authentP = &(fullP->authent);
1064     printf("\nAuthentication info:\n--------------------\n");
1065     printf
1066         ("\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n",
1067          authentP->curr_PAGs, authentP->curr_Records,
1068          authentP->curr_AuthRecords, authentP->curr_UnauthRecords,
1069          authentP->curr_MaxRecordsInPAG, authentP->curr_LongestChain);
1070     printf("\t%d PAG creations, %d tkt updates\n", authentP->PAGCreations,
1071            authentP->TicketUpdates);
1072     printf("\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n",
1073            authentP->HWM_PAGs, authentP->HWM_Records,
1074            authentP->HWM_MaxRecordsInPAG, authentP->HWM_LongestChain);
1075
1076     accessinfP = &(fullP->accessinf);
1077     printf("\n[Un]replicated accesses:\n------------------------\n");
1078     printf
1079         ("\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n",
1080          accessinfP->unreplicatedRefs, accessinfP->replicatedRefs,
1081          accessinfP->numReplicasAccessed, accessinfP->maxReplicasPerRef,
1082          accessinfP->refFirstReplicaOK);
1083
1084     /* There really isn't any authorship info
1085      * authorP = &(fullP->author); */
1086
1087 }                               /*PrintFullPerfInfo */
1088
1089
1090 /*------------------------------------------------------------------------
1091  * CM_Handler
1092  *
1093  * Description:
1094  *      Handler routine passed to the xstat_cm module.  This handler is
1095  *      called immediately after a poll of one of the Cache Managers has
1096  *      taken place.  All it needs to know is exported by the xstat_cm
1097  *      module, namely the data structure where the probe results are
1098  *      stored.
1099  *
1100  * Arguments:
1101  *      None.
1102  *
1103  * Returns:
1104  *      0 on success,
1105  *      -1 otherwise.
1106  *
1107  * Environment:
1108  *      See above.  All we do now is print out what we got.
1109  *
1110  * Side Effects:
1111  *      As advertised.
1112  *------------------------------------------------------------------------*/
1113
1114 int
1115 CM_Handler()
1116 {                               /*CM_Handler */
1117
1118     static char rn[] = "CM_Handler";    /*Routine name */
1119
1120     printf("\n-----------------------------------------------------------\n");
1121
1122     /*
1123      * If the probe failed, there isn't much we can do except gripe.
1124      */
1125     if (xstat_cm_Results.probeOK) {
1126         printf("%s: Probe %d, collection %d to CM on '%s' failed, code=%d\n",
1127                rn, xstat_cm_Results.probeNum,
1128                xstat_cm_Results.collectionNumber,
1129                xstat_cm_Results.connP->hostName, xstat_cm_Results.probeOK);
1130         return (0);
1131     }
1132
1133     switch (xstat_cm_Results.collectionNumber) {
1134     case AFSCB_XSTATSCOLL_CALL_INFO:
1135         /* Why was this commented out in 3.3 ? */
1136         /* PrintCallInfo();  */
1137         print_cmCallStats();
1138         break;
1139
1140     case AFSCB_XSTATSCOLL_PERF_INFO:
1141         /* we will do nothing here */
1142         /* PrintPerfInfo(); */
1143         break;
1144
1145     case AFSCB_XSTATSCOLL_FULL_PERF_INFO:
1146         PrintFullPerfInfo();
1147         break;
1148
1149     default:
1150         printf("** Unknown collection: %d\n",
1151                xstat_cm_Results.collectionNumber);
1152     }
1153
1154     /*
1155      * Return the happy news.
1156      */
1157     return (0);
1158
1159 }                               /*CM_Handler */
1160
1161
1162 /*------------------------------------------------------------------------
1163  * CountListItems
1164  *
1165  * Description:
1166  *      Given a pointer to the list of Cache Managers we'll be polling
1167  *      (or, in fact, any list at all), compute the length of the list.
1168  *
1169  * Arguments:
1170  *      struct cmd_item *a_firstItem : Ptr to first item in list.
1171  *
1172  * Returns:
1173  *      Length of the above list.
1174  *
1175  * Environment:
1176  *      Nothing interesting.
1177  *
1178  * Side Effects:
1179  *      As advertised.
1180  *------------------------------------------------------------------------*/
1181
1182 static int
1183 CountListItems(a_firstItem)
1184      struct cmd_item *a_firstItem;
1185
1186 {                               /*CountListItems */
1187
1188     int list_len;               /*List length */
1189     struct cmd_item *curr_item; /*Ptr to current item */
1190
1191     list_len = 0;
1192     curr_item = a_firstItem;
1193
1194     /*
1195      * Count 'em up.
1196      */
1197     while (curr_item) {
1198         list_len++;
1199         curr_item = curr_item->next;
1200     }
1201
1202     /*
1203      * Return our tally.
1204      */
1205     return (list_len);
1206
1207 }                               /*CountListItems */
1208
1209
1210 /*------------------------------------------------------------------------
1211  * RunTheTest
1212  *
1213  * Description:
1214  *      Routine called by the command line interpreter to execute the
1215  *      meat of the program.  We count the number of Cache Managers
1216  *      to watch, allocate enough space to remember all the connection
1217  *      info for them, then go for it.
1218  *      
1219  *
1220  * Arguments:
1221  *      a_s : Ptr to the command line syntax descriptor.
1222  *
1223  * Returns:
1224  *      0, but may exit the whole program on an error!
1225  *
1226  * Environment:
1227  *      Nothing interesting.
1228  *
1229  * Side Effects:
1230  *      As advertised.
1231  *------------------------------------------------------------------------*/
1232
1233 int
1234 RunTheTest(struct cmd_syndesc *a_s, void *arock)
1235 {                               /*RunTheTest */
1236
1237     static char rn[] = "RunTheTest";    /*Routine name */
1238     int code;                   /*Return code */
1239     int numCMs;                 /*# Cache Managers to monitor */
1240     int numCollIDs;             /*# collections to fetch */
1241     int currCM;                 /*Loop index */
1242     int currCollIDIdx;          /*Index of current collection ID */
1243     afs_int32 *collIDP;         /*Ptr to array of collection IDs */
1244     afs_int32 *currCollIDP;     /*Ptr to current collection ID */
1245     struct cmd_item *curr_item; /*Current CM cmd line record */
1246     struct sockaddr_in *CMSktArray;     /*Cache Manager socket array */
1247     struct hostent *he;         /*Host entry */
1248     struct timeval tv;          /*Time structure */
1249     int sleep_secs;             /*Number of seconds to sleep */
1250     int initFlags;              /*Flags passed to the init fcn */
1251     int waitCode;               /*Result of LWP_WaitProcess() */
1252     int freq;                   /*Frequency of polls */
1253     int period;                 /*Time in minutes of data collection */
1254
1255     /*
1256      * Are we doing one-shot measurements?
1257      */
1258     if (a_s->parms[P_ONESHOT].items != 0)
1259         one_shot = 1;
1260
1261     /*
1262      * Are we doing debugging output?
1263      */
1264     if (a_s->parms[P_DEBUG].items != 0)
1265         debugging_on = 1;
1266
1267     /*
1268      * Pull out the number of Cache Managers to watch and the number of
1269      * collections to get.
1270      */
1271     numCMs = CountListItems(a_s->parms[P_CM_NAMES].items);
1272     numCollIDs = CountListItems(a_s->parms[P_COLL_IDS].items);
1273
1274     /* Get the polling frequency */
1275     if (a_s->parms[P_FREQUENCY].items != 0)
1276         freq = atoi(a_s->parms[P_FREQUENCY].items->data);
1277     else
1278         freq = 30;              /* default to 30 seconds */
1279
1280     /* Get the time duration to run the tests */
1281     if (a_s->parms[P_PERIOD].items != 0)
1282         period = atoi(a_s->parms[P_PERIOD].items->data);
1283     else
1284         period = 10;            /* default to 10 minutes */
1285
1286     /*
1287      * Allocate the socket array.
1288      */
1289     if (debugging_on)
1290         printf("%s: Allocating socket array for %d Cache Manager(s)\n", rn,
1291                numCMs);
1292     CMSktArray = (struct sockaddr_in *)
1293         malloc(numCMs * sizeof(struct sockaddr_in));
1294     if (CMSktArray == (struct sockaddr_in *)0) {
1295         printf("%s: Can't allocate socket array for %d Cache Managers\n", rn,
1296                numCMs);
1297         exit(1);
1298     }
1299
1300     /*
1301      * Fill in the socket array for each of the Cache Managers listed.
1302      */
1303     curr_item = a_s->parms[P_CM_NAMES].items;
1304     for (currCM = 0; currCM < numCMs; currCM++) {
1305 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
1306         CMSktArray[currCM].sin_family = AF_INET;        /*Internet family */
1307 #else
1308         CMSktArray[currCM].sin_family = htons(AF_INET); /*Internet family */
1309 #endif
1310         CMSktArray[currCM].sin_port = htons(7001);      /*Cache Manager port */
1311         he = hostutil_GetHostByName(curr_item->data);
1312         if (he == NULL) {
1313             fprintf(stderr, "[%s] Can't get host info for '%s'\n", rn,
1314                     curr_item->data);
1315             exit(-1);
1316         }
1317         memcpy(&(CMSktArray[currCM].sin_addr.s_addr), he->h_addr, 4);
1318
1319         /*
1320          * Move to the next CM name.
1321          */
1322         curr_item = curr_item->next;
1323
1324     }                           /*Get socket info for each Cache Manager */
1325
1326     /*
1327      * Create and fill up the array of desired collection IDs.
1328      */
1329     if (debugging_on)
1330         printf("Allocating %d long(s) for coll ID\n", numCollIDs);
1331     collIDP = (afs_int32 *) (malloc(numCollIDs * sizeof(afs_int32)));
1332     currCollIDP = collIDP;
1333     curr_item = a_s->parms[P_COLL_IDS].items;
1334     for (currCollIDIdx = 0; currCollIDIdx < numCollIDs; currCollIDIdx++) {
1335         *currCollIDP = (afs_int32) (atoi(curr_item->data));
1336         if (debugging_on)
1337             printf("CollID at index %d is %d\n", currCollIDIdx, *currCollIDP);
1338         curr_item = curr_item->next;
1339         currCollIDP++;
1340     };
1341
1342     /*
1343      * Crank up the Cache Manager prober, then sit back and have fun.
1344      */
1345     printf("\nStarting up the xstat_cm service, ");
1346     initFlags = 0;
1347     if (debugging_on) {
1348         initFlags |= XSTAT_CM_INITFLAG_DEBUGGING;
1349         printf("debugging enabled, ");
1350     } else
1351         printf("no debugging, ");
1352     if (one_shot) {
1353         initFlags |= XSTAT_CM_INITFLAG_ONE_SHOT;
1354         printf("one-shot operation\n");
1355     } else
1356         printf("continuous operation\n");
1357
1358     code = xstat_cm_Init(numCMs,        /*Num CMs */
1359                          CMSktArray,    /*File Server socket array */
1360                          freq,  /*Probe every 30 seconds */
1361                          CM_Handler,    /*Handler routine */
1362                          initFlags,     /*Initialization flags */
1363                          numCollIDs,    /*Number of collection IDs */
1364                          collIDP);      /*Ptr to collection ID array */
1365     if (code) {
1366         fprintf(stderr, "[%s] Error returned by xstat_cm_Init: %d\n", rn,
1367                 code);
1368         xstat_cm_Cleanup(1);    /*Get rid of malloc'ed structures */
1369         exit(-1);
1370     }
1371
1372     if (one_shot) {
1373         /*
1374          * One-shot operation; just wait for the collection to be done.
1375          */
1376         if (debugging_on)
1377             printf("[%s] Calling LWP_WaitProcess() on event 0x%x\n", rn,
1378                    &terminationEvent);
1379         waitCode = LWP_WaitProcess(&terminationEvent);
1380         if (debugging_on)
1381             printf("[%s] Returned from LWP_WaitProcess()\n", rn);
1382         if (waitCode) {
1383             if (debugging_on)
1384                 fprintf(stderr,
1385                         "[%s] Error %d encountered by LWP_WaitProcess()\n",
1386                         rn, waitCode);
1387         }
1388     } else {
1389         /*
1390          * Continuous operation.
1391          */
1392         sleep_secs = 60 * period;       /*length of data collection */
1393         printf
1394             ("xstat_cm service started, main thread sleeping for %d secs.\n",
1395              sleep_secs);
1396
1397         /*
1398          * Let's just fall asleep for a while, then we'll clean up.
1399          */
1400         tv.tv_sec = sleep_secs;
1401         tv.tv_usec = 0;
1402         code = IOMGR_Select(0,  /*Num fds */
1403                             0,  /*Descriptors ready for reading */
1404                             0,  /*Descriptors ready for writing */
1405                             0,  /*Descriptors with exceptional conditions */
1406                             &tv);       /*Timeout structure */
1407         if (code) {
1408             fprintf(stderr,
1409                     "[%s] IOMGR_Select() returned non-zero value: %d\n", rn,
1410                     code);
1411         }
1412     }
1413
1414     /*
1415      * We're all done.  Clean up, put the last nail in Rx, then
1416      * exit happily.
1417      */
1418     if (debugging_on)
1419         printf("\nYawn, main thread just woke up.  Cleaning things out...\n");
1420     code = xstat_cm_Cleanup(1); /*Get rid of malloc'ed data */
1421     rx_Finalize();
1422     return (0);
1423
1424 }                               /*RunTheTest */
1425
1426
1427 #include "AFS_component_version_number.c"
1428
1429 main(argc, argv)
1430      int argc;
1431      char **argv;
1432
1433 {                               /*Main routine */
1434
1435     static char rn[] = "xstat_cm_test"; /*Routine name */
1436     register afs_int32 code;    /*Return code */
1437     struct cmd_syndesc *ts;     /*Ptr to cmd line syntax desc */
1438
1439     /*
1440      * Set up the commands we understand.
1441      */
1442     ts = cmd_CreateSyntax("initcmd", RunTheTest, NULL, "initialize the program");
1443     cmd_AddParm(ts, "-cmname", CMD_LIST, CMD_REQUIRED,
1444                 "Cache Manager name(s) to monitor");
1445     cmd_AddParm(ts, "-collID", CMD_LIST, CMD_REQUIRED,
1446                 "Collection(s) to fetch");
1447     cmd_AddParm(ts, "-onceonly", CMD_FLAG, CMD_OPTIONAL,
1448                 "Collect results exactly once, then quit");
1449     cmd_AddParm(ts, "-frequency", CMD_SINGLE, CMD_OPTIONAL,
1450                 "poll frequency, in seconds");
1451     cmd_AddParm(ts, "-period", CMD_SINGLE, CMD_OPTIONAL,
1452                 "data collection time, in minutes");
1453     cmd_AddParm(ts, "-debug", CMD_FLAG, CMD_OPTIONAL,
1454                 "turn on debugging output");
1455
1456     /*
1457      * Parse command-line switches & execute the test, then get the
1458      * heck out of here.
1459      */
1460     code = cmd_Dispatch(argc, argv);
1461     if (code) {
1462         fprintf(stderr, "[%s] Call to cmd_Dispatch() failed; code is %d\n",
1463                 rn, code);
1464     }
1465
1466     exit(code);
1467
1468 }                               /*Main routine */