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