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>
34 #include <afs/xstat_fs.h>
35 #include <afs/xstat_cm.h>
39 /* Extern Variables */
40 extern int afsmon_debug; /* debugging on ? */
41 extern FILE *debugFD; /* debug file FD */
42 extern char errMsg[256]; /* error message buffer */
44 extern int afsmon_Exit(); /* exit routine */
46 static FILE *fs_outFD; /* fs output file descriptor */
47 static FILE *cm_outFD; /* cm output file descriptor */
49 /* structures used by FS & CM stats print routines */
51 static char *fsOpNames[] = {
82 static char *cmOpNames[] = {
92 static char *xferOpNames[] = {
97 /*________________________________________________________________________
99 *_______________________________________________________________________*/
101 /*------------------------------------------------------------------------
102 * Print_fs_OverallPerfInfo
105 * Print out overall performance numbers.
108 * a_ovP : Ptr to the overall performance numbers.
114 * Nothing interesting.
118 *------------------------------------------------------------------------*/
121 Print_fs_OverallPerfInfo(a_ovP)
122 struct afs_PerfStats *a_ovP;
124 { /*Print_fs_OverallPerfInfo */
126 fprintf(fs_outFD, "\t%10d numPerfCalls\n\n", a_ovP->numPerfCalls);
130 * Vnode cache section.
132 fprintf(fs_outFD, "\t%10d vcache_L_Entries\n", a_ovP->vcache_L_Entries);
133 fprintf(fs_outFD, "\t%10d vcache_L_Allocs\n", a_ovP->vcache_L_Allocs);
134 fprintf(fs_outFD, "\t%10d vcache_L_Gets\n", a_ovP->vcache_L_Gets);
135 fprintf(fs_outFD, "\t%10d vcache_L_Reads\n", a_ovP->vcache_L_Reads);
136 fprintf(fs_outFD, "\t%10d vcache_L_Writes\n\n", a_ovP->vcache_L_Writes);
138 fprintf(fs_outFD, "\t%10d vcache_S_Entries\n", a_ovP->vcache_S_Entries);
139 fprintf(fs_outFD, "\t%10d vcache_S_Allocs\n", a_ovP->vcache_S_Allocs);
140 fprintf(fs_outFD, "\t%10d vcache_S_Gets\n", a_ovP->vcache_S_Gets);
141 fprintf(fs_outFD, "\t%10d vcache_S_Reads\n", a_ovP->vcache_S_Reads);
142 fprintf(fs_outFD, "\t%10d vcache_S_Writes\n\n", a_ovP->vcache_S_Writes);
144 fprintf(fs_outFD, "\t%10d vcache_H_Entries\n", a_ovP->vcache_H_Entries);
145 fprintf(fs_outFD, "\t%10d vcache_H_Gets\n", a_ovP->vcache_H_Gets);
146 fprintf(fs_outFD, "\t%10d vcache_H_Replacements\n\n",
147 a_ovP->vcache_H_Replacements);
150 * Directory package section.
152 fprintf(fs_outFD, "\t%10d dir_Buffers\n", a_ovP->dir_Buffers);
153 fprintf(fs_outFD, "\t%10d dir_Calls\n", a_ovP->dir_Calls);
154 fprintf(fs_outFD, "\t%10d dir_IOs\n\n", a_ovP->dir_IOs);
159 fprintf(fs_outFD, "\t%10d rx_packetRequests\n", a_ovP->rx_packetRequests);
160 fprintf(fs_outFD, "\t%10d rx_noPackets_RcvClass\n",
161 a_ovP->rx_noPackets_RcvClass);
162 fprintf(fs_outFD, "\t%10d rx_noPackets_SendClass\n",
163 a_ovP->rx_noPackets_SendClass);
164 fprintf(fs_outFD, "\t%10d rx_noPackets_SpecialClass\n",
165 a_ovP->rx_noPackets_SpecialClass);
166 fprintf(fs_outFD, "\t%10d rx_socketGreedy\n", a_ovP->rx_socketGreedy);
167 fprintf(fs_outFD, "\t%10d rx_bogusPacketOnRead\n",
168 a_ovP->rx_bogusPacketOnRead);
169 fprintf(fs_outFD, "\t%10d rx_bogusHost\n", a_ovP->rx_bogusHost);
170 fprintf(fs_outFD, "\t%10d rx_noPacketOnRead\n", a_ovP->rx_noPacketOnRead);
171 fprintf(fs_outFD, "\t%10d rx_noPacketBuffersOnRead\n",
172 a_ovP->rx_noPacketBuffersOnRead);
173 fprintf(fs_outFD, "\t%10d rx_selects\n", a_ovP->rx_selects);
174 fprintf(fs_outFD, "\t%10d rx_sendSelects\n", a_ovP->rx_sendSelects);
175 fprintf(fs_outFD, "\t%10d rx_packetsRead_RcvClass\n",
176 a_ovP->rx_packetsRead_RcvClass);
177 fprintf(fs_outFD, "\t%10d rx_packetsRead_SendClass\n",
178 a_ovP->rx_packetsRead_SendClass);
179 fprintf(fs_outFD, "\t%10d rx_packetsRead_SpecialClass\n",
180 a_ovP->rx_packetsRead_SpecialClass);
181 fprintf(fs_outFD, "\t%10d rx_dataPacketsRead\n",
182 a_ovP->rx_dataPacketsRead);
183 fprintf(fs_outFD, "\t%10d rx_ackPacketsRead\n", a_ovP->rx_ackPacketsRead);
184 fprintf(fs_outFD, "\t%10d rx_dupPacketsRead\n", a_ovP->rx_dupPacketsRead);
185 fprintf(fs_outFD, "\t%10d rx_spuriousPacketsRead\n",
186 a_ovP->rx_spuriousPacketsRead);
187 fprintf(fs_outFD, "\t%10d rx_packetsSent_RcvClass\n",
188 a_ovP->rx_packetsSent_RcvClass);
189 fprintf(fs_outFD, "\t%10d rx_packetsSent_SendClass\n",
190 a_ovP->rx_packetsSent_SendClass);
191 fprintf(fs_outFD, "\t%10d rx_packetsSent_SpecialClass\n",
192 a_ovP->rx_packetsSent_SpecialClass);
193 fprintf(fs_outFD, "\t%10d rx_ackPacketsSent\n", a_ovP->rx_ackPacketsSent);
194 fprintf(fs_outFD, "\t%10d rx_pingPacketsSent\n",
195 a_ovP->rx_pingPacketsSent);
196 fprintf(fs_outFD, "\t%10d rx_abortPacketsSent\n",
197 a_ovP->rx_abortPacketsSent);
198 fprintf(fs_outFD, "\t%10d rx_busyPacketsSent\n",
199 a_ovP->rx_busyPacketsSent);
200 fprintf(fs_outFD, "\t%10d rx_dataPacketsSent\n",
201 a_ovP->rx_dataPacketsSent);
202 fprintf(fs_outFD, "\t%10d rx_dataPacketsReSent\n",
203 a_ovP->rx_dataPacketsReSent);
204 fprintf(fs_outFD, "\t%10d rx_dataPacketsPushed\n",
205 a_ovP->rx_dataPacketsPushed);
206 fprintf(fs_outFD, "\t%10d rx_ignoreAckedPacket\n",
207 a_ovP->rx_ignoreAckedPacket);
208 fprintf(fs_outFD, "\t%10d rx_totalRtt_Sec\n", a_ovP->rx_totalRtt_Sec);
209 fprintf(fs_outFD, "\t%10d rx_totalRtt_Usec\n", a_ovP->rx_totalRtt_Usec);
210 fprintf(fs_outFD, "\t%10d rx_minRtt_Sec\n", a_ovP->rx_minRtt_Sec);
211 fprintf(fs_outFD, "\t%10d rx_minRtt_Usec\n", a_ovP->rx_minRtt_Usec);
212 fprintf(fs_outFD, "\t%10d rx_maxRtt_Sec\n", a_ovP->rx_maxRtt_Sec);
213 fprintf(fs_outFD, "\t%10d rx_maxRtt_Usec\n", a_ovP->rx_maxRtt_Usec);
214 fprintf(fs_outFD, "\t%10d rx_nRttSamples\n", a_ovP->rx_nRttSamples);
215 fprintf(fs_outFD, "\t%10d rx_nServerConns\n", a_ovP->rx_nServerConns);
216 fprintf(fs_outFD, "\t%10d rx_nClientConns\n", a_ovP->rx_nClientConns);
217 fprintf(fs_outFD, "\t%10d rx_nPeerStructs\n", a_ovP->rx_nPeerStructs);
218 fprintf(fs_outFD, "\t%10d rx_nCallStructs\n", a_ovP->rx_nCallStructs);
219 fprintf(fs_outFD, "\t%10d rx_nFreeCallStructs\n\n",
220 a_ovP->rx_nFreeCallStructs);
223 * Host module fields.
225 fprintf(fs_outFD, "\t%10d host_NumHostEntries\n",
226 a_ovP->host_NumHostEntries);
227 fprintf(fs_outFD, "\t%10d host_HostBlocks\n", a_ovP->host_HostBlocks);
228 fprintf(fs_outFD, "\t%10d host_NonDeletedHosts\n",
229 a_ovP->host_NonDeletedHosts);
230 fprintf(fs_outFD, "\t%10d host_HostsInSameNetOrSubnet\n",
231 a_ovP->host_HostsInSameNetOrSubnet);
232 fprintf(fs_outFD, "\t%10d host_HostsInDiffSubnet\n",
233 a_ovP->host_HostsInDiffSubnet);
234 fprintf(fs_outFD, "\t%10d host_HostsInDiffNetwork\n",
235 a_ovP->host_HostsInDiffNetwork);
236 fprintf(fs_outFD, "\t%10d host_NumClients\n", a_ovP->host_NumClients);
237 fprintf(fs_outFD, "\t%10d host_ClientBlocks\n\n",
238 a_ovP->host_ClientBlocks);
240 } /*Print_fs_OverallPerfInfo */
243 /*------------------------------------------------------------------------
247 * Print out the contents of an RPC op timing structure.
250 * a_opIdx : Index of the AFS operation we're printing number on.
251 * a_opTimeP : Ptr to the op timing structure to print.
257 * Nothing interesting.
261 *------------------------------------------------------------------------*/
264 Print_fs_OpTiming(a_opIdx, a_opTimeP)
266 struct fs_stats_opTimingData *a_opTimeP;
268 { /*Print_fs_OpTiming */
271 "%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
272 fsOpNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses,
273 a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
274 a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
275 a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
277 } /*Print_fs_OpTiming */
280 /*------------------------------------------------------------------------
281 * Print_fs_XferTiming
284 * Print out the contents of a data transfer structure.
287 * a_opIdx : Index of the AFS operation we're printing number on.
288 * a_xferP : Ptr to the data transfer structure to print.
294 * Nothing interesting.
298 *------------------------------------------------------------------------*/
301 Print_fs_XferTiming(a_opIdx, a_xferP)
303 struct fs_stats_xferData *a_xferP;
305 { /*Print_fs_XferTiming */
308 "%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
309 xferOpNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses,
310 a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
311 a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
312 a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
313 fprintf(fs_outFD, "\t[bytes: sum=%d, min=%d, max=%d]\n",
314 a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
316 "\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
317 a_xferP->count[0], a_xferP->count[1], a_xferP->count[2],
318 a_xferP->count[3], a_xferP->count[4], a_xferP->count[5],
319 a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]);
321 } /*Print_fs_XferTiming */
324 /*------------------------------------------------------------------------
325 * Print_fs_DetailedPerfInfo
328 * Print out a set of detailed performance numbers.
331 * a_detP : Ptr to detailed perf numbers to print.
337 * Nothing interesting.
341 *------------------------------------------------------------------------*/
344 Print_fs_DetailedPerfInfo(a_detP)
345 struct fs_stats_DetailedStats *a_detP;
347 { /*Print_fs_DetailedPerfInfo */
349 int currIdx; /*Loop variable */
351 fprintf(fs_outFD, "\t%10d epoch\n", a_detP->epoch);
353 for (currIdx = 0; currIdx < FS_STATS_NUM_RPC_OPS; currIdx++)
354 Print_fs_OpTiming(currIdx, &(a_detP->rpcOpTimes[currIdx]));
356 for (currIdx = 0; currIdx < FS_STATS_NUM_XFER_OPS; currIdx++)
357 Print_fs_XferTiming(currIdx, &(a_detP->xferOpTimes[currIdx]));
359 } /*Print_fs_DetailedPerfInfo */
362 /*------------------------------------------------------------------------
363 * Print_fs_FullPerfInfo
366 * Print out the AFS_XSTATSCOLL_FULL_PERF_INFO collection we just
376 * All the info we need is nestled into xstat_fs_Results.
380 *------------------------------------------------------------------------*/
383 Print_fs_FullPerfInfo(a_fs_Results)
384 struct xstat_fs_ProbeResults *a_fs_Results; /* ptr to fs results */
385 { /*Print_fs_FullPerfInfo */
387 static char rn[] = "Print_fs_FullPerfInfo"; /*Routine name */
388 static afs_int32 fullPerfLongs = (sizeof(struct fs_stats_FullPerfStats) >> 2); /*Correct # longs to rcv */
389 afs_int32 numLongs; /*# longwords received */
390 struct fs_stats_FullPerfStats *fullPerfP; /*Ptr to full perf stats */
391 char *printableTime; /*Ptr to printable time string */
394 numLongs = a_fs_Results->data.AFS_CollData_len;
395 if (numLongs != fullPerfLongs) {
397 " ** Data size mismatch in full performance collection!\n");
398 fprintf(fs_outFD, " ** Expecting %d, got %d\n", fullPerfLongs,
403 printableTime = ctime((time_t *) & (a_fs_Results->probeTime));
404 printableTime[strlen(printableTime) - 1] = '\0';
405 fullPerfP = (struct fs_stats_FullPerfStats *)
406 (a_fs_Results->data.AFS_CollData_val);
409 "AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n",
410 a_fs_Results->collectionNumber, a_fs_Results->connP->hostName,
411 a_fs_Results->probeNum, printableTime);
413 Print_fs_OverallPerfInfo(&(fullPerfP->overall));
414 Print_fs_DetailedPerfInfo(&(fullPerfP->det));
416 } /*Print_fs_FullPerfInfo */
419 /*------------------------------------------------------------------------
423 * Prints the contents of xstat_fs_Results to an output file. The
424 * output is either in a compact (longs only) format or a detailed
425 * format giving the names of each of the datums. Output is appended.
428 * Name of output file.
429 * Flag to indicate if detailed output is required.
435 * All the info we need is nestled into xstat_fs_Results.
439 *------------------------------------------------------------------------*/
441 afsmon_fsOutput(a_outfile, a_detOutput)
442 char *a_outfile; /* ptr to output file name */
443 int a_detOutput; /* detailed output ? */
446 static char rn[] = "afsmon_fsOutput"; /* routine name */
447 char *printTime; /* ptr to time string */
448 char *hostname; /* fileserner name */
449 afs_int32 numLongs; /* longwords in result */
450 afs_int32 *currLong; /* ptr to longwords in result */
454 fprintf(debugFD, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
455 rn, a_outfile, a_detOutput);
459 fs_outFD = fopen(a_outfile, "a");
460 if (fs_outFD == (FILE *) 0) {
461 sprintf(errMsg, "[ %s ] failed to open output file %s", rn,
466 /* get the probe time and strip the \n at the end */
467 printTime = ctime((time_t *) & (xstat_fs_Results.probeTime));
468 printTime[strlen(printTime) - 1] = '\0';
469 hostname = xstat_fs_Results.connP->hostName;
471 /* print "time hostname FS" */
472 fprintf(fs_outFD, "\n%s %s FS ", printTime, hostname);
474 /* if probe failed print -1 and return */
475 if (xstat_fs_Results.probeOK) {
476 fprintf(fs_outFD, "-1\n");
481 /* print out the probe information as long words */
482 numLongs = xstat_fs_Results.data.AFS_CollData_len;
483 currLong = (afs_int32 *) (xstat_fs_Results.data.AFS_CollData_val);
485 for (i = 0; i < numLongs; i++) {
486 fprintf(fs_outFD, "%d ", *currLong++);
488 fprintf(fs_outFD, "\n\n");
490 /* print detailed information */
492 Print_fs_FullPerfInfo(&xstat_fs_Results);
496 if (fclose(fs_outFD))
498 fprintf(debugFD, "[ %s ] failed to close %s\n", rn, a_outfile);
505 /*___________________________________________________________________________
507 *__________________________________________________________________________*/
511 /*------------------------------------------------------------------------
512 * Print_cm_UpDownStats
515 * Print the up/downtime stats for the given class of server records
519 * a_upDownP : Ptr to the server up/down info.
525 * Nothing interesting.
529 *------------------------------------------------------------------------*/
532 Print_cm_UpDownStats(a_upDownP)
533 struct afs_stats_SrvUpDownInfo *a_upDownP; /*Ptr to server up/down info */
535 { /*Print_cm_UpDownStats */
538 * First, print the simple values.
540 fprintf(cm_outFD, "\t\t%10d numTtlRecords\n", a_upDownP->numTtlRecords);
541 fprintf(cm_outFD, "\t\t%10d numUpRecords\n", a_upDownP->numUpRecords);
542 fprintf(cm_outFD, "\t\t%10d numDownRecords\n", a_upDownP->numDownRecords);
543 fprintf(cm_outFD, "\t\t%10d sumOfRecordAges\n",
544 a_upDownP->sumOfRecordAges);
545 fprintf(cm_outFD, "\t\t%10d ageOfYoungestRecord\n",
546 a_upDownP->ageOfYoungestRecord);
547 fprintf(cm_outFD, "\t\t%10d ageOfOldestRecord\n",
548 a_upDownP->ageOfOldestRecord);
549 fprintf(cm_outFD, "\t\t%10d numDowntimeIncidents\n",
550 a_upDownP->numDowntimeIncidents);
551 fprintf(cm_outFD, "\t\t%10d numRecordsNeverDown\n",
552 a_upDownP->numRecordsNeverDown);
553 fprintf(cm_outFD, "\t\t%10d maxDowntimesInARecord\n",
554 a_upDownP->maxDowntimesInARecord);
555 fprintf(cm_outFD, "\t\t%10d sumOfDowntimes\n", a_upDownP->sumOfDowntimes);
556 fprintf(cm_outFD, "\t\t%10d shortestDowntime\n",
557 a_upDownP->shortestDowntime);
558 fprintf(cm_outFD, "\t\t%10d longestDowntime\n",
559 a_upDownP->longestDowntime);
562 * Now, print the array values.
564 fprintf(cm_outFD, "\t\tDowntime duration distribution:\n");
565 fprintf(cm_outFD, "\t\t\t%8d: 0 min .. 10 min\n",
566 a_upDownP->downDurations[0]);
567 fprintf(cm_outFD, "\t\t\t%8d: 10 min .. 30 min\n",
568 a_upDownP->downDurations[1]);
569 fprintf(cm_outFD, "\t\t\t%8d: 30 min .. 1 hr\n",
570 a_upDownP->downDurations[2]);
571 fprintf(cm_outFD, "\t\t\t%8d: 1 hr .. 2 hr\n",
572 a_upDownP->downDurations[3]);
573 fprintf(cm_outFD, "\t\t\t%8d: 2 hr .. 4 hr\n",
574 a_upDownP->downDurations[4]);
575 fprintf(cm_outFD, "\t\t\t%8d: 4 hr .. 8 hr\n",
576 a_upDownP->downDurations[5]);
577 fprintf(cm_outFD, "\t\t\t%8d: > 8 hr\n", a_upDownP->downDurations[6]);
579 fprintf(cm_outFD, "\t\tDowntime incident distribution:\n");
580 fprintf(cm_outFD, "\t\t\t%8d: 0 times\n", a_upDownP->downIncidents[0]);
581 fprintf(cm_outFD, "\t\t\t%8d: 1 time\n", a_upDownP->downIncidents[1]);
582 fprintf(cm_outFD, "\t\t\t%8d: 2 .. 5 times\n",
583 a_upDownP->downIncidents[2]);
584 fprintf(cm_outFD, "\t\t\t%8d: 6 .. 10 times\n",
585 a_upDownP->downIncidents[3]);
586 fprintf(cm_outFD, "\t\t\t%8d: 10 .. 50 times\n",
587 a_upDownP->downIncidents[4]);
588 fprintf(cm_outFD, "\t\t\t%8d: > 50 times\n", a_upDownP->downIncidents[5]);
590 } /*Print_cm_UpDownStats */
593 /*------------------------------------------------------------------------
594 * Print_cm_OverallPerfInfo
597 * Print out overall performance numbers.
600 * a_ovP : Ptr to the overall performance numbers.
606 * All the info we need is nestled into xstat_cm_Results.
610 *------------------------------------------------------------------------*/
613 Print_cm_OverallPerfInfo(a_ovP)
614 struct afs_stats_CMPerf *a_ovP;
616 { /*Print_cm_OverallPerfInfo */
618 fprintf(cm_outFD, "\t%10d numPerfCalls\n", a_ovP->numPerfCalls);
620 fprintf(cm_outFD, "\t%10d epoch\n", a_ovP->epoch);
621 fprintf(cm_outFD, "\t%10d numCellsVisible\n", a_ovP->numCellsVisible);
622 fprintf(cm_outFD, "\t%10d numCellsContacted\n", a_ovP->numCellsContacted);
623 fprintf(cm_outFD, "\t%10d dlocalAccesses\n", a_ovP->dlocalAccesses);
624 fprintf(cm_outFD, "\t%10d vlocalAccesses\n", a_ovP->vlocalAccesses);
625 fprintf(cm_outFD, "\t%10d dremoteAccesses\n", a_ovP->dremoteAccesses);
626 fprintf(cm_outFD, "\t%10d vremoteAccesses\n", a_ovP->vremoteAccesses);
627 fprintf(cm_outFD, "\t%10d cacheNumEntries\n", a_ovP->cacheNumEntries);
628 fprintf(cm_outFD, "\t%10d cacheBlocksTotal\n", a_ovP->cacheBlocksTotal);
629 fprintf(cm_outFD, "\t%10d cacheBlocksInUse\n", a_ovP->cacheBlocksInUse);
630 fprintf(cm_outFD, "\t%10d cacheBlocksOrig\n", a_ovP->cacheBlocksOrig);
631 fprintf(cm_outFD, "\t%10d cacheMaxDirtyChunks\n",
632 a_ovP->cacheMaxDirtyChunks);
633 fprintf(cm_outFD, "\t%10d cacheCurrDirtyChunks\n",
634 a_ovP->cacheCurrDirtyChunks);
635 fprintf(cm_outFD, "\t%10d dcacheHits\n", a_ovP->dcacheHits);
636 fprintf(cm_outFD, "\t%10d vcacheHits\n", a_ovP->vcacheHits);
637 fprintf(cm_outFD, "\t%10d dcacheMisses\n", a_ovP->dcacheMisses);
638 fprintf(cm_outFD, "\t%10d vcacheMisses\n", a_ovP->vcacheMisses);
639 fprintf(cm_outFD, "\t%10d cacheFilesReused\n", a_ovP->cacheFilesReused);
640 fprintf(cm_outFD, "\t%10d vcacheXAllocs\n", a_ovP->vcacheXAllocs);
642 fprintf(cm_outFD, "\t%10d bufAlloced\n", a_ovP->bufAlloced);
643 fprintf(cm_outFD, "\t%10d bufHits\n", a_ovP->bufHits);
644 fprintf(cm_outFD, "\t%10d bufMisses\n", a_ovP->bufMisses);
645 fprintf(cm_outFD, "\t%10d bufFlushDirty\n", a_ovP->bufFlushDirty);
647 fprintf(cm_outFD, "\t%10d LargeBlocksActive\n", a_ovP->LargeBlocksActive);
648 fprintf(cm_outFD, "\t%10d LargeBlocksAlloced\n",
649 a_ovP->LargeBlocksAlloced);
650 fprintf(cm_outFD, "\t%10d SmallBlocksActive\n", a_ovP->SmallBlocksActive);
651 fprintf(cm_outFD, "\t%10d SmallBlocksAlloced\n",
652 a_ovP->SmallBlocksAlloced);
653 fprintf(cm_outFD, "\t%10d OutStandingMemUsage\n",
654 a_ovP->OutStandingMemUsage);
655 fprintf(cm_outFD, "\t%10d OutStandingAllocs\n", a_ovP->OutStandingAllocs);
656 fprintf(cm_outFD, "\t%10d CallBackAlloced\n", a_ovP->CallBackAlloced);
657 fprintf(cm_outFD, "\t%10d CallBackFlushes\n", a_ovP->CallBackFlushes);
659 fprintf(cm_outFD, "\t%10d srvRecords\n", a_ovP->srvRecords);
660 fprintf(cm_outFD, "\t%10d srvNumBuckets\n", a_ovP->srvNumBuckets);
661 fprintf(cm_outFD, "\t%10d srvMaxChainLength\n", a_ovP->srvMaxChainLength);
662 fprintf(cm_outFD, "\t%10d srvMaxChainLengthHWM\n",
663 a_ovP->srvMaxChainLengthHWM);
664 fprintf(cm_outFD, "\t%10d srvRecordsHWM\n", a_ovP->srvRecordsHWM);
666 fprintf(cm_outFD, "\t%10d sysName_ID\n", a_ovP->sysName_ID);
668 fprintf(cm_outFD, "\tFile Server up/downtimes, same cell:\n");
669 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[0]));
671 fprintf(cm_outFD, "\tFile Server up/downtimes, diff cell:\n");
672 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[1]));
674 fprintf(cm_outFD, "\tVL Server up/downtimes, same cell:\n");
675 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[0]));
677 fprintf(cm_outFD, "\tVL Server up/downtimes, diff cell:\n");
678 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[1]));
680 } /*Print_cm_OverallPerfInfo */
683 /*------------------------------------------------------------------------
687 * Print out the AFSCB_XSTATSCOLL_PERF_INFO collection we just
697 * All the info we need is nestled into xstat_cm_Results.
701 *------------------------------------------------------------------------*/
705 { /*Print_cm_PerfInfo */
707 static char rn[] = "Print_cm_PerfInfo"; /*Routine name */
708 static afs_int32 perfLongs = (sizeof(struct afs_stats_CMPerf) >> 2); /*Correct # longs to rcv */
709 afs_int32 numLongs; /*# longwords received */
710 struct afs_stats_CMPerf *perfP; /*Ptr to performance stats */
711 char *printableTime; /*Ptr to printable time string */
713 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
714 if (numLongs != perfLongs) {
716 " ** Data size mismatch in performance collection!\n");
717 fprintf(cm_outFD, "** Expecting %d, got %d\n", perfLongs, numLongs);
721 printableTime = ctime((time_t *) & (xstat_cm_Results.probeTime));
722 printableTime[strlen(printableTime) - 1] = '\0';
723 perfP = (struct afs_stats_CMPerf *)
724 (xstat_cm_Results.data.AFSCB_CollData_val);
727 "AFSCB_XSTATSCOLL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
728 xstat_cm_Results.collectionNumber,
729 xstat_cm_Results.connP->hostName, xstat_cm_Results.probeNum,
732 Print_cm_OverallPerfInfo(perfP);
734 } /*Print_cm_PerfInfo */
737 /*------------------------------------------------------------------------
741 * Print out the contents of an FS RPC op timing structure.
744 * a_opIdx : Index of the AFS operation we're printing number on.
745 * a_opNames : Ptr to table of operaton names.
746 * a_opTimeP : Ptr to the op timing structure to print.
752 * Nothing interesting.
756 *------------------------------------------------------------------------*/
759 Print_cm_OpTiming(a_opIdx, a_opNames, a_opTimeP)
762 struct afs_stats_opTimingData *a_opTimeP;
764 { /*Print_cm_OpTiming */
767 "%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
768 a_opNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses,
769 a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
770 a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
771 a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
773 } /*Print_cm_OpTiming */
776 /*------------------------------------------------------------------------
777 * Print_cm_XferTiming
780 * Print out the contents of a data transfer structure.
783 * a_opIdx : Index of the AFS operation we're printing number on.
784 * a_xferP : Ptr to the data transfer structure to print.
790 * Nothing interesting.
794 *------------------------------------------------------------------------*/
797 Print_cm_XferTiming(a_opIdx, a_opNames, a_xferP)
800 struct afs_stats_xferData *a_xferP;
802 { /*Print_cm_XferTiming */
805 "%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
806 a_opNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses,
807 a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
808 a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
809 a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
810 fprintf(cm_outFD, "\t[bytes: sum=%d, min=%d, max=%d]\n",
811 a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
813 "\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
814 a_xferP->count[0], a_xferP->count[1], a_xferP->count[2],
815 a_xferP->count[3], a_xferP->count[4], a_xferP->count[5],
816 a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]);
818 } /*Print_cm_XferTiming */
821 /*------------------------------------------------------------------------
825 * Print out the contents of an FS RPC error info structure.
828 * a_opIdx : Index of the AFS operation we're printing.
829 * a_opNames : Ptr to table of operation names.
830 * a_opErrP : Ptr to the op timing structure to print.
836 * Nothing interesting.
840 *------------------------------------------------------------------------*/
843 Print_cm_ErrInfo(a_opIdx, a_opNames, a_opErrP)
846 struct afs_stats_RPCErrors *a_opErrP;
848 { /*Print_cm_ErrInfo */
851 "%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n",
852 a_opNames[a_opIdx], a_opErrP->err_Server, a_opErrP->err_Network,
853 a_opErrP->err_Protection, a_opErrP->err_Volume,
854 a_opErrP->err_VolumeBusies, a_opErrP->err_Other);
856 } /*Print_cm_ErrInfo */
859 /*------------------------------------------------------------------------
860 * Print_cm_RPCPerfInfo
863 * Print out a set of RPC performance numbers.
866 * a_rpcP : Ptr to RPC perf numbers to print.
872 * Nothing interesting.
876 *------------------------------------------------------------------------*/
879 Print_cm_RPCPerfInfo(a_rpcP)
880 struct afs_stats_RPCOpInfo *a_rpcP;
882 { /*Print_cm_RPCPerfInfo */
884 int currIdx; /*Loop variable */
887 * Print the contents of each of the opcode-related arrays.
889 fprintf(cm_outFD, "FS Operation Timings:\n---------------------\n");
890 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
891 Print_cm_OpTiming(currIdx, fsOpNames, &(a_rpcP->fsRPCTimes[currIdx]));
893 fprintf(cm_outFD, "\nError Info:\n-----------\n");
894 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
895 Print_cm_ErrInfo(currIdx, fsOpNames, &(a_rpcP->fsRPCErrors[currIdx]));
897 fprintf(cm_outFD, "\nTransfer timings:\n-----------------\n");
898 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++)
899 Print_cm_XferTiming(currIdx, xferOpNames,
900 &(a_rpcP->fsXferTimes[currIdx]));
902 fprintf(cm_outFD, "\nCM Operation Timings:\n---------------------\n");
903 for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++)
904 Print_cm_OpTiming(currIdx, cmOpNames, &(a_rpcP->cmRPCTimes[currIdx]));
906 } /*Print_cm_RPCPerfInfo */
909 /*------------------------------------------------------------------------
910 * Print_cm_FullPerfInfo
913 * Print out a set of full performance numbers.
922 * Nothing interesting.
926 *------------------------------------------------------------------------*/
929 Print_cm_FullPerfInfo()
930 { /*Print_cm_FullPerfInfo */
932 static char rn[] = "Print_cm_FullPerfInfo"; /* routine name */
933 struct afs_stats_AuthentInfo *authentP; /*Ptr to authentication stats */
934 struct afs_stats_AccessInfo *accessinfP; /*Ptr to access stats */
935 static afs_int32 fullPerfLongs = (sizeof(struct afs_stats_CMFullPerf) >> 2); /*Correct #longs */
936 afs_int32 numLongs; /*# longs actually received */
937 struct afs_stats_CMFullPerf *fullP; /*Ptr to full perf info */
939 char *printableTime; /*Ptr to printable time string */
941 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
942 if (numLongs != fullPerfLongs) {
944 " ** Data size mismatch in performance collection!\n");
945 fprintf(cm_outFD, " ** Expecting %d, got %d\n", fullPerfLongs,
950 printableTime = ctime((time_t *) & (xstat_cm_Results.probeTime));
951 printableTime[strlen(printableTime) - 1] = '\0';
952 fullP = (struct afs_stats_CMFullPerf *)
953 (xstat_cm_Results.data.AFSCB_CollData_val);
956 "AFSCB_XSTATSCOLL_FULL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
957 xstat_cm_Results.collectionNumber,
958 xstat_cm_Results.connP->hostName, xstat_cm_Results.probeNum,
962 * Print the overall numbers first, followed by all of the RPC numbers,
963 * then each of the other groupings.
966 "Overall Performance Info:\n-------------------------\n");
967 Print_cm_OverallPerfInfo(&(fullP->perf));
968 fprintf(cm_outFD, "\n");
969 Print_cm_RPCPerfInfo(&(fullP->rpc));
971 authentP = &(fullP->authent);
972 fprintf(cm_outFD, "\nAuthentication info:\n--------------------\n");
974 "\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n",
975 authentP->curr_PAGs, authentP->curr_Records,
976 authentP->curr_AuthRecords, authentP->curr_UnauthRecords,
977 authentP->curr_MaxRecordsInPAG, authentP->curr_LongestChain);
978 fprintf(cm_outFD, "\t%d PAG creations, %d tkt updates\n",
979 authentP->PAGCreations, authentP->TicketUpdates);
981 "\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n",
982 authentP->HWM_PAGs, authentP->HWM_Records,
983 authentP->HWM_MaxRecordsInPAG, authentP->HWM_LongestChain);
985 accessinfP = &(fullP->accessinf);
987 "\n[Un]replicated accesses:\n------------------------\n");
989 "\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n",
990 accessinfP->unreplicatedRefs, accessinfP->replicatedRefs,
991 accessinfP->numReplicasAccessed, accessinfP->maxReplicasPerRef,
992 accessinfP->refFirstReplicaOK);
994 /* There really isn't any authorship info
995 * authorP = &(fullP->author); */
997 } /*Print_cm_FullPerfInfo */
999 /*------------------------------------------------------------------------
1003 * Prints the contents of xstat_cm_Results to an output file. The
1004 * output is either in a compact (longs only) format or a detailed
1005 * format giving the names of each of the datums. Output is appended.
1008 * Name of output file.
1009 * Flag to indicate if detailed output is required.
1015 * All the info we need is nestled into xstat_cm_Results.
1019 *------------------------------------------------------------------------*/
1021 afsmon_cmOutput(a_outfile, a_detOutput)
1022 char *a_outfile; /* ptr to output file name */
1023 int a_detOutput; /* detailed output ? */
1026 static char rn[] = "afsmon_cmOutput"; /* routine name */
1027 char *printTime; /* ptr to time string */
1028 char *hostname; /* fileserner name */
1029 afs_int32 numLongs; /* longwords in result */
1030 afs_int32 *currLong; /* ptr to longwords in result */
1034 fprintf(debugFD, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
1035 rn, a_outfile, a_detOutput);
1039 /* need to lock this file before writing */
1040 cm_outFD = fopen(a_outfile, "a");
1041 if (cm_outFD == (FILE *) 0) {
1042 sprintf(errMsg, "[ %s ] failed to open output file %s", rn,
1047 /* get the probe time and strip the \n at the end */
1048 printTime = ctime((time_t *) & (xstat_cm_Results.probeTime));
1049 printTime[strlen(printTime) - 1] = '\0';
1050 hostname = xstat_cm_Results.connP->hostName;
1052 /* print "time hostname CM" prefix */
1053 fprintf(cm_outFD, "\n%s %s CM ", printTime, hostname);
1055 /* if probe failed print -1 and vanish */
1056 if (xstat_cm_Results.probeOK) {
1057 fprintf(cm_outFD, "-1\n");
1062 /* print out the probe information as long words */
1063 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
1064 currLong = (afs_int32 *) (xstat_cm_Results.data.AFSCB_CollData_val);
1066 for (i = 0; i < numLongs; i++) {
1067 fprintf(cm_outFD, "%d ", *currLong++);
1069 fprintf(cm_outFD, "\n\n");
1071 /* print out detailed statistics */
1073 Print_cm_FullPerfInfo();
1077 if (fclose(cm_outFD))
1079 fprintf(debugFD, "[ %s ] failed to close %s\n", rn, a_outfile);