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