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