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