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