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