e49453cab05c3063230af70b9656314754752784
[openafs.git] / src / afsmonitor / afsmon-parselog.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  * This program will parse the output generated by afsmonitor (with the -output
12  * switch) and print it in a readable form. It does not make any statistical
13  * analysis of the data.
14  *
15  * Most of the code here is cloned from afsmon-output.c. It is made as a 
16  * separate file so that it can be independently given to customers.
17  *
18  *-------------------------------------------------------------------------*/
19
20 #include <stdio.h>
21 #include <afs/param.h>
22 #include <afsconfig.h>
23
24 RCSID("$Header$");
25
26 #include <afs/xstat_fs.h>  
27 #include <afs/xstat_cm.h>
28 #include <malloc.h>
29
30
31 /* Number of items of CM & FS statistics collected per probe.
32    These constants MUST be changed if the xstat structures are modified */
33
34 #define XSTAT_CM_FULLPERF_RESULTS_LEN 740
35 #define XSTAT_FS_FULLPERF_RESULTS_LEN 424
36
37
38 /* structures used by FS & CM stats print routines */
39
40 static char *fsOpNames[] = {
41     "FetchData",
42     "FetchACL",
43     "FetchStatus",
44     "StoreData",
45     "StoreACL",
46     "StoreStatus",
47     "RemoveFile",
48     "CreateFile",
49     "Rename",
50     "Symlink",
51     "Link",
52     "MakeDir",
53     "RemoveDir",
54     "SetLock",
55     "ExtendLock",
56     "ReleaseLock",
57     "GetStatistics",
58     "GiveUpCallbacks",
59     "GetVolumeInfo",
60     "GetVolumeStatus",
61     "SetVolumeStatus",
62     "GetRootVolume",
63     "CheckToken",
64     "GetTime",
65     "NGetVolumeInfo",
66     "BulkStatus",
67     "XStatsVersion",
68     "GetXStats"
69 };
70
71 static char *cmOpNames[] = {
72     "CallBack",
73     "InitCallBackState",
74     "Probe",
75     "GetLock",
76     "GetCE",
77     "XStatsVersion",
78     "GetXStats"
79 };
80
81 static char *xferOpNames[] = {
82     "FetchData",
83     "StoreData"
84 };
85
86 /*________________________________________________________________________
87                                 FS STATS ROUTINES 
88  *_______________________________________________________________________*/
89
90 /*------------------------------------------------------------------------
91  * Print_fs_OverallPerfInfo
92  *
93  * Description:
94  *      Print out overall performance numbers.
95  *
96  * Arguments:
97  *      a_ovP : Ptr to the overall performance numbers.
98  *
99  *------------------------------------------------------------------------*/
100
101 void Print_fs_OverallPerfInfo(a_ovP)
102     struct afs_PerfStats *a_ovP;
103
104 { /*Print_fs_OverallPerfInfo*/
105
106     printf("\t%10d numPerfCalls\n\n", a_ovP->numPerfCalls);
107
108
109     /*
110      * Vnode cache section.
111      */
112     printf("\t%10d vcache_L_Entries\n", a_ovP->vcache_L_Entries);
113     printf("\t%10d vcache_L_Allocs\n",  a_ovP->vcache_L_Allocs);
114     printf("\t%10d vcache_L_Gets\n",      a_ovP->vcache_L_Gets);
115     printf("\t%10d vcache_L_Reads\n",     a_ovP->vcache_L_Reads);
116     printf("\t%10d vcache_L_Writes\n\n",a_ovP->vcache_L_Writes);
117
118     printf("\t%10d vcache_S_Entries\n", a_ovP->vcache_S_Entries);
119     printf("\t%10d vcache_S_Allocs\n",  a_ovP->vcache_S_Allocs);
120     printf("\t%10d vcache_S_Gets\n",      a_ovP->vcache_S_Gets);
121     printf("\t%10d vcache_S_Reads\n",     a_ovP->vcache_S_Reads);
122     printf("\t%10d vcache_S_Writes\n\n",a_ovP->vcache_S_Writes);
123
124     printf("\t%10d vcache_H_Entries\n", a_ovP->vcache_H_Entries);
125     printf("\t%10d vcache_H_Gets\n",      a_ovP->vcache_H_Gets);
126     printf("\t%10d vcache_H_Replacements\n\n",a_ovP->vcache_H_Replacements);
127
128     /*
129      * Directory package section.
130      */
131     printf("\t%10d dir_Buffers\n", a_ovP->dir_Buffers);
132     printf("\t%10d dir_Calls\n", a_ovP->dir_Calls);
133     printf("\t%10d dir_IOs\n\n", a_ovP->dir_IOs);
134
135     /*
136      * Rx section.
137      */
138     printf("\t%10d rx_packetRequests\n", a_ovP->rx_packetRequests);
139     printf("\t%10d rx_noPackets_RcvClass\n", a_ovP->rx_noPackets_RcvClass);
140     printf("\t%10d rx_noPackets_SendClass\n",   a_ovP->rx_noPackets_SendClass);
141     printf("\t%10d rx_noPackets_SpecialClass\n", a_ovP->rx_noPackets_SpecialClass);
142     printf("\t%10d rx_socketGreedy\n", a_ovP->rx_socketGreedy);
143     printf("\t%10d rx_bogusPacketOnRead\n", a_ovP->rx_bogusPacketOnRead);
144     printf("\t%10d rx_bogusHost\n",     a_ovP->rx_bogusHost);
145     printf("\t%10d rx_noPacketOnRead\n", a_ovP->rx_noPacketOnRead);
146     printf("\t%10d rx_noPacketBuffersOnRead\n", a_ovP->rx_noPacketBuffersOnRead);
147     printf("\t%10d rx_selects\n", a_ovP->rx_selects);
148     printf("\t%10d rx_sendSelects\n",   a_ovP->rx_sendSelects);
149     printf("\t%10d rx_packetsRead_RcvClass\n", a_ovP->rx_packetsRead_RcvClass);
150     printf("\t%10d rx_packetsRead_SendClass\n", a_ovP->rx_packetsRead_SendClass);
151     printf("\t%10d rx_packetsRead_SpecialClass\n", a_ovP->rx_packetsRead_SpecialClass);
152     printf("\t%10d rx_dataPacketsRead\n", a_ovP->rx_dataPacketsRead);
153     printf("\t%10d rx_ackPacketsRead\n", a_ovP->rx_ackPacketsRead);
154     printf("\t%10d rx_dupPacketsRead\n", a_ovP->rx_dupPacketsRead);
155     printf("\t%10d rx_spuriousPacketsRead\n",   a_ovP->rx_spuriousPacketsRead);
156     printf("\t%10d rx_packetsSent_RcvClass\n", a_ovP->rx_packetsSent_RcvClass);
157     printf("\t%10d rx_packetsSent_SendClass\n", a_ovP->rx_packetsSent_SendClass);
158     printf("\t%10d rx_packetsSent_SpecialClass\n", a_ovP->rx_packetsSent_SpecialClass);
159     printf("\t%10d rx_ackPacketsSent\n", a_ovP->rx_ackPacketsSent);
160     printf("\t%10d rx_pingPacketsSent\n", a_ovP->rx_pingPacketsSent);
161     printf("\t%10d rx_abortPacketsSent\n",a_ovP->rx_abortPacketsSent);
162     printf("\t%10d rx_busyPacketsSent\n", a_ovP->rx_busyPacketsSent);
163     printf("\t%10d rx_dataPacketsSent\n", a_ovP->rx_dataPacketsSent);
164     printf("\t%10d rx_dataPacketsReSent\n", a_ovP->rx_dataPacketsReSent);
165     printf("\t%10d rx_dataPacketsPushed\n",     a_ovP->rx_dataPacketsPushed);
166     printf("\t%10d rx_ignoreAckedPacket\n",     a_ovP->rx_ignoreAckedPacket);
167     printf("\t%10d rx_totalRtt_Sec\n", a_ovP->rx_totalRtt_Sec);
168     printf("\t%10d rx_totalRtt_Usec\n", a_ovP->rx_totalRtt_Usec);
169     printf("\t%10d rx_minRtt_Sec\n",    a_ovP->rx_minRtt_Sec);
170     printf("\t%10d rx_minRtt_Usec\n",           a_ovP->rx_minRtt_Usec);
171     printf("\t%10d rx_maxRtt_Sec\n",            a_ovP->rx_maxRtt_Sec);
172     printf("\t%10d rx_maxRtt_Usec\n",           a_ovP->rx_maxRtt_Usec);
173     printf("\t%10d rx_nRttSamples\n",           a_ovP->rx_nRttSamples);
174     printf("\t%10d rx_nServerConns\n",  a_ovP->rx_nServerConns);
175     printf("\t%10d rx_nClientConns\n",  a_ovP->rx_nClientConns);
176     printf("\t%10d rx_nPeerStructs\n",  a_ovP->rx_nPeerStructs);
177     printf("\t%10d rx_nCallStructs\n",  a_ovP->rx_nCallStructs);
178     printf("\t%10d rx_nFreeCallStructs\n\n",    a_ovP->rx_nFreeCallStructs);
179
180     /*
181      * Host module fields.
182      */
183     printf("\t%10d host_NumHostEntries\n",      a_ovP->host_NumHostEntries);
184     printf("\t%10d host_HostBlocks\n",  a_ovP->host_HostBlocks);
185     printf("\t%10d host_NonDeletedHosts\n",     a_ovP->host_NonDeletedHosts);
186     printf("\t%10d host_HostsInSameNetOrSubnet\n", a_ovP->host_HostsInSameNetOrSubnet);
187     printf("\t%10d host_HostsInDiffSubnet\n",   a_ovP->host_HostsInDiffSubnet);
188     printf("\t%10d host_HostsInDiffNetwork\n",a_ovP->host_HostsInDiffNetwork);
189     printf("\t%10d host_NumClients\n",  a_ovP->host_NumClients);
190     printf("\t%10d host_ClientBlocks\n\n",      a_ovP->host_ClientBlocks);
191
192 } /*Print_fs_OverallPerfInfo*/
193
194
195 /*------------------------------------------------------------------------
196  * Print_fs_OpTiming
197  *
198  * Description:
199  *      Print out the contents of an RPC op timing structure.
200  *
201  * Arguments:
202  *      a_opIdx   : Index of the AFS operation we're printing number on.
203  *      a_opTimeP : Ptr to the op timing structure to print.
204  *
205  *------------------------------------------------------------------------*/
206
207 void Print_fs_OpTiming(a_opIdx, a_opTimeP)
208     int a_opIdx;
209     struct fs_stats_opTimingData *a_opTimeP;
210
211 { /*Print_fs_OpTiming*/
212
213     printf("%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
214            fsOpNames[a_opIdx],
215            a_opTimeP->numOps, a_opTimeP->numSuccesses,
216            a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
217            a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
218            a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
219
220 } /*Print_fs_OpTiming*/
221
222
223 /*------------------------------------------------------------------------
224  * Print_fs_XferTiming
225  *
226  * Description:
227  *      Print out the contents of a data transfer structure.
228  *
229  * Arguments:
230  *      a_opIdx : Index of the AFS operation we're printing number on.
231  *      a_xferP : Ptr to the data transfer structure to print.
232  *
233  *------------------------------------------------------------------------*/
234
235 void Print_fs_XferTiming(a_opIdx, a_xferP)
236     int a_opIdx;
237     struct fs_stats_xferData *a_xferP;
238
239 { /*Print_fs_XferTiming*/
240
241     printf("%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
242            xferOpNames[a_opIdx],
243            a_xferP->numXfers, a_xferP->numSuccesses,
244            a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
245            a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
246            a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
247     printf("\t[bytes: sum=%d, min=%d, max=%d]\n",
248            a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
249     printf("\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d 7:%d 8:%d]\n",
250            a_xferP->count[0],
251            a_xferP->count[1],
252            a_xferP->count[2],
253            a_xferP->count[3],
254            a_xferP->count[4],
255            a_xferP->count[5],
256            a_xferP->count[6],
257            a_xferP->count[7],
258            a_xferP->count[8]);
259
260 } /*Print_fs_XferTiming*/
261
262
263 /*------------------------------------------------------------------------
264  * Print_fs_DetailedPerfInfo
265  *
266  * Description:
267  *      Print out a set of detailed performance numbers.
268  *
269  * Arguments:
270  *      a_detP : Ptr to detailed perf numbers to print.
271  *
272  *------------------------------------------------------------------------*/
273
274 void Print_fs_DetailedPerfInfo(a_detP)
275     struct fs_stats_DetailedStats *a_detP;
276
277 { /*Print_fs_DetailedPerfInfo*/
278
279     int currIdx;        /*Loop variable*/
280
281     printf("\t%10d epoch\n", a_detP->epoch);
282
283     for (currIdx = 0; currIdx < FS_STATS_NUM_RPC_OPS; currIdx++)
284         Print_fs_OpTiming(currIdx, &(a_detP->rpcOpTimes[currIdx]));
285
286     for (currIdx = 0; currIdx < FS_STATS_NUM_XFER_OPS; currIdx++)
287         Print_fs_XferTiming(currIdx, &(a_detP->xferOpTimes[currIdx]));
288
289 } /*Print_fs_DetailedPerfInfo*/
290
291
292 /*------------------------------------------------------------------------
293  * Print_fs_FullPerfInfo
294  *
295  * Description:
296  *      Print out the AFS_XSTATSCOLL_FULL_PERF_INFO collection we just
297  *      received.
298  *
299  * Arguments:
300  *      None.
301  *
302  *------------------------------------------------------------------------*/
303
304 void Print_fs_FullPerfInfo(a_fs_Results)
305 struct xstat_fs_ProbeResults *a_fs_Results;             /* ptr to fs results */
306 { /*Print_fs_FullPerfInfo*/
307
308     static char rn[] = "Print_fs_FullPerfInfo";       /*Routine name*/
309     static long fullPerfLongs =
310         (sizeof(struct fs_stats_FullPerfStats) >> 2); /*Correct # longs to rcv*/
311     long numLongs;                                    /*# longwords received*/
312     struct fs_stats_FullPerfStats *fullPerfP;         /*Ptr to full perf stats*/
313     char *printableTime;                        /*Ptr to printable time string*/
314
315
316     numLongs = a_fs_Results->data.AFS_CollData_len;
317     if (numLongs != fullPerfLongs) {
318         printf(" ** Data size mismatch in full performance collection!\n");
319         printf(" ** Expecting %d, got %d\n", fullPerfLongs, numLongs);
320         return;
321     }
322
323     printableTime = ctime(&(a_fs_Results->probeTime));
324     printableTime[strlen(printableTime)-1] = '\0';
325     fullPerfP = (struct fs_stats_FullPerfStats *)
326         (a_fs_Results->data.AFS_CollData_val);
327
328     printf("AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n",
329            a_fs_Results->collectionNumber,
330            a_fs_Results->connP->hostName,
331            a_fs_Results->probeNum,
332            printableTime);
333
334     Print_fs_OverallPerfInfo(&(fullPerfP->overall));
335     Print_fs_DetailedPerfInfo(&(fullPerfP->det));
336
337 } /*Print_fs_FullPerfInfo*/
338
339
340    
341 /*___________________________________________________________________________
342                         CM STATS
343  *__________________________________________________________________________*/
344
345
346
347 /*------------------------------------------------------------------------
348  * Print_cm_UpDownStats
349  *
350  * Description:
351  *      Print the up/downtime stats for the given class of server records
352  *      provided.
353  *
354  * Arguments:
355  *      a_upDownP : Ptr to the server up/down info.
356  *
357  *------------------------------------------------------------------------*/
358
359 void Print_cm_UpDownStats(a_upDownP)
360     struct afs_stats_SrvUpDownInfo *a_upDownP;  /*Ptr to server up/down info*/
361
362 { /*Print_cm_UpDownStats*/
363
364     /*
365      * First, print the simple values.
366      */
367     printf("\t\t%10d numTtlRecords\n",          a_upDownP->numTtlRecords);
368     printf("\t\t%10d numUpRecords\n",           a_upDownP->numUpRecords);
369     printf("\t\t%10d numDownRecords\n",         a_upDownP->numDownRecords);
370     printf("\t\t%10d sumOfRecordAges\n",        a_upDownP->sumOfRecordAges);
371     printf("\t\t%10d ageOfYoungestRecord\n",    a_upDownP->ageOfYoungestRecord);
372     printf("\t\t%10d ageOfOldestRecord\n",      a_upDownP->ageOfOldestRecord);
373     printf("\t\t%10d numDowntimeIncidents\n",   a_upDownP->numDowntimeIncidents);
374     printf("\t\t%10d numRecordsNeverDown\n",    a_upDownP->numRecordsNeverDown);
375     printf("\t\t%10d maxDowntimesInARecord\n",  a_upDownP->maxDowntimesInARecord);
376     printf("\t\t%10d sumOfDowntimes\n",         a_upDownP->sumOfDowntimes);
377     printf("\t\t%10d shortestDowntime\n",       a_upDownP->shortestDowntime);
378     printf("\t\t%10d longestDowntime\n",        a_upDownP->longestDowntime);
379
380     /*
381      * Now, print the array values.
382      */
383     printf("\t\tDowntime duration distribution:\n");
384     printf("\t\t\t%8d: 0 min .. 10 min\n",  a_upDownP->downDurations[0]);
385     printf("\t\t\t%8d: 10 min .. 30 min\n", a_upDownP->downDurations[1]);
386     printf("\t\t\t%8d: 30 min .. 1 hr\n",   a_upDownP->downDurations[2]);
387     printf("\t\t\t%8d: 1 hr .. 2 hr\n",     a_upDownP->downDurations[3]);
388     printf("\t\t\t%8d: 2 hr .. 4 hr\n",     a_upDownP->downDurations[4]);
389     printf("\t\t\t%8d: 4 hr .. 8 hr\n",     a_upDownP->downDurations[5]);
390     printf("\t\t\t%8d: > 8 hr\n",           a_upDownP->downDurations[6]);
391
392     printf("\t\tDowntime incident distribution:\n");
393     printf("\t\t\t%8d: 0 times\n",        a_upDownP->downIncidents[0]);
394     printf("\t\t\t%8d: 1 time\n",         a_upDownP->downIncidents[1]);
395     printf("\t\t\t%8d: 2 .. 5 times\n",   a_upDownP->downIncidents[2]);
396     printf("\t\t\t%8d: 6 .. 10 times\n",  a_upDownP->downIncidents[3]);
397     printf("\t\t\t%8d: 10 .. 50 times\n", a_upDownP->downIncidents[4]);
398     printf("\t\t\t%8d: > 50 times\n",     a_upDownP->downIncidents[5]);
399
400 } /*Print_cm_UpDownStats*/
401
402
403 /*------------------------------------------------------------------------
404  * Print_cm_OverallPerfInfo
405  *
406  * Description:
407  *      Print out overall performance numbers.
408  *
409  * Arguments:
410  *      a_ovP : Ptr to the overall performance numbers.
411  *
412  *------------------------------------------------------------------------*/
413
414 void Print_cm_OverallPerfInfo(a_ovP)
415     struct afs_stats_CMPerf *a_ovP;
416
417 { /*Print_cm_OverallPerfInfo*/
418
419     printf("\t%10d numPerfCalls\n",             a_ovP->numPerfCalls);
420
421     printf("\t%10d epoch\n",                    a_ovP->epoch);
422     printf("\t%10d numCellsVisible\n",  a_ovP->numCellsVisible);
423     printf("\t%10d numCellsContacted\n",        a_ovP->numCellsContacted);
424     printf("\t%10d dlocalAccesses\n",           a_ovP->dlocalAccesses);
425     printf("\t%10d vlocalAccesses\n",           a_ovP->vlocalAccesses);
426     printf("\t%10d dremoteAccesses\n",  a_ovP->dremoteAccesses);
427     printf("\t%10d vremoteAccesses\n",  a_ovP->vremoteAccesses);
428     printf("\t%10d cacheNumEntries\n",  a_ovP->cacheNumEntries);
429     printf("\t%10d cacheBlocksTotal\n", a_ovP->cacheBlocksTotal);
430     printf("\t%10d cacheBlocksInUse\n", a_ovP->cacheBlocksInUse);
431     printf("\t%10d cacheBlocksOrig\n",  a_ovP->cacheBlocksOrig);
432     printf("\t%10d cacheMaxDirtyChunks\n",a_ovP->cacheMaxDirtyChunks);
433     printf("\t%10d cacheCurrDirtyChunks\n",     a_ovP->cacheCurrDirtyChunks);
434     printf("\t%10d dcacheHits\n",               a_ovP->dcacheHits);
435     printf("\t%10d vcacheHits\n",               a_ovP->vcacheHits);
436     printf("\t%10d dcacheMisses\n",             a_ovP->dcacheMisses);
437     printf("\t%10d vcacheMisses\n",             a_ovP->vcacheMisses);
438     printf("\t%10d cacheFilesReused\n", a_ovP->cacheFilesReused);
439     printf("\t%10d vcacheXAllocs\n",            a_ovP->vcacheXAllocs);
440
441     printf("\t%10d bufAlloced\n",               a_ovP->bufAlloced);
442     printf("\t%10d bufHits\n",                  a_ovP->bufHits);
443     printf("\t%10d bufMisses\n",                a_ovP->bufMisses);
444     printf("\t%10d bufFlushDirty\n",            a_ovP->bufFlushDirty);
445
446     printf("\t%10d LargeBlocksActive\n",        a_ovP->LargeBlocksActive);
447     printf("\t%10d LargeBlocksAlloced\n",       a_ovP->LargeBlocksAlloced);
448     printf("\t%10d SmallBlocksActive\n",        a_ovP->SmallBlocksActive);
449     printf("\t%10d SmallBlocksAlloced\n",       a_ovP->SmallBlocksAlloced);
450     printf("\t%10d OutStandingMemUsage\n",      a_ovP->OutStandingMemUsage);
451     printf("\t%10d OutStandingAllocs\n",        a_ovP->OutStandingAllocs);
452     printf("\t%10d CallBackAlloced\n",  a_ovP->CallBackAlloced);
453     printf("\t%10d CallBackFlushes\n",  a_ovP->CallBackFlushes);
454
455     printf("\t%10d srvRecords\n",               a_ovP->srvRecords);
456     printf("\t%10d srvNumBuckets\n",            a_ovP->srvNumBuckets);
457     printf("\t%10d srvMaxChainLength\n",        a_ovP->srvMaxChainLength);
458     printf("\t%10d srvMaxChainLengthHWM\n",     a_ovP->srvMaxChainLengthHWM);
459     printf("\t%10d srvRecordsHWM\n",            a_ovP->srvRecordsHWM);
460
461     printf("\t%10d sysName_ID\n",               a_ovP->sysName_ID);
462
463     printf("\tFile Server up/downtimes, same cell:\n");
464     Print_cm_UpDownStats(&(a_ovP->fs_UpDown[0]));
465
466     printf("\tFile Server up/downtimes, diff cell:\n");
467     Print_cm_UpDownStats(&(a_ovP->fs_UpDown[1]));
468
469     printf("\tVL Server up/downtimes, same cell:\n");
470     Print_cm_UpDownStats(&(a_ovP->vl_UpDown[0]));
471
472     printf("\tVL Server up/downtimes, diff cell:\n");
473     Print_cm_UpDownStats(&(a_ovP->vl_UpDown[1]));
474
475 } /*Print_cm_OverallPerfInfo*/
476
477
478
479 /*------------------------------------------------------------------------
480  * Print_cm_OpTiming
481  *
482  * Description:
483  *      Print out the contents of an FS RPC op timing structure.
484  *
485  * Arguments:
486  *      a_opIdx   : Index of the AFS operation we're printing number on.
487  *      a_opNames : Ptr to table of operaton names.
488  *      a_opTimeP : Ptr to the op timing structure to print.
489  *
490  *------------------------------------------------------------------------*/
491
492 void Print_cm_OpTiming(a_opIdx, a_opNames, a_opTimeP)
493     int a_opIdx;
494     char *a_opNames[];
495     struct afs_stats_opTimingData *a_opTimeP;
496
497 { /*Print_cm_OpTiming*/
498
499     printf("%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
500            a_opNames[a_opIdx],
501            a_opTimeP->numOps, a_opTimeP->numSuccesses,
502            a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
503            a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
504            a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
505
506 } /*Print_cm_OpTiming*/
507
508
509 /*------------------------------------------------------------------------
510  * Print_cm_XferTiming
511  *
512  * Description:
513  *      Print out the contents of a data transfer structure.
514  *
515  * Arguments:
516  *      a_opIdx : Index of the AFS operation we're printing number on.
517  *      a_xferP : Ptr to the data transfer structure to print.
518  *
519  *------------------------------------------------------------------------*/
520
521 void Print_cm_XferTiming(a_opIdx, a_opNames, a_xferP)
522     int a_opIdx;
523     char *a_opNames[];
524     struct afs_stats_xferData *a_xferP;
525
526 { /*Print_cm_XferTiming*/
527
528     printf("%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
529            a_opNames[a_opIdx],
530            a_xferP->numXfers, a_xferP->numSuccesses,
531            a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
532            a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
533            a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
534     printf("\t[bytes: sum=%d, min=%d, max=%d]\n",
535            a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
536     printf("\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d, 6: %d, 7: %d, 8: %d]\n",
537            a_xferP->count[0],
538            a_xferP->count[1],
539            a_xferP->count[2],
540            a_xferP->count[3],
541            a_xferP->count[4],
542            a_xferP->count[5],
543            a_xferP->count[6],
544            a_xferP->count[7],
545            a_xferP->count[8]);
546
547 } /*Print_cm_XferTiming*/
548
549
550 /*------------------------------------------------------------------------
551  * Print_cm_ErrInfo
552  *
553  * Description:
554  *      Print out the contents of an FS RPC error info structure.
555  *
556  * Arguments:
557  *      a_opIdx   : Index of the AFS operation we're printing.
558  *      a_opNames : Ptr to table of operation names.
559  *      a_opErrP  : Ptr to the op timing structure to print.
560  *
561  *------------------------------------------------------------------------*/
562
563 void Print_cm_ErrInfo(a_opIdx, a_opNames, a_opErrP)
564     int a_opIdx;
565     char *a_opNames[];
566     struct afs_stats_RPCErrors *a_opErrP;
567
568 { /*Print_cm_ErrInfo*/
569
570     printf("%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n",
571            a_opNames[a_opIdx],
572            a_opErrP->err_Server,
573            a_opErrP->err_Network,
574            a_opErrP->err_Protection,
575            a_opErrP->err_Volume,
576            a_opErrP->err_VolumeBusies,
577            a_opErrP->err_Other);
578
579 } /*Print_cm_ErrInfo*/
580
581
582 /*------------------------------------------------------------------------
583  * Print_cm_RPCPerfInfo
584  *
585  * Description:
586  *      Print out a set of RPC performance numbers.
587  *
588  * Arguments:
589  *      a_rpcP : Ptr to RPC perf numbers to print.
590  *
591  *------------------------------------------------------------------------*/
592
593 void Print_cm_RPCPerfInfo(a_rpcP)
594     struct afs_stats_RPCOpInfo *a_rpcP;
595
596 { /*Print_cm_RPCPerfInfo*/
597
598     int currIdx;                /*Loop variable*/
599
600     /*
601      * Print the contents of each of the opcode-related arrays.
602      */
603     printf("FS Operation Timings:\n---------------------\n");
604     for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
605         Print_cm_OpTiming(currIdx, fsOpNames, &(a_rpcP->fsRPCTimes[currIdx]));
606
607     printf("\nError Info:\n-----------\n");
608     for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
609         Print_cm_ErrInfo(currIdx, fsOpNames, &(a_rpcP->fsRPCErrors[currIdx]));
610
611     printf("\nTransfer timings:\n-----------------\n");
612     for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++)
613         Print_cm_XferTiming(currIdx, xferOpNames, &(a_rpcP->fsXferTimes[currIdx]));
614
615     printf("\nCM Operation Timings:\n---------------------\n");
616     for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++)
617         Print_cm_OpTiming(currIdx, cmOpNames, &(a_rpcP->cmRPCTimes[currIdx]));
618
619 } /*Print_cm_RPCPerfInfo*/
620
621
622 /*------------------------------------------------------------------------
623  * Print_cm_FullPerfInfo
624  *
625  * Description:
626  *      Print out a set of full performance numbers.
627  *
628  * Arguments:
629  *      None.
630  *
631  *------------------------------------------------------------------------*/
632
633 void Print_cm_FullPerfInfo(a_fullP)
634 struct afs_stats_CMFullPerf *a_fullP;
635 { /*Print_cm_FullPerfInfo*/
636
637     static char rn[] = "Print_cm_FullPerfInfo"; /* routine name */
638     struct afs_stats_AuthentInfo *authentP;     /*Ptr to authentication stats*/
639     struct afs_stats_AccessInfo *accessinfP;    /*Ptr to access stats*/
640     struct afs_stats_AuthorInfo *authorP;       /*Ptr to authorship stats*/
641    static long fullPerfLongs =
642         (sizeof (struct afs_stats_CMFullPerf) >> 2); /*Correct #longs*/
643     long numLongs;                              /*# longs actually received*/
644     struct afs_stats_CMFullPerf *fullP;
645
646     fullP = a_fullP;
647
648     /*
649      * Print the overall numbers first, followed by all of the RPC numbers,
650      * then each of the other groupings.
651      */
652     printf("Overall Performance Info:\n-------------------------\n");
653     Print_cm_OverallPerfInfo(&(fullP->perf));
654     printf("\n");
655     Print_cm_RPCPerfInfo(&(fullP->rpc));
656
657     authentP = &(fullP->authent);
658     printf("\nAuthentication info:\n--------------------\n");
659     printf("\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n",
660            authentP->curr_PAGs,
661            authentP->curr_Records,
662            authentP->curr_AuthRecords,
663            authentP->curr_UnauthRecords,
664            authentP->curr_MaxRecordsInPAG,
665            authentP->curr_LongestChain);
666     printf("\t%d PAG creations, %d tkt updates\n",
667            authentP->PAGCreations,
668            authentP->TicketUpdates);
669     printf("\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n",
670            authentP->HWM_PAGs,
671            authentP->HWM_Records,
672            authentP->HWM_MaxRecordsInPAG,
673            authentP->HWM_LongestChain);
674
675     accessinfP = &(fullP->accessinf);
676     printf("\n[Un]replicated accesses:\n------------------------\n");
677     printf("\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n",
678            accessinfP->unreplicatedRefs,
679            accessinfP->replicatedRefs,
680            accessinfP->numReplicasAccessed,
681            accessinfP->maxReplicasPerRef,
682            accessinfP->refFirstReplicaOK);
683
684     /* There really isn't any authorship info
685     authorP = &(fullP->author); */
686
687 } /*Print_cm_FullPerfInfo*/
688
689
690
691
692 main(argc,argv)
693 int argc;
694 char *argv[];
695 {
696   static char rn[] = "main";
697   FILE *inFD;
698   char  *line, *charPtr;
699   long  *longs, *longPtr;
700   int   block_size, exitcode, i, numLongs, counter;
701   char  day[5],month[5],date[5],time[10],year[5],hostname[80],hosttype[5];
702   struct afs_stats_CMFullPerf *cmPerfP;
703   struct fs_stats_FullPerfStats *fsPerfP;
704   char  tmpstr[20];
705
706
707   if ((argc < 2) || (strcasecmp(argv[1],"-h")==0) || 
708       (strcasecmp(argv[1],"-help")==0) || (strcasecmp(argv[1],"help")==0) ) {
709     fprintf(stderr,"\nUsage: %s  <file>\n",argv[0]);
710     fprintf(stderr,"\twhere <file> is the output generated by AFSMonitor\n\n");
711     exit(1);
712    }
713
714
715
716   inFD = fopen(argv[1],"r");
717   if (inFD == (FILE *)0) {
718     fprintf(stderr,"\n[ %s ] Unable to open input file %s. \n",rn,argv[1]);
719     exit(5);
720   }
721
722   block_size = XSTAT_CM_FULLPERF_RESULTS_LEN * sizeof(long);
723   
724   /* Malloc two blocks of data, one for reading each line from the data file
725      and the other for coverting data to longs */
726
727   if ( (line = malloc(block_size+256)) == (char *)NULL) {
728         fprintf(stderr,"[ %s ] malloc %d bytes failed\n",rn,block_size+256);
729         exit(10);
730       }
731
732   if ( (longs = malloc(block_size)) == (long *) NULL) {
733     fprintf(stderr,"[ %s ] malloc %d bytes failed\n",rn,block_size);
734     exit(20);
735   }
736
737   /* Parse the data file */
738   while (1) {
739   if (fgets(line, block_size, inFD) == NULL) {
740     exitcode = 0; 
741     goto FINISH;
742   }
743   if (strlen(line) < 5)
744     continue;
745
746   /* Parse the date, hostname, and hosttype (FS or CM) */
747   
748   charPtr = line;
749   sscanf(charPtr,"%s %s %s %s %s %s %s", day,month,date,time,
750                         year,hostname,hosttype);
751   charPtr += strlen(day) + strlen(month) + strlen(date) +  strlen(time) + 
752          strlen(year) +  strlen(hostname) +  strlen(hosttype) + 8;
753
754   printf("\n\n%s %s %s %s %s %s %s \n\n",
755          day,month,date,time,year,hostname, hosttype);
756
757   /* Check the first datum. If it is -1 the probe had failed */
758
759   sscanf(charPtr,"%s",tmpstr);
760   if ( atoi(tmpstr) == -1) {
761     printf("Probe failed, no data to process.\n");
762     continue;
763   }
764
765   /* Convert the data to longs */
766   
767   if (strcmp(hosttype,"FS") == 0) numLongs = XSTAT_FS_FULLPERF_RESULTS_LEN;
768   else if (strcmp(hosttype,"CM") == 0) numLongs=XSTAT_CM_FULLPERF_RESULTS_LEN;
769   else {
770     fprintf(stderr, "Cannot determine hosttype %s\n",hosttype);
771     fprintf(stderr,"Skipping this entry\n");
772     continue;
773   }
774
775   longPtr = longs;
776   counter = 0;
777   for (i = 0; i < numLongs; i++) {
778     sscanf(charPtr,"%ld",longPtr);
779     sscanf(charPtr,"%s",tmpstr);
780     longPtr++;
781     charPtr += strlen(tmpstr) + 1;
782     counter++;
783    }
784
785   /* Verify that we read the correct number of longs and print them */
786
787   if (strcmp(hosttype,"CM") == 0) {
788     if (counter == XSTAT_CM_FULLPERF_RESULTS_LEN)
789       Print_cm_FullPerfInfo( (struct afs_stats_CMFullPerf *) longs);
790     else 
791       fprintf(stderr,"Data size mismatch error. Expected %d longs, found %d longs\n",numLongs,counter);
792   }
793   else {
794     if (counter == XSTAT_FS_FULLPERF_RESULTS_LEN) {
795       fsPerfP = (struct fs_stats_FullPerfStats *) longs;
796       Print_fs_OverallPerfInfo (&(fsPerfP->overall));
797       Print_fs_DetailedPerfInfo (&(fsPerfP->det));
798     }
799     else
800       fprintf(stderr,"Data size mismatch error. Expected %d longs, found %d longs\n",numLongs,counter);
801       
802   }
803
804   printf("\n-------------------------------------------------------------------------\n"); 
805   } /* while */
806
807   exitcode = 0;
808
809 FINISH:
810   fclose(inFD);
811   free(line);
812   free(longs);
813 }
814   
815