time-t-casting-fixes-20060404
[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     time_t probeTime;
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     probeTime = a_fs_Results->probeTime;
333     printableTime = ctime(&probeTime);
334     printableTime[strlen(printableTime) - 1] = '\0';
335     fullPerfP = (struct fs_stats_FullPerfStats *)
336         (a_fs_Results->data.AFS_CollData_val);
337
338     printf
339         ("AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n",
340          a_fs_Results->collectionNumber, a_fs_Results->connP->hostName,
341          a_fs_Results->probeNum, printableTime);
342
343     Print_fs_OverallPerfInfo(&(fullPerfP->overall));
344     Print_fs_DetailedPerfInfo(&(fullPerfP->det));
345
346 }                               /*Print_fs_FullPerfInfo */
347
348
349
350 /*___________________________________________________________________________
351                         CM STATS
352  *__________________________________________________________________________*/
353
354
355
356 /*------------------------------------------------------------------------
357  * Print_cm_UpDownStats
358  *
359  * Description:
360  *      Print the up/downtime stats for the given class of server records
361  *      provided.
362  *
363  * Arguments:
364  *      a_upDownP : Ptr to the server up/down info.
365  *
366  *------------------------------------------------------------------------*/
367
368 void
369 Print_cm_UpDownStats(a_upDownP)
370      struct afs_stats_SrvUpDownInfo *a_upDownP; /*Ptr to server up/down info */
371
372 {                               /*Print_cm_UpDownStats */
373
374     /*
375      * First, print the simple values.
376      */
377     printf("\t\t%10d numTtlRecords\n", a_upDownP->numTtlRecords);
378     printf("\t\t%10d numUpRecords\n", a_upDownP->numUpRecords);
379     printf("\t\t%10d numDownRecords\n", a_upDownP->numDownRecords);
380     printf("\t\t%10d sumOfRecordAges\n", a_upDownP->sumOfRecordAges);
381     printf("\t\t%10d ageOfYoungestRecord\n", a_upDownP->ageOfYoungestRecord);
382     printf("\t\t%10d ageOfOldestRecord\n", a_upDownP->ageOfOldestRecord);
383     printf("\t\t%10d numDowntimeIncidents\n",
384            a_upDownP->numDowntimeIncidents);
385     printf("\t\t%10d numRecordsNeverDown\n", a_upDownP->numRecordsNeverDown);
386     printf("\t\t%10d maxDowntimesInARecord\n",
387            a_upDownP->maxDowntimesInARecord);
388     printf("\t\t%10d sumOfDowntimes\n", a_upDownP->sumOfDowntimes);
389     printf("\t\t%10d shortestDowntime\n", a_upDownP->shortestDowntime);
390     printf("\t\t%10d longestDowntime\n", a_upDownP->longestDowntime);
391
392     /*
393      * Now, print the array values.
394      */
395     printf("\t\tDowntime duration distribution:\n");
396     printf("\t\t\t%8d: 0 min .. 10 min\n", a_upDownP->downDurations[0]);
397     printf("\t\t\t%8d: 10 min .. 30 min\n", a_upDownP->downDurations[1]);
398     printf("\t\t\t%8d: 30 min .. 1 hr\n", a_upDownP->downDurations[2]);
399     printf("\t\t\t%8d: 1 hr .. 2 hr\n", a_upDownP->downDurations[3]);
400     printf("\t\t\t%8d: 2 hr .. 4 hr\n", a_upDownP->downDurations[4]);
401     printf("\t\t\t%8d: 4 hr .. 8 hr\n", a_upDownP->downDurations[5]);
402     printf("\t\t\t%8d: > 8 hr\n", a_upDownP->downDurations[6]);
403
404     printf("\t\tDowntime incident distribution:\n");
405     printf("\t\t\t%8d: 0 times\n", a_upDownP->downIncidents[0]);
406     printf("\t\t\t%8d: 1 time\n", a_upDownP->downIncidents[1]);
407     printf("\t\t\t%8d: 2 .. 5 times\n", a_upDownP->downIncidents[2]);
408     printf("\t\t\t%8d: 6 .. 10 times\n", a_upDownP->downIncidents[3]);
409     printf("\t\t\t%8d: 10 .. 50 times\n", a_upDownP->downIncidents[4]);
410     printf("\t\t\t%8d: > 50 times\n", a_upDownP->downIncidents[5]);
411
412 }                               /*Print_cm_UpDownStats */
413
414
415 /*------------------------------------------------------------------------
416  * Print_cm_OverallPerfInfo
417  *
418  * Description:
419  *      Print out overall performance numbers.
420  *
421  * Arguments:
422  *      a_ovP : Ptr to the overall performance numbers.
423  *
424  *------------------------------------------------------------------------*/
425
426 void
427 Print_cm_OverallPerfInfo(a_ovP)
428      struct afs_stats_CMPerf *a_ovP;
429
430 {                               /*Print_cm_OverallPerfInfo */
431
432     printf("\t%10d numPerfCalls\n", a_ovP->numPerfCalls);
433
434     printf("\t%10d epoch\n", a_ovP->epoch);
435     printf("\t%10d numCellsVisible\n", a_ovP->numCellsVisible);
436     printf("\t%10d numCellsContacted\n", a_ovP->numCellsContacted);
437     printf("\t%10d dlocalAccesses\n", a_ovP->dlocalAccesses);
438     printf("\t%10d vlocalAccesses\n", a_ovP->vlocalAccesses);
439     printf("\t%10d dremoteAccesses\n", a_ovP->dremoteAccesses);
440     printf("\t%10d vremoteAccesses\n", a_ovP->vremoteAccesses);
441     printf("\t%10d cacheNumEntries\n", a_ovP->cacheNumEntries);
442     printf("\t%10d cacheBlocksTotal\n", a_ovP->cacheBlocksTotal);
443     printf("\t%10d cacheBlocksInUse\n", a_ovP->cacheBlocksInUse);
444     printf("\t%10d cacheBlocksOrig\n", a_ovP->cacheBlocksOrig);
445     printf("\t%10d cacheMaxDirtyChunks\n", a_ovP->cacheMaxDirtyChunks);
446     printf("\t%10d cacheCurrDirtyChunks\n", a_ovP->cacheCurrDirtyChunks);
447     printf("\t%10d dcacheHits\n", a_ovP->dcacheHits);
448     printf("\t%10d vcacheHits\n", a_ovP->vcacheHits);
449     printf("\t%10d dcacheMisses\n", a_ovP->dcacheMisses);
450     printf("\t%10d vcacheMisses\n", a_ovP->vcacheMisses);
451     printf("\t%10d cacheFilesReused\n", a_ovP->cacheFilesReused);
452     printf("\t%10d vcacheXAllocs\n", a_ovP->vcacheXAllocs);
453
454     printf("\t%10d bufAlloced\n", a_ovP->bufAlloced);
455     printf("\t%10d bufHits\n", a_ovP->bufHits);
456     printf("\t%10d bufMisses\n", a_ovP->bufMisses);
457     printf("\t%10d bufFlushDirty\n", a_ovP->bufFlushDirty);
458
459     printf("\t%10d LargeBlocksActive\n", a_ovP->LargeBlocksActive);
460     printf("\t%10d LargeBlocksAlloced\n", a_ovP->LargeBlocksAlloced);
461     printf("\t%10d SmallBlocksActive\n", a_ovP->SmallBlocksActive);
462     printf("\t%10d SmallBlocksAlloced\n", a_ovP->SmallBlocksAlloced);
463     printf("\t%10d OutStandingMemUsage\n", a_ovP->OutStandingMemUsage);
464     printf("\t%10d OutStandingAllocs\n", a_ovP->OutStandingAllocs);
465     printf("\t%10d CallBackAlloced\n", a_ovP->CallBackAlloced);
466     printf("\t%10d CallBackFlushes\n", a_ovP->CallBackFlushes);
467
468     printf("\t%10d srvRecords\n", a_ovP->srvRecords);
469     printf("\t%10d srvNumBuckets\n", a_ovP->srvNumBuckets);
470     printf("\t%10d srvMaxChainLength\n", a_ovP->srvMaxChainLength);
471     printf("\t%10d srvMaxChainLengthHWM\n", a_ovP->srvMaxChainLengthHWM);
472     printf("\t%10d srvRecordsHWM\n", a_ovP->srvRecordsHWM);
473
474     printf("\t%10d sysName_ID\n", a_ovP->sysName_ID);
475
476     printf("\tFile Server up/downtimes, same cell:\n");
477     Print_cm_UpDownStats(&(a_ovP->fs_UpDown[0]));
478
479     printf("\tFile Server up/downtimes, diff cell:\n");
480     Print_cm_UpDownStats(&(a_ovP->fs_UpDown[1]));
481
482     printf("\tVL Server up/downtimes, same cell:\n");
483     Print_cm_UpDownStats(&(a_ovP->vl_UpDown[0]));
484
485     printf("\tVL Server up/downtimes, diff cell:\n");
486     Print_cm_UpDownStats(&(a_ovP->vl_UpDown[1]));
487
488 }                               /*Print_cm_OverallPerfInfo */
489
490
491
492 /*------------------------------------------------------------------------
493  * Print_cm_OpTiming
494  *
495  * Description:
496  *      Print out the contents of an FS RPC op timing structure.
497  *
498  * Arguments:
499  *      a_opIdx   : Index of the AFS operation we're printing number on.
500  *      a_opNames : Ptr to table of operaton names.
501  *      a_opTimeP : Ptr to the op timing structure to print.
502  *
503  *------------------------------------------------------------------------*/
504
505 void
506 Print_cm_OpTiming(a_opIdx, a_opNames, a_opTimeP)
507      int a_opIdx;
508      char *a_opNames[];
509      struct afs_stats_opTimingData *a_opTimeP;
510
511 {                               /*Print_cm_OpTiming */
512
513     printf("%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
514            a_opNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses,
515            a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
516            a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
517            a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
518
519 }                               /*Print_cm_OpTiming */
520
521
522 /*------------------------------------------------------------------------
523  * Print_cm_XferTiming
524  *
525  * Description:
526  *      Print out the contents of a data transfer structure.
527  *
528  * Arguments:
529  *      a_opIdx : Index of the AFS operation we're printing number on.
530  *      a_xferP : Ptr to the data transfer structure to print.
531  *
532  *------------------------------------------------------------------------*/
533
534 void
535 Print_cm_XferTiming(a_opIdx, a_opNames, a_xferP)
536      int a_opIdx;
537      char *a_opNames[];
538      struct afs_stats_xferData *a_xferP;
539
540 {                               /*Print_cm_XferTiming */
541
542     printf
543         ("%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
544          a_opNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses,
545          a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
546          a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
547          a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
548     printf("\t[bytes: sum=%d, min=%d, max=%d]\n", a_xferP->sumBytes,
549            a_xferP->minBytes, a_xferP->maxBytes);
550     printf
551         ("\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d, 6: %d, 7: %d, 8: %d]\n",
552          a_xferP->count[0], a_xferP->count[1], a_xferP->count[2],
553          a_xferP->count[3], a_xferP->count[4], a_xferP->count[5],
554          a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]);
555
556 }                               /*Print_cm_XferTiming */
557
558
559 /*------------------------------------------------------------------------
560  * Print_cm_ErrInfo
561  *
562  * Description:
563  *      Print out the contents of an FS RPC error info structure.
564  *
565  * Arguments:
566  *      a_opIdx   : Index of the AFS operation we're printing.
567  *      a_opNames : Ptr to table of operation names.
568  *      a_opErrP  : Ptr to the op timing structure to print.
569  *
570  *------------------------------------------------------------------------*/
571
572 void
573 Print_cm_ErrInfo(a_opIdx, a_opNames, a_opErrP)
574      int a_opIdx;
575      char *a_opNames[];
576      struct afs_stats_RPCErrors *a_opErrP;
577
578 {                               /*Print_cm_ErrInfo */
579
580     printf
581         ("%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n",
582          a_opNames[a_opIdx], a_opErrP->err_Server, a_opErrP->err_Network,
583          a_opErrP->err_Protection, a_opErrP->err_Volume,
584          a_opErrP->err_VolumeBusies, a_opErrP->err_Other);
585
586 }                               /*Print_cm_ErrInfo */
587
588
589 /*------------------------------------------------------------------------
590  * Print_cm_RPCPerfInfo
591  *
592  * Description:
593  *      Print out a set of RPC performance numbers.
594  *
595  * Arguments:
596  *      a_rpcP : Ptr to RPC perf numbers to print.
597  *
598  *------------------------------------------------------------------------*/
599
600 void
601 Print_cm_RPCPerfInfo(a_rpcP)
602      struct afs_stats_RPCOpInfo *a_rpcP;
603
604 {                               /*Print_cm_RPCPerfInfo */
605
606     int currIdx;                /*Loop variable */
607
608     /*
609      * Print the contents of each of the opcode-related arrays.
610      */
611     printf("FS Operation Timings:\n---------------------\n");
612     for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
613         Print_cm_OpTiming(currIdx, fsOpNames, &(a_rpcP->fsRPCTimes[currIdx]));
614
615     printf("\nError Info:\n-----------\n");
616     for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
617         Print_cm_ErrInfo(currIdx, fsOpNames, &(a_rpcP->fsRPCErrors[currIdx]));
618
619     printf("\nTransfer timings:\n-----------------\n");
620     for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++)
621         Print_cm_XferTiming(currIdx, xferOpNames,
622                             &(a_rpcP->fsXferTimes[currIdx]));
623
624     printf("\nCM Operation Timings:\n---------------------\n");
625     for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++)
626         Print_cm_OpTiming(currIdx, cmOpNames, &(a_rpcP->cmRPCTimes[currIdx]));
627
628 }                               /*Print_cm_RPCPerfInfo */
629
630
631 /*------------------------------------------------------------------------
632  * Print_cm_FullPerfInfo
633  *
634  * Description:
635  *      Print out a set of full performance numbers.
636  *
637  * Arguments:
638  *      None.
639  *
640  *------------------------------------------------------------------------*/
641
642 void
643 Print_cm_FullPerfInfo(a_fullP)
644      struct afs_stats_CMFullPerf *a_fullP;
645 {                               /*Print_cm_FullPerfInfo */
646
647     static char rn[] = "Print_cm_FullPerfInfo"; /* routine name */
648     struct afs_stats_AuthentInfo *authentP;     /*Ptr to authentication stats */
649     struct afs_stats_AccessInfo *accessinfP;    /*Ptr to access stats */
650     struct afs_stats_AuthorInfo *authorP;       /*Ptr to authorship stats */
651     static long fullPerfLongs = (sizeof(struct afs_stats_CMFullPerf) >> 2);     /*Correct #longs */
652     long numLongs;              /*# longs actually received */
653     struct afs_stats_CMFullPerf *fullP;
654
655     fullP = a_fullP;
656
657     /*
658      * Print the overall numbers first, followed by all of the RPC numbers,
659      * then each of the other groupings.
660      */
661     printf("Overall Performance Info:\n-------------------------\n");
662     Print_cm_OverallPerfInfo(&(fullP->perf));
663     printf("\n");
664     Print_cm_RPCPerfInfo(&(fullP->rpc));
665
666     authentP = &(fullP->authent);
667     printf("\nAuthentication info:\n--------------------\n");
668     printf
669         ("\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n",
670          authentP->curr_PAGs, authentP->curr_Records,
671          authentP->curr_AuthRecords, authentP->curr_UnauthRecords,
672          authentP->curr_MaxRecordsInPAG, authentP->curr_LongestChain);
673     printf("\t%d PAG creations, %d tkt updates\n", authentP->PAGCreations,
674            authentP->TicketUpdates);
675     printf("\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n",
676            authentP->HWM_PAGs, authentP->HWM_Records,
677            authentP->HWM_MaxRecordsInPAG, authentP->HWM_LongestChain);
678
679     accessinfP = &(fullP->accessinf);
680     printf("\n[Un]replicated accesses:\n------------------------\n");
681     printf
682         ("\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n",
683          accessinfP->unreplicatedRefs, accessinfP->replicatedRefs,
684          accessinfP->numReplicasAccessed, accessinfP->maxReplicasPerRef,
685          accessinfP->refFirstReplicaOK);
686
687     /* There really isn't any authorship info
688      * authorP = &(fullP->author); */
689
690 }                               /*Print_cm_FullPerfInfo */
691
692
693
694
695 main(argc, argv)
696      int argc;
697      char *argv[];
698 {
699     static char rn[] = "main";
700     FILE *inFD;
701     char *line, *charPtr;
702     long *longs, *longPtr;
703     int block_size, exitcode, i, numLongs, counter;
704     char day[5], month[5], date[5], time[10], year[5], hostname[80],
705         hosttype[5];
706     struct afs_stats_CMFullPerf *cmPerfP;
707     struct fs_stats_FullPerfStats *fsPerfP;
708     char tmpstr[20];
709
710
711     if ((argc < 2) || (strcasecmp(argv[1], "-h") == 0)
712         || (strcasecmp(argv[1], "-help") == 0)
713         || (strcasecmp(argv[1], "help") == 0)) {
714         fprintf(stderr, "\nUsage: %s  <file>\n", argv[0]);
715         fprintf(stderr,
716                 "\twhere <file> is the output generated by AFSMonitor\n\n");
717         exit(1);
718     }
719
720
721
722     inFD = fopen(argv[1], "r");
723     if (inFD == (FILE *) 0) {
724         fprintf(stderr, "\n[ %s ] Unable to open input file %s. \n", rn,
725                 argv[1]);
726         exit(5);
727     }
728
729     block_size = XSTAT_CM_FULLPERF_RESULTS_LEN * sizeof(long);
730
731     /* Malloc two blocks of data, one for reading each line from the data file
732      * and the other for coverting data to longs */
733
734     if ((line = malloc(block_size + 256)) == (char *)NULL) {
735         fprintf(stderr, "[ %s ] malloc %d bytes failed\n", rn,
736                 block_size + 256);
737         exit(10);
738     }
739
740     if ((longs = malloc(block_size)) == (long *)NULL) {
741         fprintf(stderr, "[ %s ] malloc %d bytes failed\n", rn, block_size);
742         exit(20);
743     }
744
745     /* Parse the data file */
746     while (1) {
747         if (fgets(line, block_size, inFD) == NULL) {
748             exitcode = 0;
749             goto FINISH;
750         }
751         if (strlen(line) < 5)
752             continue;
753
754         /* Parse the date, hostname, and hosttype (FS or CM) */
755
756         charPtr = line;
757         sscanf(charPtr, "%s %s %s %s %s %s %s", day, month, date, time, year,
758                hostname, hosttype);
759         charPtr +=
760             strlen(day) + strlen(month) + strlen(date) + strlen(time) +
761             strlen(year) + strlen(hostname) + strlen(hosttype) + 8;
762
763         printf("\n\n%s %s %s %s %s %s %s \n\n", day, month, date, time, year,
764                hostname, hosttype);
765
766         /* Check the first datum. If it is -1 the probe had failed */
767
768         sscanf(charPtr, "%s", tmpstr);
769         if (atoi(tmpstr) == -1) {
770             printf("Probe failed, no data to process.\n");
771             continue;
772         }
773
774         /* Convert the data to longs */
775
776         if (strcmp(hosttype, "FS") == 0)
777             numLongs = XSTAT_FS_FULLPERF_RESULTS_LEN;
778         else if (strcmp(hosttype, "CM") == 0)
779             numLongs = XSTAT_CM_FULLPERF_RESULTS_LEN;
780         else {
781             fprintf(stderr, "Cannot determine hosttype %s\n", hosttype);
782             fprintf(stderr, "Skipping this entry\n");
783             continue;
784         }
785
786         longPtr = longs;
787         counter = 0;
788         for (i = 0; i < numLongs; i++) {
789             sscanf(charPtr, "%ld", longPtr);
790             sscanf(charPtr, "%s", tmpstr);
791             longPtr++;
792             charPtr += strlen(tmpstr) + 1;
793             counter++;
794         }
795
796         /* Verify that we read the correct number of longs and print them */
797
798         if (strcmp(hosttype, "CM") == 0) {
799             if (counter == XSTAT_CM_FULLPERF_RESULTS_LEN)
800                 Print_cm_FullPerfInfo((struct afs_stats_CMFullPerf *)longs);
801             else
802                 fprintf(stderr,
803                         "Data size mismatch error. Expected %d longs, found %d longs\n",
804                         numLongs, counter);
805         } else {
806             if (counter == XSTAT_FS_FULLPERF_RESULTS_LEN) {
807                 fsPerfP = (struct fs_stats_FullPerfStats *)longs;
808                 Print_fs_OverallPerfInfo(&(fsPerfP->overall));
809                 Print_fs_DetailedPerfInfo(&(fsPerfP->det));
810             } else
811                 fprintf(stderr,
812                         "Data size mismatch error. Expected %d longs, found %d longs\n",
813                         numLongs, counter);
814
815         }
816
817         printf
818             ("\n-------------------------------------------------------------------------\n");
819     }                           /* while */
820
821     exitcode = 0;
822
823   FINISH:
824     fclose(inFD);
825     free(line);
826     free(longs);
827 }