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