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