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 <afsconfig.h>
21 #include <afs/param.h>
33 #include <afs/xstat_fs.h>
34 #include <afs/xstat_cm.h>
38 /* Extern Variables */
39 extern int afsmon_debug; /* debugging on ? */
40 extern FILE *debugFD; /* debug file FD */
41 extern char errMsg[256]; /* error message buffer */
43 extern int afsmon_Exit(); /* exit routine */
45 static FILE *fs_outFD; /* fs output file descriptor */
46 static FILE *cm_outFD; /* cm output file descriptor */
48 /* structures used by FS & CM stats print routines */
50 static char *fsOpNames[] = {
81 static char *cmOpNames[] = {
91 static char *xferOpNames[] = {
96 /*________________________________________________________________________
98 *_______________________________________________________________________*/
100 /*------------------------------------------------------------------------
101 * Print_fs_OverallPerfInfo
104 * Print out overall performance numbers.
107 * a_ovP : Ptr to the overall performance numbers.
113 * Nothing interesting.
117 *------------------------------------------------------------------------*/
119 void Print_fs_OverallPerfInfo(a_ovP)
120 struct afs_PerfStats *a_ovP;
122 { /*Print_fs_OverallPerfInfo*/
124 fprintf(fs_outFD,"\t%10d numPerfCalls\n\n", a_ovP->numPerfCalls);
128 * Vnode cache section.
130 fprintf(fs_outFD,"\t%10d vcache_L_Entries\n", a_ovP->vcache_L_Entries);
131 fprintf(fs_outFD,"\t%10d vcache_L_Allocs\n", a_ovP->vcache_L_Allocs);
132 fprintf(fs_outFD,"\t%10d vcache_L_Gets\n", a_ovP->vcache_L_Gets);
133 fprintf(fs_outFD,"\t%10d vcache_L_Reads\n", a_ovP->vcache_L_Reads);
134 fprintf(fs_outFD,"\t%10d vcache_L_Writes\n\n",a_ovP->vcache_L_Writes);
136 fprintf(fs_outFD,"\t%10d vcache_S_Entries\n", a_ovP->vcache_S_Entries);
137 fprintf(fs_outFD,"\t%10d vcache_S_Allocs\n", a_ovP->vcache_S_Allocs);
138 fprintf(fs_outFD,"\t%10d vcache_S_Gets\n", a_ovP->vcache_S_Gets);
139 fprintf(fs_outFD,"\t%10d vcache_S_Reads\n", a_ovP->vcache_S_Reads);
140 fprintf(fs_outFD,"\t%10d vcache_S_Writes\n\n",a_ovP->vcache_S_Writes);
142 fprintf(fs_outFD,"\t%10d vcache_H_Entries\n", a_ovP->vcache_H_Entries);
143 fprintf(fs_outFD,"\t%10d vcache_H_Gets\n", a_ovP->vcache_H_Gets);
144 fprintf(fs_outFD,"\t%10d vcache_H_Replacements\n\n",a_ovP->vcache_H_Replacements);
147 * Directory package section.
149 fprintf(fs_outFD,"\t%10d dir_Buffers\n", a_ovP->dir_Buffers);
150 fprintf(fs_outFD,"\t%10d dir_Calls\n", a_ovP->dir_Calls);
151 fprintf(fs_outFD,"\t%10d dir_IOs\n\n", a_ovP->dir_IOs);
156 fprintf(fs_outFD,"\t%10d rx_packetRequests\n", a_ovP->rx_packetRequests);
157 fprintf(fs_outFD,"\t%10d rx_noPackets_RcvClass\n", a_ovP->rx_noPackets_RcvClass);
158 fprintf(fs_outFD,"\t%10d rx_noPackets_SendClass\n", a_ovP->rx_noPackets_SendClass);
159 fprintf(fs_outFD,"\t%10d rx_noPackets_SpecialClass\n", a_ovP->rx_noPackets_SpecialClass);
160 fprintf(fs_outFD,"\t%10d rx_socketGreedy\n", a_ovP->rx_socketGreedy);
161 fprintf(fs_outFD,"\t%10d rx_bogusPacketOnRead\n", a_ovP->rx_bogusPacketOnRead);
162 fprintf(fs_outFD,"\t%10d rx_bogusHost\n", a_ovP->rx_bogusHost);
163 fprintf(fs_outFD,"\t%10d rx_noPacketOnRead\n", a_ovP->rx_noPacketOnRead);
164 fprintf(fs_outFD,"\t%10d rx_noPacketBuffersOnRead\n", a_ovP->rx_noPacketBuffersOnRead);
165 fprintf(fs_outFD,"\t%10d rx_selects\n", a_ovP->rx_selects);
166 fprintf(fs_outFD,"\t%10d rx_sendSelects\n", a_ovP->rx_sendSelects);
167 fprintf(fs_outFD,"\t%10d rx_packetsRead_RcvClass\n", a_ovP->rx_packetsRead_RcvClass);
168 fprintf(fs_outFD,"\t%10d rx_packetsRead_SendClass\n", a_ovP->rx_packetsRead_SendClass);
169 fprintf(fs_outFD,"\t%10d rx_packetsRead_SpecialClass\n", a_ovP->rx_packetsRead_SpecialClass);
170 fprintf(fs_outFD,"\t%10d rx_dataPacketsRead\n", a_ovP->rx_dataPacketsRead);
171 fprintf(fs_outFD,"\t%10d rx_ackPacketsRead\n", a_ovP->rx_ackPacketsRead);
172 fprintf(fs_outFD,"\t%10d rx_dupPacketsRead\n", a_ovP->rx_dupPacketsRead);
173 fprintf(fs_outFD,"\t%10d rx_spuriousPacketsRead\n", a_ovP->rx_spuriousPacketsRead);
174 fprintf(fs_outFD,"\t%10d rx_packetsSent_RcvClass\n", a_ovP->rx_packetsSent_RcvClass);
175 fprintf(fs_outFD,"\t%10d rx_packetsSent_SendClass\n", a_ovP->rx_packetsSent_SendClass);
176 fprintf(fs_outFD,"\t%10d rx_packetsSent_SpecialClass\n", a_ovP->rx_packetsSent_SpecialClass);
177 fprintf(fs_outFD,"\t%10d rx_ackPacketsSent\n", a_ovP->rx_ackPacketsSent);
178 fprintf(fs_outFD,"\t%10d rx_pingPacketsSent\n", a_ovP->rx_pingPacketsSent);
179 fprintf(fs_outFD,"\t%10d rx_abortPacketsSent\n",a_ovP->rx_abortPacketsSent);
180 fprintf(fs_outFD,"\t%10d rx_busyPacketsSent\n", a_ovP->rx_busyPacketsSent);
181 fprintf(fs_outFD,"\t%10d rx_dataPacketsSent\n", a_ovP->rx_dataPacketsSent);
182 fprintf(fs_outFD,"\t%10d rx_dataPacketsReSent\n", a_ovP->rx_dataPacketsReSent);
183 fprintf(fs_outFD,"\t%10d rx_dataPacketsPushed\n", a_ovP->rx_dataPacketsPushed);
184 fprintf(fs_outFD,"\t%10d rx_ignoreAckedPacket\n", a_ovP->rx_ignoreAckedPacket);
185 fprintf(fs_outFD,"\t%10d rx_totalRtt_Sec\n", a_ovP->rx_totalRtt_Sec);
186 fprintf(fs_outFD,"\t%10d rx_totalRtt_Usec\n", a_ovP->rx_totalRtt_Usec);
187 fprintf(fs_outFD,"\t%10d rx_minRtt_Sec\n", a_ovP->rx_minRtt_Sec);
188 fprintf(fs_outFD,"\t%10d rx_minRtt_Usec\n", a_ovP->rx_minRtt_Usec);
189 fprintf(fs_outFD,"\t%10d rx_maxRtt_Sec\n", a_ovP->rx_maxRtt_Sec);
190 fprintf(fs_outFD,"\t%10d rx_maxRtt_Usec\n", a_ovP->rx_maxRtt_Usec);
191 fprintf(fs_outFD,"\t%10d rx_nRttSamples\n", a_ovP->rx_nRttSamples);
192 fprintf(fs_outFD,"\t%10d rx_nServerConns\n", a_ovP->rx_nServerConns);
193 fprintf(fs_outFD,"\t%10d rx_nClientConns\n", a_ovP->rx_nClientConns);
194 fprintf(fs_outFD,"\t%10d rx_nPeerStructs\n", a_ovP->rx_nPeerStructs);
195 fprintf(fs_outFD,"\t%10d rx_nCallStructs\n", a_ovP->rx_nCallStructs);
196 fprintf(fs_outFD,"\t%10d rx_nFreeCallStructs\n\n", a_ovP->rx_nFreeCallStructs);
199 * Host module fields.
201 fprintf(fs_outFD,"\t%10d host_NumHostEntries\n", a_ovP->host_NumHostEntries);
202 fprintf(fs_outFD,"\t%10d host_HostBlocks\n", a_ovP->host_HostBlocks);
203 fprintf(fs_outFD,"\t%10d host_NonDeletedHosts\n", a_ovP->host_NonDeletedHosts);
204 fprintf(fs_outFD,"\t%10d host_HostsInSameNetOrSubnet\n", a_ovP->host_HostsInSameNetOrSubnet);
205 fprintf(fs_outFD,"\t%10d host_HostsInDiffSubnet\n", a_ovP->host_HostsInDiffSubnet);
206 fprintf(fs_outFD,"\t%10d host_HostsInDiffNetwork\n",a_ovP->host_HostsInDiffNetwork);
207 fprintf(fs_outFD,"\t%10d host_NumClients\n", a_ovP->host_NumClients);
208 fprintf(fs_outFD,"\t%10d host_ClientBlocks\n\n", a_ovP->host_ClientBlocks);
210 } /*Print_fs_OverallPerfInfo*/
213 /*------------------------------------------------------------------------
217 * Print out the contents of an RPC op timing structure.
220 * a_opIdx : Index of the AFS operation we're printing number on.
221 * a_opTimeP : Ptr to the op timing structure to print.
227 * Nothing interesting.
231 *------------------------------------------------------------------------*/
233 void Print_fs_OpTiming(a_opIdx, a_opTimeP)
235 struct fs_stats_opTimingData *a_opTimeP;
237 { /*Print_fs_OpTiming*/
239 fprintf(fs_outFD,"%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
241 a_opTimeP->numOps, a_opTimeP->numSuccesses,
242 a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
243 a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
244 a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
246 } /*Print_fs_OpTiming*/
249 /*------------------------------------------------------------------------
250 * Print_fs_XferTiming
253 * Print out the contents of a data transfer structure.
256 * a_opIdx : Index of the AFS operation we're printing number on.
257 * a_xferP : Ptr to the data transfer structure to print.
263 * Nothing interesting.
267 *------------------------------------------------------------------------*/
269 void Print_fs_XferTiming(a_opIdx, a_xferP)
271 struct fs_stats_xferData *a_xferP;
273 { /*Print_fs_XferTiming*/
275 fprintf(fs_outFD,"%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
276 xferOpNames[a_opIdx],
277 a_xferP->numXfers, a_xferP->numSuccesses,
278 a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
279 a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
280 a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
281 fprintf(fs_outFD,"\t[bytes: sum=%d, min=%d, max=%d]\n",
282 a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
283 fprintf(fs_outFD,"\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
294 } /*Print_fs_XferTiming*/
297 /*------------------------------------------------------------------------
298 * Print_fs_DetailedPerfInfo
301 * Print out a set of detailed performance numbers.
304 * a_detP : Ptr to detailed perf numbers to print.
310 * Nothing interesting.
314 *------------------------------------------------------------------------*/
316 void Print_fs_DetailedPerfInfo(a_detP)
317 struct fs_stats_DetailedStats *a_detP;
319 { /*Print_fs_DetailedPerfInfo*/
321 int currIdx; /*Loop variable*/
323 fprintf(fs_outFD,"\t%10d epoch\n", a_detP->epoch);
325 for (currIdx = 0; currIdx < FS_STATS_NUM_RPC_OPS; currIdx++)
326 Print_fs_OpTiming(currIdx, &(a_detP->rpcOpTimes[currIdx]));
328 for (currIdx = 0; currIdx < FS_STATS_NUM_XFER_OPS; currIdx++)
329 Print_fs_XferTiming(currIdx, &(a_detP->xferOpTimes[currIdx]));
331 } /*Print_fs_DetailedPerfInfo*/
334 /*------------------------------------------------------------------------
335 * Print_fs_FullPerfInfo
338 * Print out the AFS_XSTATSCOLL_FULL_PERF_INFO collection we just
348 * All the info we need is nestled into xstat_fs_Results.
352 *------------------------------------------------------------------------*/
354 void Print_fs_FullPerfInfo(a_fs_Results)
355 struct xstat_fs_ProbeResults *a_fs_Results; /* ptr to fs results */
356 { /*Print_fs_FullPerfInfo*/
358 static char rn[] = "Print_fs_FullPerfInfo"; /*Routine name*/
359 static afs_int32 fullPerfLongs =
360 (sizeof(struct fs_stats_FullPerfStats) >> 2); /*Correct # longs to rcv*/
361 afs_int32 numLongs; /*# longwords received*/
362 struct fs_stats_FullPerfStats *fullPerfP; /*Ptr to full perf stats*/
363 char *printableTime; /*Ptr to printable time string*/
366 numLongs = a_fs_Results->data.AFS_CollData_len;
367 if (numLongs != fullPerfLongs) {
368 fprintf(fs_outFD," ** Data size mismatch in full performance collection!\n");
369 fprintf(fs_outFD," ** Expecting %d, got %d\n", fullPerfLongs, numLongs);
373 printableTime = ctime((time_t *)&(a_fs_Results->probeTime));
374 printableTime[strlen(printableTime)-1] = '\0';
375 fullPerfP = (struct fs_stats_FullPerfStats *)
376 (a_fs_Results->data.AFS_CollData_val);
378 fprintf(fs_outFD,"AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n",
379 a_fs_Results->collectionNumber,
380 a_fs_Results->connP->hostName,
381 a_fs_Results->probeNum,
384 Print_fs_OverallPerfInfo(&(fullPerfP->overall));
385 Print_fs_DetailedPerfInfo(&(fullPerfP->det));
387 } /*Print_fs_FullPerfInfo*/
390 /*------------------------------------------------------------------------
394 * Prints the contents of xstat_fs_Results to an output file. The
395 * output is either in a compact (longs only) format or a detailed
396 * format giving the names of each of the datums. Output is appended.
399 * Name of output file.
400 * Flag to indicate if detailed output is required.
406 * All the info we need is nestled into xstat_fs_Results.
410 *------------------------------------------------------------------------*/
412 afsmon_fsOutput(a_outfile, a_detOutput)
413 char *a_outfile; /* ptr to output file name */
414 int a_detOutput; /* detailed output ? */
417 static char rn[] = "afsmon_fsOutput"; /* routine name */
418 char *printTime; /* ptr to time string */
419 char *hostname; /* fileserner name */
420 afs_int32 numLongs; /* longwords in result */
421 afs_int32 *currLong; /* ptr to longwords in result */
425 fprintf(debugFD,"[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
426 rn, a_outfile, a_detOutput);
430 fs_outFD = fopen(a_outfile,"a");
431 if (fs_outFD == (FILE *)0) {
432 sprintf(errMsg,"[ %s ] failed to open output file %s",rn,a_outfile);
436 /* get the probe time and strip the \n at the end */
437 printTime = ctime((time_t *)&(xstat_fs_Results.probeTime));
438 printTime[strlen(printTime) - 1] = '\0';
439 hostname = xstat_fs_Results.connP->hostName;
441 /* print "time hostname FS" */
442 fprintf(fs_outFD,"\n%s %s FS ",printTime,hostname);
444 /* if probe failed print -1 and return */
445 if (xstat_fs_Results.probeOK) {
446 fprintf(fs_outFD,"-1\n");
451 /* print out the probe information as long words */
452 numLongs = xstat_fs_Results.data.AFS_CollData_len;
453 currLong = (afs_int32 *)(xstat_fs_Results.data.AFS_CollData_val);
455 for(i=0; i<numLongs; i++) {
456 fprintf(fs_outFD,"%d ",*currLong++);
458 fprintf(fs_outFD,"\n\n");
460 /* print detailed information */
462 Print_fs_FullPerfInfo(&xstat_fs_Results);
466 if ( fclose(fs_outFD))
468 fprintf(debugFD,"[ %s ] failed to close %s\n",rn,a_outfile);
475 /*___________________________________________________________________________
477 *__________________________________________________________________________*/
481 /*------------------------------------------------------------------------
482 * Print_cm_UpDownStats
485 * Print the up/downtime stats for the given class of server records
489 * a_upDownP : Ptr to the server up/down info.
495 * Nothing interesting.
499 *------------------------------------------------------------------------*/
501 void Print_cm_UpDownStats(a_upDownP)
502 struct afs_stats_SrvUpDownInfo *a_upDownP; /*Ptr to server up/down info*/
504 { /*Print_cm_UpDownStats*/
507 * First, print the simple values.
509 fprintf(cm_outFD,"\t\t%10d numTtlRecords\n", a_upDownP->numTtlRecords);
510 fprintf(cm_outFD,"\t\t%10d numUpRecords\n", a_upDownP->numUpRecords);
511 fprintf(cm_outFD,"\t\t%10d numDownRecords\n", a_upDownP->numDownRecords);
512 fprintf(cm_outFD,"\t\t%10d sumOfRecordAges\n", a_upDownP->sumOfRecordAges);
513 fprintf(cm_outFD,"\t\t%10d ageOfYoungestRecord\n", a_upDownP->ageOfYoungestRecord);
514 fprintf(cm_outFD,"\t\t%10d ageOfOldestRecord\n", a_upDownP->ageOfOldestRecord);
515 fprintf(cm_outFD,"\t\t%10d numDowntimeIncidents\n", a_upDownP->numDowntimeIncidents);
516 fprintf(cm_outFD,"\t\t%10d numRecordsNeverDown\n", a_upDownP->numRecordsNeverDown);
517 fprintf(cm_outFD,"\t\t%10d maxDowntimesInARecord\n", a_upDownP->maxDowntimesInARecord);
518 fprintf(cm_outFD,"\t\t%10d sumOfDowntimes\n", a_upDownP->sumOfDowntimes);
519 fprintf(cm_outFD,"\t\t%10d shortestDowntime\n", a_upDownP->shortestDowntime);
520 fprintf(cm_outFD,"\t\t%10d longestDowntime\n", a_upDownP->longestDowntime);
523 * Now, print the array values.
525 fprintf(cm_outFD,"\t\tDowntime duration distribution:\n");
526 fprintf(cm_outFD,"\t\t\t%8d: 0 min .. 10 min\n", a_upDownP->downDurations[0]);
527 fprintf(cm_outFD,"\t\t\t%8d: 10 min .. 30 min\n", a_upDownP->downDurations[1]);
528 fprintf(cm_outFD,"\t\t\t%8d: 30 min .. 1 hr\n", a_upDownP->downDurations[2]);
529 fprintf(cm_outFD,"\t\t\t%8d: 1 hr .. 2 hr\n", a_upDownP->downDurations[3]);
530 fprintf(cm_outFD,"\t\t\t%8d: 2 hr .. 4 hr\n", a_upDownP->downDurations[4]);
531 fprintf(cm_outFD,"\t\t\t%8d: 4 hr .. 8 hr\n", a_upDownP->downDurations[5]);
532 fprintf(cm_outFD,"\t\t\t%8d: > 8 hr\n", a_upDownP->downDurations[6]);
534 fprintf(cm_outFD,"\t\tDowntime incident distribution:\n");
535 fprintf(cm_outFD,"\t\t\t%8d: 0 times\n", a_upDownP->downIncidents[0]);
536 fprintf(cm_outFD,"\t\t\t%8d: 1 time\n", a_upDownP->downIncidents[1]);
537 fprintf(cm_outFD,"\t\t\t%8d: 2 .. 5 times\n", a_upDownP->downIncidents[2]);
538 fprintf(cm_outFD,"\t\t\t%8d: 6 .. 10 times\n", a_upDownP->downIncidents[3]);
539 fprintf(cm_outFD,"\t\t\t%8d: 10 .. 50 times\n", a_upDownP->downIncidents[4]);
540 fprintf(cm_outFD,"\t\t\t%8d: > 50 times\n", a_upDownP->downIncidents[5]);
542 } /*Print_cm_UpDownStats*/
545 /*------------------------------------------------------------------------
546 * Print_cm_OverallPerfInfo
549 * Print out overall performance numbers.
552 * a_ovP : Ptr to the overall performance numbers.
558 * All the info we need is nestled into xstat_cm_Results.
562 *------------------------------------------------------------------------*/
564 void Print_cm_OverallPerfInfo(a_ovP)
565 struct afs_stats_CMPerf *a_ovP;
567 { /*Print_cm_OverallPerfInfo*/
569 fprintf(cm_outFD,"\t%10d numPerfCalls\n", a_ovP->numPerfCalls);
571 fprintf(cm_outFD,"\t%10d epoch\n", a_ovP->epoch);
572 fprintf(cm_outFD,"\t%10d numCellsVisible\n", a_ovP->numCellsVisible);
573 fprintf(cm_outFD,"\t%10d numCellsContacted\n", a_ovP->numCellsContacted);
574 fprintf(cm_outFD,"\t%10d dlocalAccesses\n", a_ovP->dlocalAccesses);
575 fprintf(cm_outFD,"\t%10d vlocalAccesses\n", a_ovP->vlocalAccesses);
576 fprintf(cm_outFD,"\t%10d dremoteAccesses\n", a_ovP->dremoteAccesses);
577 fprintf(cm_outFD,"\t%10d vremoteAccesses\n", a_ovP->vremoteAccesses);
578 fprintf(cm_outFD,"\t%10d cacheNumEntries\n", a_ovP->cacheNumEntries);
579 fprintf(cm_outFD,"\t%10d cacheBlocksTotal\n", a_ovP->cacheBlocksTotal);
580 fprintf(cm_outFD,"\t%10d cacheBlocksInUse\n", a_ovP->cacheBlocksInUse);
581 fprintf(cm_outFD,"\t%10d cacheBlocksOrig\n", a_ovP->cacheBlocksOrig);
582 fprintf(cm_outFD,"\t%10d cacheMaxDirtyChunks\n",a_ovP->cacheMaxDirtyChunks);
583 fprintf(cm_outFD,"\t%10d cacheCurrDirtyChunks\n", a_ovP->cacheCurrDirtyChunks);
584 fprintf(cm_outFD,"\t%10d dcacheHits\n", a_ovP->dcacheHits);
585 fprintf(cm_outFD,"\t%10d vcacheHits\n", a_ovP->vcacheHits);
586 fprintf(cm_outFD,"\t%10d dcacheMisses\n", a_ovP->dcacheMisses);
587 fprintf(cm_outFD,"\t%10d vcacheMisses\n", a_ovP->vcacheMisses);
588 fprintf(cm_outFD,"\t%10d cacheFilesReused\n", a_ovP->cacheFilesReused);
589 fprintf(cm_outFD,"\t%10d vcacheXAllocs\n", a_ovP->vcacheXAllocs);
591 fprintf(cm_outFD,"\t%10d bufAlloced\n", a_ovP->bufAlloced);
592 fprintf(cm_outFD,"\t%10d bufHits\n", a_ovP->bufHits);
593 fprintf(cm_outFD,"\t%10d bufMisses\n", a_ovP->bufMisses);
594 fprintf(cm_outFD,"\t%10d bufFlushDirty\n", a_ovP->bufFlushDirty);
596 fprintf(cm_outFD,"\t%10d LargeBlocksActive\n", a_ovP->LargeBlocksActive);
597 fprintf(cm_outFD,"\t%10d LargeBlocksAlloced\n", a_ovP->LargeBlocksAlloced);
598 fprintf(cm_outFD,"\t%10d SmallBlocksActive\n", a_ovP->SmallBlocksActive);
599 fprintf(cm_outFD,"\t%10d SmallBlocksAlloced\n", a_ovP->SmallBlocksAlloced);
600 fprintf(cm_outFD,"\t%10d OutStandingMemUsage\n", a_ovP->OutStandingMemUsage);
601 fprintf(cm_outFD,"\t%10d OutStandingAllocs\n", a_ovP->OutStandingAllocs);
602 fprintf(cm_outFD,"\t%10d CallBackAlloced\n", a_ovP->CallBackAlloced);
603 fprintf(cm_outFD,"\t%10d CallBackFlushes\n", a_ovP->CallBackFlushes);
605 fprintf(cm_outFD,"\t%10d srvRecords\n", a_ovP->srvRecords);
606 fprintf(cm_outFD,"\t%10d srvNumBuckets\n", a_ovP->srvNumBuckets);
607 fprintf(cm_outFD,"\t%10d srvMaxChainLength\n", a_ovP->srvMaxChainLength);
608 fprintf(cm_outFD,"\t%10d srvMaxChainLengthHWM\n", a_ovP->srvMaxChainLengthHWM);
609 fprintf(cm_outFD,"\t%10d srvRecordsHWM\n", a_ovP->srvRecordsHWM);
611 fprintf(cm_outFD,"\t%10d sysName_ID\n", a_ovP->sysName_ID);
613 fprintf(cm_outFD,"\tFile Server up/downtimes, same cell:\n");
614 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[0]));
616 fprintf(cm_outFD,"\tFile Server up/downtimes, diff cell:\n");
617 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[1]));
619 fprintf(cm_outFD,"\tVL Server up/downtimes, same cell:\n");
620 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[0]));
622 fprintf(cm_outFD,"\tVL Server up/downtimes, diff cell:\n");
623 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[1]));
625 } /*Print_cm_OverallPerfInfo*/
628 /*------------------------------------------------------------------------
632 * Print out the AFSCB_XSTATSCOLL_PERF_INFO collection we just
642 * All the info we need is nestled into xstat_cm_Results.
646 *------------------------------------------------------------------------*/
648 void Print_cm_PerfInfo()
650 { /*Print_cm_PerfInfo*/
652 static char rn[] = "Print_cm_PerfInfo"; /*Routine name*/
653 static afs_int32 perfLongs =
654 (sizeof(struct afs_stats_CMPerf) >> 2); /*Correct # longs to rcv*/
655 afs_int32 numLongs; /*# longwords received*/
656 struct afs_stats_CMPerf *perfP; /*Ptr to performance stats*/
657 char *printableTime; /*Ptr to printable time string*/
659 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
660 if (numLongs != perfLongs) {
661 fprintf(cm_outFD," ** Data size mismatch in performance collection!\n");
662 fprintf(cm_outFD,"** Expecting %d, got %d\n", perfLongs, numLongs);
666 printableTime = ctime((time_t *)&(xstat_cm_Results.probeTime));
667 printableTime[strlen(printableTime)-1] = '\0';
668 perfP = (struct afs_stats_CMPerf *)
669 (xstat_cm_Results.data.AFSCB_CollData_val);
671 fprintf(cm_outFD,"AFSCB_XSTATSCOLL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
672 xstat_cm_Results.collectionNumber,
673 xstat_cm_Results.connP->hostName,
674 xstat_cm_Results.probeNum,
677 Print_cm_OverallPerfInfo(perfP);
679 } /*Print_cm_PerfInfo*/
682 /*------------------------------------------------------------------------
686 * Print out the contents of an FS RPC op timing structure.
689 * a_opIdx : Index of the AFS operation we're printing number on.
690 * a_opNames : Ptr to table of operaton names.
691 * a_opTimeP : Ptr to the op timing structure to print.
697 * Nothing interesting.
701 *------------------------------------------------------------------------*/
703 void Print_cm_OpTiming(a_opIdx, a_opNames, a_opTimeP)
706 struct afs_stats_opTimingData *a_opTimeP;
708 { /*Print_cm_OpTiming*/
710 fprintf(cm_outFD,"%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
712 a_opTimeP->numOps, a_opTimeP->numSuccesses,
713 a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
714 a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
715 a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
717 } /*Print_cm_OpTiming*/
720 /*------------------------------------------------------------------------
721 * Print_cm_XferTiming
724 * Print out the contents of a data transfer structure.
727 * a_opIdx : Index of the AFS operation we're printing number on.
728 * a_xferP : Ptr to the data transfer structure to print.
734 * Nothing interesting.
738 *------------------------------------------------------------------------*/
740 void Print_cm_XferTiming(a_opIdx, a_opNames, a_xferP)
743 struct afs_stats_xferData *a_xferP;
745 { /*Print_cm_XferTiming*/
747 fprintf(cm_outFD,"%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
749 a_xferP->numXfers, a_xferP->numSuccesses,
750 a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
751 a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
752 a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
753 fprintf(cm_outFD,"\t[bytes: sum=%d, min=%d, max=%d]\n",
754 a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
755 fprintf(cm_outFD,"\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
766 } /*Print_cm_XferTiming*/
769 /*------------------------------------------------------------------------
773 * Print out the contents of an FS RPC error info structure.
776 * a_opIdx : Index of the AFS operation we're printing.
777 * a_opNames : Ptr to table of operation names.
778 * a_opErrP : Ptr to the op timing structure to print.
784 * Nothing interesting.
788 *------------------------------------------------------------------------*/
790 void Print_cm_ErrInfo(a_opIdx, a_opNames, a_opErrP)
793 struct afs_stats_RPCErrors *a_opErrP;
795 { /*Print_cm_ErrInfo*/
797 fprintf(cm_outFD,"%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n",
799 a_opErrP->err_Server,
800 a_opErrP->err_Network,
801 a_opErrP->err_Protection,
802 a_opErrP->err_Volume,
803 a_opErrP->err_VolumeBusies,
804 a_opErrP->err_Other);
806 } /*Print_cm_ErrInfo*/
809 /*------------------------------------------------------------------------
810 * Print_cm_RPCPerfInfo
813 * Print out a set of RPC performance numbers.
816 * a_rpcP : Ptr to RPC perf numbers to print.
822 * Nothing interesting.
826 *------------------------------------------------------------------------*/
828 void Print_cm_RPCPerfInfo(a_rpcP)
829 struct afs_stats_RPCOpInfo *a_rpcP;
831 { /*Print_cm_RPCPerfInfo*/
833 int currIdx; /*Loop variable*/
836 * Print the contents of each of the opcode-related arrays.
838 fprintf(cm_outFD,"FS Operation Timings:\n---------------------\n");
839 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
840 Print_cm_OpTiming(currIdx, fsOpNames, &(a_rpcP->fsRPCTimes[currIdx]));
842 fprintf(cm_outFD,"\nError Info:\n-----------\n");
843 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
844 Print_cm_ErrInfo(currIdx, fsOpNames, &(a_rpcP->fsRPCErrors[currIdx]));
846 fprintf(cm_outFD,"\nTransfer timings:\n-----------------\n");
847 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++)
848 Print_cm_XferTiming(currIdx, xferOpNames, &(a_rpcP->fsXferTimes[currIdx]));
850 fprintf(cm_outFD,"\nCM Operation Timings:\n---------------------\n");
851 for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++)
852 Print_cm_OpTiming(currIdx, cmOpNames, &(a_rpcP->cmRPCTimes[currIdx]));
854 } /*Print_cm_RPCPerfInfo*/
857 /*------------------------------------------------------------------------
858 * Print_cm_FullPerfInfo
861 * Print out a set of full performance numbers.
870 * Nothing interesting.
874 *------------------------------------------------------------------------*/
876 void Print_cm_FullPerfInfo()
878 { /*Print_cm_FullPerfInfo*/
880 static char rn[] = "Print_cm_FullPerfInfo"; /* routine name */
881 struct afs_stats_AuthentInfo *authentP; /*Ptr to authentication stats*/
882 struct afs_stats_AccessInfo *accessinfP; /*Ptr to access stats*/
883 static afs_int32 fullPerfLongs =
884 (sizeof (struct afs_stats_CMFullPerf) >> 2); /*Correct #longs*/
885 afs_int32 numLongs; /*# longs actually received*/
886 struct afs_stats_CMFullPerf *fullP; /*Ptr to full perf info*/
888 char *printableTime; /*Ptr to printable time string*/
890 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
891 if (numLongs != fullPerfLongs) {
892 fprintf(cm_outFD," ** Data size mismatch in performance collection!\n");
893 fprintf(cm_outFD," ** Expecting %d, got %d\n",fullPerfLongs, numLongs);
897 printableTime = ctime((time_t *)&(xstat_cm_Results.probeTime));
898 printableTime[strlen(printableTime)-1] = '\0';
899 fullP = (struct afs_stats_CMFullPerf *)
900 (xstat_cm_Results.data.AFSCB_CollData_val);
902 fprintf(cm_outFD,"AFSCB_XSTATSCOLL_FULL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
903 xstat_cm_Results.collectionNumber,
904 xstat_cm_Results.connP->hostName,
905 xstat_cm_Results.probeNum,
909 * Print the overall numbers first, followed by all of the RPC numbers,
910 * then each of the other groupings.
912 fprintf(cm_outFD,"Overall Performance Info:\n-------------------------\n");
913 Print_cm_OverallPerfInfo(&(fullP->perf));
914 fprintf(cm_outFD,"\n");
915 Print_cm_RPCPerfInfo(&(fullP->rpc));
917 authentP = &(fullP->authent);
918 fprintf(cm_outFD,"\nAuthentication info:\n--------------------\n");
919 fprintf(cm_outFD,"\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n",
921 authentP->curr_Records,
922 authentP->curr_AuthRecords,
923 authentP->curr_UnauthRecords,
924 authentP->curr_MaxRecordsInPAG,
925 authentP->curr_LongestChain);
926 fprintf(cm_outFD,"\t%d PAG creations, %d tkt updates\n",
927 authentP->PAGCreations,
928 authentP->TicketUpdates);
929 fprintf(cm_outFD,"\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n",
931 authentP->HWM_Records,
932 authentP->HWM_MaxRecordsInPAG,
933 authentP->HWM_LongestChain);
935 accessinfP = &(fullP->accessinf);
936 fprintf(cm_outFD,"\n[Un]replicated accesses:\n------------------------\n");
937 fprintf(cm_outFD,"\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n",
938 accessinfP->unreplicatedRefs,
939 accessinfP->replicatedRefs,
940 accessinfP->numReplicasAccessed,
941 accessinfP->maxReplicasPerRef,
942 accessinfP->refFirstReplicaOK);
944 /* There really isn't any authorship info
945 authorP = &(fullP->author); */
947 } /*Print_cm_FullPerfInfo*/
949 /*------------------------------------------------------------------------
953 * Prints the contents of xstat_cm_Results to an output file. The
954 * output is either in a compact (longs only) format or a detailed
955 * format giving the names of each of the datums. Output is appended.
958 * Name of output file.
959 * Flag to indicate if detailed output is required.
965 * All the info we need is nestled into xstat_cm_Results.
969 *------------------------------------------------------------------------*/
971 afsmon_cmOutput(a_outfile, a_detOutput)
972 char *a_outfile; /* ptr to output file name */
973 int a_detOutput; /* detailed output ? */
976 static char rn[] = "afsmon_cmOutput"; /* routine name */
977 char *printTime; /* ptr to time string */
978 char *hostname; /* fileserner name */
979 afs_int32 numLongs; /* longwords in result */
980 afs_int32 *currLong; /* ptr to longwords in result */
984 fprintf(debugFD,"[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
985 rn, a_outfile, a_detOutput);
989 /* need to lock this file before writing */
990 cm_outFD = fopen(a_outfile,"a");
991 if (cm_outFD == (FILE *)0) {
992 sprintf(errMsg,"[ %s ] failed to open output file %s",rn,a_outfile);
996 /* get the probe time and strip the \n at the end */
997 printTime = ctime((time_t *)&(xstat_cm_Results.probeTime));
998 printTime[strlen(printTime) - 1] = '\0';
999 hostname = xstat_cm_Results.connP->hostName;
1001 /* print "time hostname CM" prefix */
1002 fprintf(cm_outFD,"\n%s %s CM ",printTime,hostname);
1004 /* if probe failed print -1 and vanish */
1005 if (xstat_cm_Results.probeOK) {
1006 fprintf(cm_outFD,"-1\n");
1011 /* print out the probe information as long words */
1012 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
1013 currLong = (afs_int32 *)(xstat_cm_Results.data.AFSCB_CollData_val);
1015 for(i=0; i<numLongs; i++) {
1016 fprintf(cm_outFD,"%d ",*currLong++);
1018 fprintf(cm_outFD,"\n\n");
1020 /* print out detailed statistics */
1022 Print_cm_FullPerfInfo();
1026 if ( fclose(cm_outFD))
1028 fprintf(debugFD,"[ %s ] failed to close %s\n",rn,a_outfile);