2 * Copyright 2000, International Business Machines Corporation and others.
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
11 * Module: afsmon-output.c
12 * Outputs the xstat probe results to a file
13 * Most of this code is taken from xstat_fs_test.c and
16 *-------------------------------------------------------------------------*/
20 #include <afs/param.h>
21 #include <afs/xstat_fs.h>
22 #include <afs/xstat_cm.h>
26 /* Extern Variables */
27 extern int afsmon_debug; /* debugging on ? */
28 extern FILE *debugFD; /* debug file FD */
29 extern char errMsg[256]; /* error message buffer */
31 extern int afsmon_Exit(); /* exit routine */
33 static FILE *fs_outFD; /* fs output file descriptor */
34 static FILE *cm_outFD; /* cm output file descriptor */
36 /* structures used by FS & CM stats print routines */
38 static char *fsOpNames[] = {
69 static char *cmOpNames[] = {
79 static char *xferOpNames[] = {
84 /*________________________________________________________________________
86 *_______________________________________________________________________*/
88 /*------------------------------------------------------------------------
89 * Print_fs_OverallPerfInfo
92 * Print out overall performance numbers.
95 * a_ovP : Ptr to the overall performance numbers.
101 * Nothing interesting.
105 *------------------------------------------------------------------------*/
107 void Print_fs_OverallPerfInfo(a_ovP)
108 struct afs_PerfStats *a_ovP;
110 { /*Print_fs_OverallPerfInfo*/
112 fprintf(fs_outFD,"\t%10d numPerfCalls\n\n", a_ovP->numPerfCalls);
116 * Vnode cache section.
118 fprintf(fs_outFD,"\t%10d vcache_L_Entries\n", a_ovP->vcache_L_Entries);
119 fprintf(fs_outFD,"\t%10d vcache_L_Allocs\n", a_ovP->vcache_L_Allocs);
120 fprintf(fs_outFD,"\t%10d vcache_L_Gets\n", a_ovP->vcache_L_Gets);
121 fprintf(fs_outFD,"\t%10d vcache_L_Reads\n", a_ovP->vcache_L_Reads);
122 fprintf(fs_outFD,"\t%10d vcache_L_Writes\n\n",a_ovP->vcache_L_Writes);
124 fprintf(fs_outFD,"\t%10d vcache_S_Entries\n", a_ovP->vcache_S_Entries);
125 fprintf(fs_outFD,"\t%10d vcache_S_Allocs\n", a_ovP->vcache_S_Allocs);
126 fprintf(fs_outFD,"\t%10d vcache_S_Gets\n", a_ovP->vcache_S_Gets);
127 fprintf(fs_outFD,"\t%10d vcache_S_Reads\n", a_ovP->vcache_S_Reads);
128 fprintf(fs_outFD,"\t%10d vcache_S_Writes\n\n",a_ovP->vcache_S_Writes);
130 fprintf(fs_outFD,"\t%10d vcache_H_Entries\n", a_ovP->vcache_H_Entries);
131 fprintf(fs_outFD,"\t%10d vcache_H_Gets\n", a_ovP->vcache_H_Gets);
132 fprintf(fs_outFD,"\t%10d vcache_H_Replacements\n\n",a_ovP->vcache_H_Replacements);
135 * Directory package section.
137 fprintf(fs_outFD,"\t%10d dir_Buffers\n", a_ovP->dir_Buffers);
138 fprintf(fs_outFD,"\t%10d dir_Calls\n", a_ovP->dir_Calls);
139 fprintf(fs_outFD,"\t%10d dir_IOs\n\n", a_ovP->dir_IOs);
144 fprintf(fs_outFD,"\t%10d rx_packetRequests\n", a_ovP->rx_packetRequests);
145 fprintf(fs_outFD,"\t%10d rx_noPackets_RcvClass\n", a_ovP->rx_noPackets_RcvClass);
146 fprintf(fs_outFD,"\t%10d rx_noPackets_SendClass\n", a_ovP->rx_noPackets_SendClass);
147 fprintf(fs_outFD,"\t%10d rx_noPackets_SpecialClass\n", a_ovP->rx_noPackets_SpecialClass);
148 fprintf(fs_outFD,"\t%10d rx_socketGreedy\n", a_ovP->rx_socketGreedy);
149 fprintf(fs_outFD,"\t%10d rx_bogusPacketOnRead\n", a_ovP->rx_bogusPacketOnRead);
150 fprintf(fs_outFD,"\t%10d rx_bogusHost\n", a_ovP->rx_bogusHost);
151 fprintf(fs_outFD,"\t%10d rx_noPacketOnRead\n", a_ovP->rx_noPacketOnRead);
152 fprintf(fs_outFD,"\t%10d rx_noPacketBuffersOnRead\n", a_ovP->rx_noPacketBuffersOnRead);
153 fprintf(fs_outFD,"\t%10d rx_selects\n", a_ovP->rx_selects);
154 fprintf(fs_outFD,"\t%10d rx_sendSelects\n", a_ovP->rx_sendSelects);
155 fprintf(fs_outFD,"\t%10d rx_packetsRead_RcvClass\n", a_ovP->rx_packetsRead_RcvClass);
156 fprintf(fs_outFD,"\t%10d rx_packetsRead_SendClass\n", a_ovP->rx_packetsRead_SendClass);
157 fprintf(fs_outFD,"\t%10d rx_packetsRead_SpecialClass\n", a_ovP->rx_packetsRead_SpecialClass);
158 fprintf(fs_outFD,"\t%10d rx_dataPacketsRead\n", a_ovP->rx_dataPacketsRead);
159 fprintf(fs_outFD,"\t%10d rx_ackPacketsRead\n", a_ovP->rx_ackPacketsRead);
160 fprintf(fs_outFD,"\t%10d rx_dupPacketsRead\n", a_ovP->rx_dupPacketsRead);
161 fprintf(fs_outFD,"\t%10d rx_spuriousPacketsRead\n", a_ovP->rx_spuriousPacketsRead);
162 fprintf(fs_outFD,"\t%10d rx_packetsSent_RcvClass\n", a_ovP->rx_packetsSent_RcvClass);
163 fprintf(fs_outFD,"\t%10d rx_packetsSent_SendClass\n", a_ovP->rx_packetsSent_SendClass);
164 fprintf(fs_outFD,"\t%10d rx_packetsSent_SpecialClass\n", a_ovP->rx_packetsSent_SpecialClass);
165 fprintf(fs_outFD,"\t%10d rx_ackPacketsSent\n", a_ovP->rx_ackPacketsSent);
166 fprintf(fs_outFD,"\t%10d rx_pingPacketsSent\n", a_ovP->rx_pingPacketsSent);
167 fprintf(fs_outFD,"\t%10d rx_abortPacketsSent\n",a_ovP->rx_abortPacketsSent);
168 fprintf(fs_outFD,"\t%10d rx_busyPacketsSent\n", a_ovP->rx_busyPacketsSent);
169 fprintf(fs_outFD,"\t%10d rx_dataPacketsSent\n", a_ovP->rx_dataPacketsSent);
170 fprintf(fs_outFD,"\t%10d rx_dataPacketsReSent\n", a_ovP->rx_dataPacketsReSent);
171 fprintf(fs_outFD,"\t%10d rx_dataPacketsPushed\n", a_ovP->rx_dataPacketsPushed);
172 fprintf(fs_outFD,"\t%10d rx_ignoreAckedPacket\n", a_ovP->rx_ignoreAckedPacket);
173 fprintf(fs_outFD,"\t%10d rx_totalRtt_Sec\n", a_ovP->rx_totalRtt_Sec);
174 fprintf(fs_outFD,"\t%10d rx_totalRtt_Usec\n", a_ovP->rx_totalRtt_Usec);
175 fprintf(fs_outFD,"\t%10d rx_minRtt_Sec\n", a_ovP->rx_minRtt_Sec);
176 fprintf(fs_outFD,"\t%10d rx_minRtt_Usec\n", a_ovP->rx_minRtt_Usec);
177 fprintf(fs_outFD,"\t%10d rx_maxRtt_Sec\n", a_ovP->rx_maxRtt_Sec);
178 fprintf(fs_outFD,"\t%10d rx_maxRtt_Usec\n", a_ovP->rx_maxRtt_Usec);
179 fprintf(fs_outFD,"\t%10d rx_nRttSamples\n", a_ovP->rx_nRttSamples);
180 fprintf(fs_outFD,"\t%10d rx_nServerConns\n", a_ovP->rx_nServerConns);
181 fprintf(fs_outFD,"\t%10d rx_nClientConns\n", a_ovP->rx_nClientConns);
182 fprintf(fs_outFD,"\t%10d rx_nPeerStructs\n", a_ovP->rx_nPeerStructs);
183 fprintf(fs_outFD,"\t%10d rx_nCallStructs\n", a_ovP->rx_nCallStructs);
184 fprintf(fs_outFD,"\t%10d rx_nFreeCallStructs\n\n", a_ovP->rx_nFreeCallStructs);
187 * Host module fields.
189 fprintf(fs_outFD,"\t%10d host_NumHostEntries\n", a_ovP->host_NumHostEntries);
190 fprintf(fs_outFD,"\t%10d host_HostBlocks\n", a_ovP->host_HostBlocks);
191 fprintf(fs_outFD,"\t%10d host_NonDeletedHosts\n", a_ovP->host_NonDeletedHosts);
192 fprintf(fs_outFD,"\t%10d host_HostsInSameNetOrSubnet\n", a_ovP->host_HostsInSameNetOrSubnet);
193 fprintf(fs_outFD,"\t%10d host_HostsInDiffSubnet\n", a_ovP->host_HostsInDiffSubnet);
194 fprintf(fs_outFD,"\t%10d host_HostsInDiffNetwork\n",a_ovP->host_HostsInDiffNetwork);
195 fprintf(fs_outFD,"\t%10d host_NumClients\n", a_ovP->host_NumClients);
196 fprintf(fs_outFD,"\t%10d host_ClientBlocks\n\n", a_ovP->host_ClientBlocks);
198 } /*Print_fs_OverallPerfInfo*/
201 /*------------------------------------------------------------------------
205 * Print out the contents of an RPC op timing structure.
208 * a_opIdx : Index of the AFS operation we're printing number on.
209 * a_opTimeP : Ptr to the op timing structure to print.
215 * Nothing interesting.
219 *------------------------------------------------------------------------*/
221 void Print_fs_OpTiming(a_opIdx, a_opTimeP)
223 struct fs_stats_opTimingData *a_opTimeP;
225 { /*Print_fs_OpTiming*/
227 fprintf(fs_outFD,"%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
229 a_opTimeP->numOps, a_opTimeP->numSuccesses,
230 a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
231 a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
232 a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
234 } /*Print_fs_OpTiming*/
237 /*------------------------------------------------------------------------
238 * Print_fs_XferTiming
241 * Print out the contents of a data transfer structure.
244 * a_opIdx : Index of the AFS operation we're printing number on.
245 * a_xferP : Ptr to the data transfer structure to print.
251 * Nothing interesting.
255 *------------------------------------------------------------------------*/
257 void Print_fs_XferTiming(a_opIdx, a_xferP)
259 struct fs_stats_xferData *a_xferP;
261 { /*Print_fs_XferTiming*/
263 fprintf(fs_outFD,"%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
264 xferOpNames[a_opIdx],
265 a_xferP->numXfers, a_xferP->numSuccesses,
266 a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
267 a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
268 a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
269 fprintf(fs_outFD,"\t[bytes: sum=%d, min=%d, max=%d]\n",
270 a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
271 fprintf(fs_outFD,"\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
282 } /*Print_fs_XferTiming*/
285 /*------------------------------------------------------------------------
286 * Print_fs_DetailedPerfInfo
289 * Print out a set of detailed performance numbers.
292 * a_detP : Ptr to detailed perf numbers to print.
298 * Nothing interesting.
302 *------------------------------------------------------------------------*/
304 void Print_fs_DetailedPerfInfo(a_detP)
305 struct fs_stats_DetailedStats *a_detP;
307 { /*Print_fs_DetailedPerfInfo*/
309 int currIdx; /*Loop variable*/
311 fprintf(fs_outFD,"\t%10d epoch\n", a_detP->epoch);
313 for (currIdx = 0; currIdx < FS_STATS_NUM_RPC_OPS; currIdx++)
314 Print_fs_OpTiming(currIdx, &(a_detP->rpcOpTimes[currIdx]));
316 for (currIdx = 0; currIdx < FS_STATS_NUM_XFER_OPS; currIdx++)
317 Print_fs_XferTiming(currIdx, &(a_detP->xferOpTimes[currIdx]));
319 } /*Print_fs_DetailedPerfInfo*/
322 /*------------------------------------------------------------------------
323 * Print_fs_FullPerfInfo
326 * Print out the AFS_XSTATSCOLL_FULL_PERF_INFO collection we just
336 * All the info we need is nestled into xstat_fs_Results.
340 *------------------------------------------------------------------------*/
342 void Print_fs_FullPerfInfo(a_fs_Results)
343 struct xstat_fs_ProbeResults *a_fs_Results; /* ptr to fs results */
344 { /*Print_fs_FullPerfInfo*/
346 static char rn[] = "Print_fs_FullPerfInfo"; /*Routine name*/
347 static afs_int32 fullPerfLongs =
348 (sizeof(struct fs_stats_FullPerfStats) >> 2); /*Correct # longs to rcv*/
349 afs_int32 numLongs; /*# longwords received*/
350 struct fs_stats_FullPerfStats *fullPerfP; /*Ptr to full perf stats*/
351 char *printableTime; /*Ptr to printable time string*/
354 numLongs = a_fs_Results->data.AFS_CollData_len;
355 if (numLongs != fullPerfLongs) {
356 fprintf(fs_outFD," ** Data size mismatch in full performance collection!\n");
357 fprintf(fs_outFD," ** Expecting %d, got %d\n", fullPerfLongs, numLongs);
361 printableTime = ctime((time_t *)&(a_fs_Results->probeTime));
362 printableTime[strlen(printableTime)-1] = '\0';
363 fullPerfP = (struct fs_stats_FullPerfStats *)
364 (a_fs_Results->data.AFS_CollData_val);
366 fprintf(fs_outFD,"AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n",
367 a_fs_Results->collectionNumber,
368 a_fs_Results->connP->hostName,
369 a_fs_Results->probeNum,
372 Print_fs_OverallPerfInfo(&(fullPerfP->overall));
373 Print_fs_DetailedPerfInfo(&(fullPerfP->det));
375 } /*Print_fs_FullPerfInfo*/
378 /*------------------------------------------------------------------------
382 * Prints the contents of xstat_fs_Results to an output file. The
383 * output is either in a compact (longs only) format or a detailed
384 * format giving the names of each of the datums. Output is appended.
387 * Name of output file.
388 * Flag to indicate if detailed output is required.
394 * All the info we need is nestled into xstat_fs_Results.
398 *------------------------------------------------------------------------*/
400 afsmon_fsOutput(a_outfile, a_detOutput)
401 char *a_outfile; /* ptr to output file name */
402 int a_detOutput; /* detailed output ? */
405 static char rn[] = "afsmon_fsOutput"; /* routine name */
406 char *printTime; /* ptr to time string */
407 char *hostname; /* fileserner name */
408 afs_int32 numLongs; /* longwords in result */
409 afs_int32 *currLong; /* ptr to longwords in result */
413 fprintf(debugFD,"[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
414 rn, a_outfile, a_detOutput);
418 fs_outFD = fopen(a_outfile,"a");
419 if (fs_outFD == (FILE *)0) {
420 sprintf(errMsg,"[ %s ] failed to open output file %s",rn,a_outfile);
424 /* get the probe time and strip the \n at the end */
425 printTime = ctime((time_t *)&(xstat_fs_Results.probeTime));
426 printTime[strlen(printTime) - 1] = '\0';
427 hostname = xstat_fs_Results.connP->hostName;
429 /* print "time hostname FS" */
430 fprintf(fs_outFD,"\n%s %s FS ",printTime,hostname);
432 /* if probe failed print -1 and return */
433 if (xstat_fs_Results.probeOK) {
434 fprintf(fs_outFD,"-1\n");
439 /* print out the probe information as long words */
440 numLongs = xstat_fs_Results.data.AFS_CollData_len;
441 currLong = (afs_int32 *)(xstat_fs_Results.data.AFS_CollData_val);
443 for(i=0; i<numLongs; i++) {
444 fprintf(fs_outFD,"%d ",*currLong++);
446 fprintf(fs_outFD,"\n\n");
448 /* print detailed information */
450 Print_fs_FullPerfInfo(&xstat_fs_Results);
454 if ( fclose(fs_outFD))
456 fprintf(debugFD,"[ %s ] failed to close %s\n",rn,a_outfile);
463 /*___________________________________________________________________________
465 *__________________________________________________________________________*/
469 /*------------------------------------------------------------------------
470 * Print_cm_UpDownStats
473 * Print the up/downtime stats for the given class of server records
477 * a_upDownP : Ptr to the server up/down info.
483 * Nothing interesting.
487 *------------------------------------------------------------------------*/
489 void Print_cm_UpDownStats(a_upDownP)
490 struct afs_stats_SrvUpDownInfo *a_upDownP; /*Ptr to server up/down info*/
492 { /*Print_cm_UpDownStats*/
495 * First, print the simple values.
497 fprintf(cm_outFD,"\t\t%10d numTtlRecords\n", a_upDownP->numTtlRecords);
498 fprintf(cm_outFD,"\t\t%10d numUpRecords\n", a_upDownP->numUpRecords);
499 fprintf(cm_outFD,"\t\t%10d numDownRecords\n", a_upDownP->numDownRecords);
500 fprintf(cm_outFD,"\t\t%10d sumOfRecordAges\n", a_upDownP->sumOfRecordAges);
501 fprintf(cm_outFD,"\t\t%10d ageOfYoungestRecord\n", a_upDownP->ageOfYoungestRecord);
502 fprintf(cm_outFD,"\t\t%10d ageOfOldestRecord\n", a_upDownP->ageOfOldestRecord);
503 fprintf(cm_outFD,"\t\t%10d numDowntimeIncidents\n", a_upDownP->numDowntimeIncidents);
504 fprintf(cm_outFD,"\t\t%10d numRecordsNeverDown\n", a_upDownP->numRecordsNeverDown);
505 fprintf(cm_outFD,"\t\t%10d maxDowntimesInARecord\n", a_upDownP->maxDowntimesInARecord);
506 fprintf(cm_outFD,"\t\t%10d sumOfDowntimes\n", a_upDownP->sumOfDowntimes);
507 fprintf(cm_outFD,"\t\t%10d shortestDowntime\n", a_upDownP->shortestDowntime);
508 fprintf(cm_outFD,"\t\t%10d longestDowntime\n", a_upDownP->longestDowntime);
511 * Now, print the array values.
513 fprintf(cm_outFD,"\t\tDowntime duration distribution:\n");
514 fprintf(cm_outFD,"\t\t\t%8d: 0 min .. 10 min\n", a_upDownP->downDurations[0]);
515 fprintf(cm_outFD,"\t\t\t%8d: 10 min .. 30 min\n", a_upDownP->downDurations[1]);
516 fprintf(cm_outFD,"\t\t\t%8d: 30 min .. 1 hr\n", a_upDownP->downDurations[2]);
517 fprintf(cm_outFD,"\t\t\t%8d: 1 hr .. 2 hr\n", a_upDownP->downDurations[3]);
518 fprintf(cm_outFD,"\t\t\t%8d: 2 hr .. 4 hr\n", a_upDownP->downDurations[4]);
519 fprintf(cm_outFD,"\t\t\t%8d: 4 hr .. 8 hr\n", a_upDownP->downDurations[5]);
520 fprintf(cm_outFD,"\t\t\t%8d: > 8 hr\n", a_upDownP->downDurations[6]);
522 fprintf(cm_outFD,"\t\tDowntime incident distribution:\n");
523 fprintf(cm_outFD,"\t\t\t%8d: 0 times\n", a_upDownP->downIncidents[0]);
524 fprintf(cm_outFD,"\t\t\t%8d: 1 time\n", a_upDownP->downIncidents[1]);
525 fprintf(cm_outFD,"\t\t\t%8d: 2 .. 5 times\n", a_upDownP->downIncidents[2]);
526 fprintf(cm_outFD,"\t\t\t%8d: 6 .. 10 times\n", a_upDownP->downIncidents[3]);
527 fprintf(cm_outFD,"\t\t\t%8d: 10 .. 50 times\n", a_upDownP->downIncidents[4]);
528 fprintf(cm_outFD,"\t\t\t%8d: > 50 times\n", a_upDownP->downIncidents[5]);
530 } /*Print_cm_UpDownStats*/
533 /*------------------------------------------------------------------------
534 * Print_cm_OverallPerfInfo
537 * Print out overall performance numbers.
540 * a_ovP : Ptr to the overall performance numbers.
546 * All the info we need is nestled into xstat_cm_Results.
550 *------------------------------------------------------------------------*/
552 void Print_cm_OverallPerfInfo(a_ovP)
553 struct afs_stats_CMPerf *a_ovP;
555 { /*Print_cm_OverallPerfInfo*/
557 fprintf(cm_outFD,"\t%10d numPerfCalls\n", a_ovP->numPerfCalls);
559 fprintf(cm_outFD,"\t%10d epoch\n", a_ovP->epoch);
560 fprintf(cm_outFD,"\t%10d numCellsVisible\n", a_ovP->numCellsVisible);
561 fprintf(cm_outFD,"\t%10d numCellsContacted\n", a_ovP->numCellsContacted);
562 fprintf(cm_outFD,"\t%10d dlocalAccesses\n", a_ovP->dlocalAccesses);
563 fprintf(cm_outFD,"\t%10d vlocalAccesses\n", a_ovP->vlocalAccesses);
564 fprintf(cm_outFD,"\t%10d dremoteAccesses\n", a_ovP->dremoteAccesses);
565 fprintf(cm_outFD,"\t%10d vremoteAccesses\n", a_ovP->vremoteAccesses);
566 fprintf(cm_outFD,"\t%10d cacheNumEntries\n", a_ovP->cacheNumEntries);
567 fprintf(cm_outFD,"\t%10d cacheBlocksTotal\n", a_ovP->cacheBlocksTotal);
568 fprintf(cm_outFD,"\t%10d cacheBlocksInUse\n", a_ovP->cacheBlocksInUse);
569 fprintf(cm_outFD,"\t%10d cacheBlocksOrig\n", a_ovP->cacheBlocksOrig);
570 fprintf(cm_outFD,"\t%10d cacheMaxDirtyChunks\n",a_ovP->cacheMaxDirtyChunks);
571 fprintf(cm_outFD,"\t%10d cacheCurrDirtyChunks\n", a_ovP->cacheCurrDirtyChunks);
572 fprintf(cm_outFD,"\t%10d dcacheHits\n", a_ovP->dcacheHits);
573 fprintf(cm_outFD,"\t%10d vcacheHits\n", a_ovP->vcacheHits);
574 fprintf(cm_outFD,"\t%10d dcacheMisses\n", a_ovP->dcacheMisses);
575 fprintf(cm_outFD,"\t%10d vcacheMisses\n", a_ovP->vcacheMisses);
576 fprintf(cm_outFD,"\t%10d cacheFilesReused\n", a_ovP->cacheFilesReused);
577 fprintf(cm_outFD,"\t%10d vcacheXAllocs\n", a_ovP->vcacheXAllocs);
579 fprintf(cm_outFD,"\t%10d bufAlloced\n", a_ovP->bufAlloced);
580 fprintf(cm_outFD,"\t%10d bufHits\n", a_ovP->bufHits);
581 fprintf(cm_outFD,"\t%10d bufMisses\n", a_ovP->bufMisses);
582 fprintf(cm_outFD,"\t%10d bufFlushDirty\n", a_ovP->bufFlushDirty);
584 fprintf(cm_outFD,"\t%10d LargeBlocksActive\n", a_ovP->LargeBlocksActive);
585 fprintf(cm_outFD,"\t%10d LargeBlocksAlloced\n", a_ovP->LargeBlocksAlloced);
586 fprintf(cm_outFD,"\t%10d SmallBlocksActive\n", a_ovP->SmallBlocksActive);
587 fprintf(cm_outFD,"\t%10d SmallBlocksAlloced\n", a_ovP->SmallBlocksAlloced);
588 fprintf(cm_outFD,"\t%10d OutStandingMemUsage\n", a_ovP->OutStandingMemUsage);
589 fprintf(cm_outFD,"\t%10d OutStandingAllocs\n", a_ovP->OutStandingAllocs);
590 fprintf(cm_outFD,"\t%10d CallBackAlloced\n", a_ovP->CallBackAlloced);
591 fprintf(cm_outFD,"\t%10d CallBackFlushes\n", a_ovP->CallBackFlushes);
593 fprintf(cm_outFD,"\t%10d srvRecords\n", a_ovP->srvRecords);
594 fprintf(cm_outFD,"\t%10d srvNumBuckets\n", a_ovP->srvNumBuckets);
595 fprintf(cm_outFD,"\t%10d srvMaxChainLength\n", a_ovP->srvMaxChainLength);
596 fprintf(cm_outFD,"\t%10d srvMaxChainLengthHWM\n", a_ovP->srvMaxChainLengthHWM);
597 fprintf(cm_outFD,"\t%10d srvRecordsHWM\n", a_ovP->srvRecordsHWM);
599 fprintf(cm_outFD,"\t%10d sysName_ID\n", a_ovP->sysName_ID);
601 fprintf(cm_outFD,"\tFile Server up/downtimes, same cell:\n");
602 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[0]));
604 fprintf(cm_outFD,"\tFile Server up/downtimes, diff cell:\n");
605 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[1]));
607 fprintf(cm_outFD,"\tVL Server up/downtimes, same cell:\n");
608 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[0]));
610 fprintf(cm_outFD,"\tVL Server up/downtimes, diff cell:\n");
611 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[1]));
613 } /*Print_cm_OverallPerfInfo*/
616 /*------------------------------------------------------------------------
620 * Print out the AFSCB_XSTATSCOLL_PERF_INFO collection we just
630 * All the info we need is nestled into xstat_cm_Results.
634 *------------------------------------------------------------------------*/
636 void Print_cm_PerfInfo()
638 { /*Print_cm_PerfInfo*/
640 static char rn[] = "Print_cm_PerfInfo"; /*Routine name*/
641 static afs_int32 perfLongs =
642 (sizeof(struct afs_stats_CMPerf) >> 2); /*Correct # longs to rcv*/
643 afs_int32 numLongs; /*# longwords received*/
644 struct afs_stats_CMPerf *perfP; /*Ptr to performance stats*/
645 char *printableTime; /*Ptr to printable time string*/
647 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
648 if (numLongs != perfLongs) {
649 fprintf(cm_outFD," ** Data size mismatch in performance collection!\n");
650 fprintf(cm_outFD,"** Expecting %d, got %d\n", perfLongs, numLongs);
654 printableTime = ctime((time_t *)&(xstat_cm_Results.probeTime));
655 printableTime[strlen(printableTime)-1] = '\0';
656 perfP = (struct afs_stats_CMPerf *)
657 (xstat_cm_Results.data.AFSCB_CollData_val);
659 fprintf(cm_outFD,"AFSCB_XSTATSCOLL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
660 xstat_cm_Results.collectionNumber,
661 xstat_cm_Results.connP->hostName,
662 xstat_cm_Results.probeNum,
665 Print_cm_OverallPerfInfo(perfP);
667 } /*Print_cm_PerfInfo*/
670 /*------------------------------------------------------------------------
674 * Print out the contents of an FS RPC op timing structure.
677 * a_opIdx : Index of the AFS operation we're printing number on.
678 * a_opNames : Ptr to table of operaton names.
679 * a_opTimeP : Ptr to the op timing structure to print.
685 * Nothing interesting.
689 *------------------------------------------------------------------------*/
691 void Print_cm_OpTiming(a_opIdx, a_opNames, a_opTimeP)
694 struct afs_stats_opTimingData *a_opTimeP;
696 { /*Print_cm_OpTiming*/
698 fprintf(cm_outFD,"%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
700 a_opTimeP->numOps, a_opTimeP->numSuccesses,
701 a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
702 a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
703 a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
705 } /*Print_cm_OpTiming*/
708 /*------------------------------------------------------------------------
709 * Print_cm_XferTiming
712 * Print out the contents of a data transfer structure.
715 * a_opIdx : Index of the AFS operation we're printing number on.
716 * a_xferP : Ptr to the data transfer structure to print.
722 * Nothing interesting.
726 *------------------------------------------------------------------------*/
728 void Print_cm_XferTiming(a_opIdx, a_opNames, a_xferP)
731 struct afs_stats_xferData *a_xferP;
733 { /*Print_cm_XferTiming*/
735 fprintf(cm_outFD,"%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
737 a_xferP->numXfers, a_xferP->numSuccesses,
738 a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
739 a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
740 a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
741 fprintf(cm_outFD,"\t[bytes: sum=%d, min=%d, max=%d]\n",
742 a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
743 fprintf(cm_outFD,"\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
754 } /*Print_cm_XferTiming*/
757 /*------------------------------------------------------------------------
761 * Print out the contents of an FS RPC error info structure.
764 * a_opIdx : Index of the AFS operation we're printing.
765 * a_opNames : Ptr to table of operation names.
766 * a_opErrP : Ptr to the op timing structure to print.
772 * Nothing interesting.
776 *------------------------------------------------------------------------*/
778 void Print_cm_ErrInfo(a_opIdx, a_opNames, a_opErrP)
781 struct afs_stats_RPCErrors *a_opErrP;
783 { /*Print_cm_ErrInfo*/
785 fprintf(cm_outFD,"%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n",
787 a_opErrP->err_Server,
788 a_opErrP->err_Network,
789 a_opErrP->err_Protection,
790 a_opErrP->err_Volume,
791 a_opErrP->err_VolumeBusies,
792 a_opErrP->err_Other);
794 } /*Print_cm_ErrInfo*/
797 /*------------------------------------------------------------------------
798 * Print_cm_RPCPerfInfo
801 * Print out a set of RPC performance numbers.
804 * a_rpcP : Ptr to RPC perf numbers to print.
810 * Nothing interesting.
814 *------------------------------------------------------------------------*/
816 void Print_cm_RPCPerfInfo(a_rpcP)
817 struct afs_stats_RPCOpInfo *a_rpcP;
819 { /*Print_cm_RPCPerfInfo*/
821 int currIdx; /*Loop variable*/
824 * Print the contents of each of the opcode-related arrays.
826 fprintf(cm_outFD,"FS Operation Timings:\n---------------------\n");
827 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
828 Print_cm_OpTiming(currIdx, fsOpNames, &(a_rpcP->fsRPCTimes[currIdx]));
830 fprintf(cm_outFD,"\nError Info:\n-----------\n");
831 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
832 Print_cm_ErrInfo(currIdx, fsOpNames, &(a_rpcP->fsRPCErrors[currIdx]));
834 fprintf(cm_outFD,"\nTransfer timings:\n-----------------\n");
835 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++)
836 Print_cm_XferTiming(currIdx, xferOpNames, &(a_rpcP->fsXferTimes[currIdx]));
838 fprintf(cm_outFD,"\nCM Operation Timings:\n---------------------\n");
839 for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++)
840 Print_cm_OpTiming(currIdx, cmOpNames, &(a_rpcP->cmRPCTimes[currIdx]));
842 } /*Print_cm_RPCPerfInfo*/
845 /*------------------------------------------------------------------------
846 * Print_cm_FullPerfInfo
849 * Print out a set of full performance numbers.
858 * Nothing interesting.
862 *------------------------------------------------------------------------*/
864 void Print_cm_FullPerfInfo()
866 { /*Print_cm_FullPerfInfo*/
868 static char rn[] = "Print_cm_FullPerfInfo"; /* routine name */
869 struct afs_stats_AuthentInfo *authentP; /*Ptr to authentication stats*/
870 struct afs_stats_AccessInfo *accessinfP; /*Ptr to access stats*/
871 static afs_int32 fullPerfLongs =
872 (sizeof (struct afs_stats_CMFullPerf) >> 2); /*Correct #longs*/
873 afs_int32 numLongs; /*# longs actually received*/
874 struct afs_stats_CMFullPerf *fullP; /*Ptr to full perf info*/
876 char *printableTime; /*Ptr to printable time string*/
878 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
879 if (numLongs != fullPerfLongs) {
880 fprintf(cm_outFD," ** Data size mismatch in performance collection!\n");
881 fprintf(cm_outFD," ** Expecting %d, got %d\n",fullPerfLongs, numLongs);
885 printableTime = ctime((time_t *)&(xstat_cm_Results.probeTime));
886 printableTime[strlen(printableTime)-1] = '\0';
887 fullP = (struct afs_stats_CMFullPerf *)
888 (xstat_cm_Results.data.AFSCB_CollData_val);
890 fprintf(cm_outFD,"AFSCB_XSTATSCOLL_FULL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
891 xstat_cm_Results.collectionNumber,
892 xstat_cm_Results.connP->hostName,
893 xstat_cm_Results.probeNum,
897 * Print the overall numbers first, followed by all of the RPC numbers,
898 * then each of the other groupings.
900 fprintf(cm_outFD,"Overall Performance Info:\n-------------------------\n");
901 Print_cm_OverallPerfInfo(&(fullP->perf));
902 fprintf(cm_outFD,"\n");
903 Print_cm_RPCPerfInfo(&(fullP->rpc));
905 authentP = &(fullP->authent);
906 fprintf(cm_outFD,"\nAuthentication info:\n--------------------\n");
907 fprintf(cm_outFD,"\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n",
909 authentP->curr_Records,
910 authentP->curr_AuthRecords,
911 authentP->curr_UnauthRecords,
912 authentP->curr_MaxRecordsInPAG,
913 authentP->curr_LongestChain);
914 fprintf(cm_outFD,"\t%d PAG creations, %d tkt updates\n",
915 authentP->PAGCreations,
916 authentP->TicketUpdates);
917 fprintf(cm_outFD,"\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n",
919 authentP->HWM_Records,
920 authentP->HWM_MaxRecordsInPAG,
921 authentP->HWM_LongestChain);
923 accessinfP = &(fullP->accessinf);
924 fprintf(cm_outFD,"\n[Un]replicated accesses:\n------------------------\n");
925 fprintf(cm_outFD,"\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n",
926 accessinfP->unreplicatedRefs,
927 accessinfP->replicatedRefs,
928 accessinfP->numReplicasAccessed,
929 accessinfP->maxReplicasPerRef,
930 accessinfP->refFirstReplicaOK);
932 /* There really isn't any authorship info
933 authorP = &(fullP->author); */
935 } /*Print_cm_FullPerfInfo*/
937 /*------------------------------------------------------------------------
941 * Prints the contents of xstat_cm_Results to an output file. The
942 * output is either in a compact (longs only) format or a detailed
943 * format giving the names of each of the datums. Output is appended.
946 * Name of output file.
947 * Flag to indicate if detailed output is required.
953 * All the info we need is nestled into xstat_cm_Results.
957 *------------------------------------------------------------------------*/
959 afsmon_cmOutput(a_outfile, a_detOutput)
960 char *a_outfile; /* ptr to output file name */
961 int a_detOutput; /* detailed output ? */
964 static char rn[] = "afsmon_cmOutput"; /* routine name */
965 char *printTime; /* ptr to time string */
966 char *hostname; /* fileserner name */
967 afs_int32 numLongs; /* longwords in result */
968 afs_int32 *currLong; /* ptr to longwords in result */
972 fprintf(debugFD,"[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
973 rn, a_outfile, a_detOutput);
977 /* need to lock this file before writing */
978 cm_outFD = fopen(a_outfile,"a");
979 if (cm_outFD == (FILE *)0) {
980 sprintf(errMsg,"[ %s ] failed to open output file %s",rn,a_outfile);
984 /* get the probe time and strip the \n at the end */
985 printTime = ctime((time_t *)&(xstat_cm_Results.probeTime));
986 printTime[strlen(printTime) - 1] = '\0';
987 hostname = xstat_cm_Results.connP->hostName;
989 /* print "time hostname CM" prefix */
990 fprintf(cm_outFD,"\n%s %s CM ",printTime,hostname);
992 /* if probe failed print -1 and vanish */
993 if (xstat_cm_Results.probeOK) {
994 fprintf(cm_outFD,"-1\n");
999 /* print out the probe information as long words */
1000 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
1001 currLong = (afs_int32 *)(xstat_cm_Results.data.AFSCB_CollData_val);
1003 for(i=0; i<numLongs; i++) {
1004 fprintf(cm_outFD,"%d ",*currLong++);
1006 fprintf(cm_outFD,"\n\n");
1008 /* print out detailed statistics */
1010 Print_cm_FullPerfInfo();
1014 if ( fclose(cm_outFD))
1016 fprintf(debugFD,"[ %s ] failed to close %s\n",rn,a_outfile);