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>
25 #include <afs/xstat_fs.h>
26 #include <afs/xstat_cm.h>
28 #include "afsmonitor.h"
31 /* Extern Variables */
32 extern int afsmon_debug; /* debugging on ? */
33 extern FILE *debugFD; /* debug file FD */
34 extern char errMsg[256]; /* error message buffer */
36 static FILE *fs_outFD; /* fs output file descriptor */
37 static FILE *cm_outFD; /* cm output file descriptor */
39 /* structures used by FS & CM stats print routines */
41 static char *fsOpNames[] = {
72 static char *cmOpNames[] = {
82 static char *xferOpNames[] = {
87 /*________________________________________________________________________
89 *_______________________________________________________________________*/
91 /*------------------------------------------------------------------------
92 * Print_fs_OverallPerfInfo
95 * Print out overall performance numbers.
98 * a_ovP : Ptr to the overall performance numbers.
104 * Nothing interesting.
108 *------------------------------------------------------------------------*/
111 Print_fs_OverallPerfInfo(struct afs_PerfStats *a_ovP)
112 { /*Print_fs_OverallPerfInfo */
114 fprintf(fs_outFD, "\t%10d numPerfCalls\n\n", a_ovP->numPerfCalls);
118 * Vnode cache section.
120 fprintf(fs_outFD, "\t%10d vcache_L_Entries\n", a_ovP->vcache_L_Entries);
121 fprintf(fs_outFD, "\t%10d vcache_L_Allocs\n", a_ovP->vcache_L_Allocs);
122 fprintf(fs_outFD, "\t%10d vcache_L_Gets\n", a_ovP->vcache_L_Gets);
123 fprintf(fs_outFD, "\t%10d vcache_L_Reads\n", a_ovP->vcache_L_Reads);
124 fprintf(fs_outFD, "\t%10d vcache_L_Writes\n\n", a_ovP->vcache_L_Writes);
126 fprintf(fs_outFD, "\t%10d vcache_S_Entries\n", a_ovP->vcache_S_Entries);
127 fprintf(fs_outFD, "\t%10d vcache_S_Allocs\n", a_ovP->vcache_S_Allocs);
128 fprintf(fs_outFD, "\t%10d vcache_S_Gets\n", a_ovP->vcache_S_Gets);
129 fprintf(fs_outFD, "\t%10d vcache_S_Reads\n", a_ovP->vcache_S_Reads);
130 fprintf(fs_outFD, "\t%10d vcache_S_Writes\n\n", a_ovP->vcache_S_Writes);
132 fprintf(fs_outFD, "\t%10d vcache_H_Entries\n", a_ovP->vcache_H_Entries);
133 fprintf(fs_outFD, "\t%10d vcache_H_Gets\n", a_ovP->vcache_H_Gets);
134 fprintf(fs_outFD, "\t%10d vcache_H_Replacements\n\n",
135 a_ovP->vcache_H_Replacements);
138 * Directory package section.
140 fprintf(fs_outFD, "\t%10d dir_Buffers\n", a_ovP->dir_Buffers);
141 fprintf(fs_outFD, "\t%10d dir_Calls\n", a_ovP->dir_Calls);
142 fprintf(fs_outFD, "\t%10d dir_IOs\n\n", a_ovP->dir_IOs);
147 fprintf(fs_outFD, "\t%10d rx_packetRequests\n", a_ovP->rx_packetRequests);
148 fprintf(fs_outFD, "\t%10d rx_noPackets_RcvClass\n",
149 a_ovP->rx_noPackets_RcvClass);
150 fprintf(fs_outFD, "\t%10d rx_noPackets_SendClass\n",
151 a_ovP->rx_noPackets_SendClass);
152 fprintf(fs_outFD, "\t%10d rx_noPackets_SpecialClass\n",
153 a_ovP->rx_noPackets_SpecialClass);
154 fprintf(fs_outFD, "\t%10d rx_socketGreedy\n", a_ovP->rx_socketGreedy);
155 fprintf(fs_outFD, "\t%10d rx_bogusPacketOnRead\n",
156 a_ovP->rx_bogusPacketOnRead);
157 fprintf(fs_outFD, "\t%10d rx_bogusHost\n", a_ovP->rx_bogusHost);
158 fprintf(fs_outFD, "\t%10d rx_noPacketOnRead\n", a_ovP->rx_noPacketOnRead);
159 fprintf(fs_outFD, "\t%10d rx_noPacketBuffersOnRead\n",
160 a_ovP->rx_noPacketBuffersOnRead);
161 fprintf(fs_outFD, "\t%10d rx_selects\n", a_ovP->rx_selects);
162 fprintf(fs_outFD, "\t%10d rx_sendSelects\n", a_ovP->rx_sendSelects);
163 fprintf(fs_outFD, "\t%10d rx_packetsRead_RcvClass\n",
164 a_ovP->rx_packetsRead_RcvClass);
165 fprintf(fs_outFD, "\t%10d rx_packetsRead_SendClass\n",
166 a_ovP->rx_packetsRead_SendClass);
167 fprintf(fs_outFD, "\t%10d rx_packetsRead_SpecialClass\n",
168 a_ovP->rx_packetsRead_SpecialClass);
169 fprintf(fs_outFD, "\t%10d rx_dataPacketsRead\n",
170 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",
174 a_ovP->rx_spuriousPacketsRead);
175 fprintf(fs_outFD, "\t%10d rx_packetsSent_RcvClass\n",
176 a_ovP->rx_packetsSent_RcvClass);
177 fprintf(fs_outFD, "\t%10d rx_packetsSent_SendClass\n",
178 a_ovP->rx_packetsSent_SendClass);
179 fprintf(fs_outFD, "\t%10d rx_packetsSent_SpecialClass\n",
180 a_ovP->rx_packetsSent_SpecialClass);
181 fprintf(fs_outFD, "\t%10d rx_ackPacketsSent\n", a_ovP->rx_ackPacketsSent);
182 fprintf(fs_outFD, "\t%10d rx_pingPacketsSent\n",
183 a_ovP->rx_pingPacketsSent);
184 fprintf(fs_outFD, "\t%10d rx_abortPacketsSent\n",
185 a_ovP->rx_abortPacketsSent);
186 fprintf(fs_outFD, "\t%10d rx_busyPacketsSent\n",
187 a_ovP->rx_busyPacketsSent);
188 fprintf(fs_outFD, "\t%10d rx_dataPacketsSent\n",
189 a_ovP->rx_dataPacketsSent);
190 fprintf(fs_outFD, "\t%10d rx_dataPacketsReSent\n",
191 a_ovP->rx_dataPacketsReSent);
192 fprintf(fs_outFD, "\t%10d rx_dataPacketsPushed\n",
193 a_ovP->rx_dataPacketsPushed);
194 fprintf(fs_outFD, "\t%10d rx_ignoreAckedPacket\n",
195 a_ovP->rx_ignoreAckedPacket);
196 fprintf(fs_outFD, "\t%10d rx_totalRtt_Sec\n", a_ovP->rx_totalRtt_Sec);
197 fprintf(fs_outFD, "\t%10d rx_totalRtt_Usec\n", a_ovP->rx_totalRtt_Usec);
198 fprintf(fs_outFD, "\t%10d rx_minRtt_Sec\n", a_ovP->rx_minRtt_Sec);
199 fprintf(fs_outFD, "\t%10d rx_minRtt_Usec\n", a_ovP->rx_minRtt_Usec);
200 fprintf(fs_outFD, "\t%10d rx_maxRtt_Sec\n", a_ovP->rx_maxRtt_Sec);
201 fprintf(fs_outFD, "\t%10d rx_maxRtt_Usec\n", a_ovP->rx_maxRtt_Usec);
202 fprintf(fs_outFD, "\t%10d rx_nRttSamples\n", a_ovP->rx_nRttSamples);
203 fprintf(fs_outFD, "\t%10d rx_nServerConns\n", a_ovP->rx_nServerConns);
204 fprintf(fs_outFD, "\t%10d rx_nClientConns\n", a_ovP->rx_nClientConns);
205 fprintf(fs_outFD, "\t%10d rx_nPeerStructs\n", a_ovP->rx_nPeerStructs);
206 fprintf(fs_outFD, "\t%10d rx_nCallStructs\n", a_ovP->rx_nCallStructs);
207 fprintf(fs_outFD, "\t%10d rx_nFreeCallStructs\n\n",
208 a_ovP->rx_nFreeCallStructs);
211 * Host module fields.
213 fprintf(fs_outFD, "\t%10d host_NumHostEntries\n",
214 a_ovP->host_NumHostEntries);
215 fprintf(fs_outFD, "\t%10d host_HostBlocks\n", a_ovP->host_HostBlocks);
216 fprintf(fs_outFD, "\t%10d host_NonDeletedHosts\n",
217 a_ovP->host_NonDeletedHosts);
218 fprintf(fs_outFD, "\t%10d host_HostsInSameNetOrSubnet\n",
219 a_ovP->host_HostsInSameNetOrSubnet);
220 fprintf(fs_outFD, "\t%10d host_HostsInDiffSubnet\n",
221 a_ovP->host_HostsInDiffSubnet);
222 fprintf(fs_outFD, "\t%10d host_HostsInDiffNetwork\n",
223 a_ovP->host_HostsInDiffNetwork);
224 fprintf(fs_outFD, "\t%10d host_NumClients\n", a_ovP->host_NumClients);
225 fprintf(fs_outFD, "\t%10d host_ClientBlocks\n\n",
226 a_ovP->host_ClientBlocks);
228 } /*Print_fs_OverallPerfInfo */
231 /*------------------------------------------------------------------------
235 * Print out the contents of an RPC op timing structure.
238 * a_opIdx : Index of the AFS operation we're printing number on.
239 * a_opTimeP : Ptr to the op timing structure to print.
245 * Nothing interesting.
249 *------------------------------------------------------------------------*/
252 Print_fs_OpTiming(int a_opIdx, struct fs_stats_opTimingData *a_opTimeP)
253 { /*Print_fs_OpTiming */
256 "%15s: %d ops (%d OK); sum=%ld.%06ld, min=%ld.%06ld, max=%ld.%06ld\n",
257 fsOpNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses,
258 (long)a_opTimeP->sumTime.tv_sec, (long)a_opTimeP->sumTime.tv_usec,
259 (long)a_opTimeP->minTime.tv_sec, (long)a_opTimeP->minTime.tv_usec,
260 (long)a_opTimeP->maxTime.tv_sec, (long)a_opTimeP->maxTime.tv_usec);
262 } /*Print_fs_OpTiming */
265 /*------------------------------------------------------------------------
266 * Print_fs_XferTiming
269 * Print out the contents of a data transfer structure.
272 * a_opIdx : Index of the AFS operation we're printing number on.
273 * a_xferP : Ptr to the data transfer structure to print.
279 * Nothing interesting.
283 *------------------------------------------------------------------------*/
286 Print_fs_XferTiming(int a_opIdx, struct fs_stats_xferData *a_xferP)
287 { /*Print_fs_XferTiming */
290 "%s: %d xfers (%d OK), time sum=%ld.%06ld, min=%ld.%06ld, max=%ld.%06ld\n",
291 xferOpNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses,
292 (long)a_xferP->sumTime.tv_sec, (long)a_xferP->sumTime.tv_usec,
293 (long)a_xferP->minTime.tv_sec, (long)a_xferP->minTime.tv_usec,
294 (long)a_xferP->maxTime.tv_sec, (long)a_xferP->maxTime.tv_usec);
295 fprintf(fs_outFD, "\t[bytes: sum=%d, min=%d, max=%d]\n",
296 a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
298 "\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
299 a_xferP->count[0], a_xferP->count[1], a_xferP->count[2],
300 a_xferP->count[3], a_xferP->count[4], a_xferP->count[5],
301 a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]);
303 } /*Print_fs_XferTiming */
306 /*------------------------------------------------------------------------
307 * Print_fs_DetailedPerfInfo
310 * Print out a set of detailed performance numbers.
313 * a_detP : Ptr to detailed perf numbers to print.
319 * Nothing interesting.
323 *------------------------------------------------------------------------*/
326 Print_fs_DetailedPerfInfo(struct fs_stats_DetailedStats *a_detP)
327 { /*Print_fs_DetailedPerfInfo */
329 int currIdx; /*Loop variable */
331 fprintf(fs_outFD, "\t%10ld epoch\n", (long)a_detP->epoch.tv_sec);
333 for (currIdx = 0; currIdx < FS_STATS_NUM_RPC_OPS; currIdx++)
334 Print_fs_OpTiming(currIdx, &(a_detP->rpcOpTimes[currIdx]));
336 for (currIdx = 0; currIdx < FS_STATS_NUM_XFER_OPS; currIdx++)
337 Print_fs_XferTiming(currIdx, &(a_detP->xferOpTimes[currIdx]));
339 } /*Print_fs_DetailedPerfInfo */
342 /*------------------------------------------------------------------------
343 * Print_fs_FullPerfInfo
346 * Print out the AFS_XSTATSCOLL_FULL_PERF_INFO collection we just
356 * All the info we need is nestled into xstat_fs_Results.
360 *------------------------------------------------------------------------*/
363 Print_fs_FullPerfInfo(struct xstat_fs_ProbeResults *a_fs_Results)
364 { /*Print_fs_FullPerfInfo */
365 static afs_int32 fullPerfLongs = (sizeof(struct fs_stats_FullPerfStats) >> 2); /*Correct # longs to rcv */
366 afs_int32 numLongs; /*# longwords received */
367 struct fs_stats_FullPerfStats *fullPerfP; /*Ptr to full perf stats */
368 char *printableTime; /*Ptr to printable time string */
372 probeTime = a_fs_Results->probeTime;
373 printableTime = ctime(&probeTime);
374 printableTime[strlen(printableTime) - 1] = '\0';
375 fullPerfP = (struct fs_stats_FullPerfStats *)
376 (a_fs_Results->data.AFS_CollData_val);
379 "AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n",
380 a_fs_Results->collectionNumber, a_fs_Results->connP->hostName,
381 a_fs_Results->probeNum, printableTime);
383 numLongs = a_fs_Results->data.AFS_CollData_len;
384 if (numLongs != fullPerfLongs) {
386 " ** Data size mismatch in full performance collection!\n");
387 fprintf(fs_outFD, " ** Expecting %d, got %d\n", fullPerfLongs,
390 /* Unfortunately, the full perf stats contain timeval structures which
391 * do not have the same size everywhere. At least try to print
394 if (numLongs >= (sizeof(struct afs_stats_CMPerf) / sizeof(afs_int32))) {
395 Print_fs_OverallPerfInfo(&(fullPerfP->overall));
398 Print_fs_OverallPerfInfo(&(fullPerfP->overall));
399 Print_fs_DetailedPerfInfo(&(fullPerfP->det));
402 } /*Print_fs_FullPerfInfo */
405 /*------------------------------------------------------------------------
409 * Prints the contents of xstat_fs_Results to an output file. The
410 * output is either in a compact (longs only) format or a detailed
411 * format giving the names of each of the datums. Output is appended.
414 * Name of output file.
415 * Flag to indicate if detailed output is required.
421 * All the info we need is nestled into xstat_fs_Results.
425 *------------------------------------------------------------------------*/
427 afsmon_fsOutput(char *a_outfile, /* ptr to output file name */
428 int a_detOutput) /* detailed output ? */
431 static char rn[] = "afsmon_fsOutput"; /* routine name */
432 char *printTime; /* ptr to time string */
433 char *hostname; /* fileserner name */
434 afs_int32 numLongs; /* longwords in result */
435 afs_int32 *currLong; /* ptr to longwords in result */
440 fprintf(debugFD, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
441 rn, a_outfile, a_detOutput);
445 fs_outFD = fopen(a_outfile, "a");
446 if (fs_outFD == (FILE *) 0) {
447 sprintf(errMsg, "[ %s ] failed to open output file %s", rn,
452 /* get the probe time and strip the \n at the end */
453 probeTime = xstat_fs_Results.probeTime;
454 printTime = ctime(&probeTime);
455 printTime[strlen(printTime) - 1] = '\0';
456 hostname = xstat_fs_Results.connP->hostName;
458 /* print "time hostname FS" */
459 fprintf(fs_outFD, "\n%s %s FS ", printTime, hostname);
461 /* if probe failed print -1 and return */
462 if (xstat_fs_Results.probeOK) {
463 fprintf(fs_outFD, "-1\n");
468 /* print out the probe information as long words */
469 numLongs = xstat_fs_Results.data.AFS_CollData_len;
470 currLong = (afs_int32 *) (xstat_fs_Results.data.AFS_CollData_val);
472 for (i = 0; i < numLongs; i++) {
473 fprintf(fs_outFD, "%d ", *currLong++);
475 fprintf(fs_outFD, "\n\n");
477 /* print detailed information */
479 Print_fs_FullPerfInfo(&xstat_fs_Results);
483 if (fclose(fs_outFD))
485 fprintf(debugFD, "[ %s ] failed to close %s\n", rn, a_outfile);
492 /*___________________________________________________________________________
494 *__________________________________________________________________________*/
498 /*------------------------------------------------------------------------
499 * Print_cm_UpDownStats
502 * Print the up/downtime stats for the given class of server records
506 * a_upDownP : Ptr to the server up/down info.
512 * Nothing interesting.
516 *------------------------------------------------------------------------*/
519 Print_cm_UpDownStats(struct afs_stats_SrvUpDownInfo *a_upDownP) /*Ptr to server up/down info */
520 { /*Print_cm_UpDownStats */
523 * First, print the simple values.
525 fprintf(cm_outFD, "\t\t%10d numTtlRecords\n", a_upDownP->numTtlRecords);
526 fprintf(cm_outFD, "\t\t%10d numUpRecords\n", a_upDownP->numUpRecords);
527 fprintf(cm_outFD, "\t\t%10d numDownRecords\n", a_upDownP->numDownRecords);
528 fprintf(cm_outFD, "\t\t%10d sumOfRecordAges\n",
529 a_upDownP->sumOfRecordAges);
530 fprintf(cm_outFD, "\t\t%10d ageOfYoungestRecord\n",
531 a_upDownP->ageOfYoungestRecord);
532 fprintf(cm_outFD, "\t\t%10d ageOfOldestRecord\n",
533 a_upDownP->ageOfOldestRecord);
534 fprintf(cm_outFD, "\t\t%10d numDowntimeIncidents\n",
535 a_upDownP->numDowntimeIncidents);
536 fprintf(cm_outFD, "\t\t%10d numRecordsNeverDown\n",
537 a_upDownP->numRecordsNeverDown);
538 fprintf(cm_outFD, "\t\t%10d maxDowntimesInARecord\n",
539 a_upDownP->maxDowntimesInARecord);
540 fprintf(cm_outFD, "\t\t%10d sumOfDowntimes\n", a_upDownP->sumOfDowntimes);
541 fprintf(cm_outFD, "\t\t%10d shortestDowntime\n",
542 a_upDownP->shortestDowntime);
543 fprintf(cm_outFD, "\t\t%10d longestDowntime\n",
544 a_upDownP->longestDowntime);
547 * Now, print the array values.
549 fprintf(cm_outFD, "\t\tDowntime duration distribution:\n");
550 fprintf(cm_outFD, "\t\t\t%8d: 0 min .. 10 min\n",
551 a_upDownP->downDurations[0]);
552 fprintf(cm_outFD, "\t\t\t%8d: 10 min .. 30 min\n",
553 a_upDownP->downDurations[1]);
554 fprintf(cm_outFD, "\t\t\t%8d: 30 min .. 1 hr\n",
555 a_upDownP->downDurations[2]);
556 fprintf(cm_outFD, "\t\t\t%8d: 1 hr .. 2 hr\n",
557 a_upDownP->downDurations[3]);
558 fprintf(cm_outFD, "\t\t\t%8d: 2 hr .. 4 hr\n",
559 a_upDownP->downDurations[4]);
560 fprintf(cm_outFD, "\t\t\t%8d: 4 hr .. 8 hr\n",
561 a_upDownP->downDurations[5]);
562 fprintf(cm_outFD, "\t\t\t%8d: > 8 hr\n", a_upDownP->downDurations[6]);
564 fprintf(cm_outFD, "\t\tDowntime incident distribution:\n");
565 fprintf(cm_outFD, "\t\t\t%8d: 0 times\n", a_upDownP->downIncidents[0]);
566 fprintf(cm_outFD, "\t\t\t%8d: 1 time\n", a_upDownP->downIncidents[1]);
567 fprintf(cm_outFD, "\t\t\t%8d: 2 .. 5 times\n",
568 a_upDownP->downIncidents[2]);
569 fprintf(cm_outFD, "\t\t\t%8d: 6 .. 10 times\n",
570 a_upDownP->downIncidents[3]);
571 fprintf(cm_outFD, "\t\t\t%8d: 10 .. 50 times\n",
572 a_upDownP->downIncidents[4]);
573 fprintf(cm_outFD, "\t\t\t%8d: > 50 times\n", a_upDownP->downIncidents[5]);
575 } /*Print_cm_UpDownStats */
578 /*------------------------------------------------------------------------
579 * Print_cm_OverallPerfInfo
582 * Print out overall performance numbers.
585 * a_ovP : Ptr to the overall performance numbers.
591 * All the info we need is nestled into xstat_cm_Results.
595 *------------------------------------------------------------------------*/
598 Print_cm_OverallPerfInfo(struct afs_stats_CMPerf *a_ovP)
599 { /*Print_cm_OverallPerfInfo */
601 fprintf(cm_outFD, "\t%10d numPerfCalls\n", a_ovP->numPerfCalls);
603 fprintf(cm_outFD, "\t%10d epoch\n", a_ovP->epoch);
604 fprintf(cm_outFD, "\t%10d numCellsVisible\n", a_ovP->numCellsVisible);
605 fprintf(cm_outFD, "\t%10d numCellsContacted\n", a_ovP->numCellsContacted);
606 fprintf(cm_outFD, "\t%10d dlocalAccesses\n", a_ovP->dlocalAccesses);
607 fprintf(cm_outFD, "\t%10d vlocalAccesses\n", a_ovP->vlocalAccesses);
608 fprintf(cm_outFD, "\t%10d dremoteAccesses\n", a_ovP->dremoteAccesses);
609 fprintf(cm_outFD, "\t%10d vremoteAccesses\n", a_ovP->vremoteAccesses);
610 fprintf(cm_outFD, "\t%10d cacheNumEntries\n", a_ovP->cacheNumEntries);
611 fprintf(cm_outFD, "\t%10d cacheBlocksTotal\n", a_ovP->cacheBlocksTotal);
612 fprintf(cm_outFD, "\t%10d cacheBlocksInUse\n", a_ovP->cacheBlocksInUse);
613 fprintf(cm_outFD, "\t%10d cacheBlocksOrig\n", a_ovP->cacheBlocksOrig);
614 fprintf(cm_outFD, "\t%10d cacheMaxDirtyChunks\n",
615 a_ovP->cacheMaxDirtyChunks);
616 fprintf(cm_outFD, "\t%10d cacheCurrDirtyChunks\n",
617 a_ovP->cacheCurrDirtyChunks);
618 fprintf(cm_outFD, "\t%10d dcacheHits\n", a_ovP->dcacheHits);
619 fprintf(cm_outFD, "\t%10d vcacheHits\n", a_ovP->vcacheHits);
620 fprintf(cm_outFD, "\t%10d dcacheMisses\n", a_ovP->dcacheMisses);
621 fprintf(cm_outFD, "\t%10d vcacheMisses\n", a_ovP->vcacheMisses);
622 fprintf(cm_outFD, "\t%10d cacheFilesReused\n", a_ovP->cacheFilesReused);
623 fprintf(cm_outFD, "\t%10d vcacheXAllocs\n", a_ovP->vcacheXAllocs);
625 fprintf(cm_outFD, "\t%10d bufAlloced\n", a_ovP->bufAlloced);
626 fprintf(cm_outFD, "\t%10d bufHits\n", a_ovP->bufHits);
627 fprintf(cm_outFD, "\t%10d bufMisses\n", a_ovP->bufMisses);
628 fprintf(cm_outFD, "\t%10d bufFlushDirty\n", a_ovP->bufFlushDirty);
630 fprintf(cm_outFD, "\t%10d LargeBlocksActive\n", a_ovP->LargeBlocksActive);
631 fprintf(cm_outFD, "\t%10d LargeBlocksAlloced\n",
632 a_ovP->LargeBlocksAlloced);
633 fprintf(cm_outFD, "\t%10d SmallBlocksActive\n", a_ovP->SmallBlocksActive);
634 fprintf(cm_outFD, "\t%10d SmallBlocksAlloced\n",
635 a_ovP->SmallBlocksAlloced);
636 fprintf(cm_outFD, "\t%10d OutStandingMemUsage\n",
637 a_ovP->OutStandingMemUsage);
638 fprintf(cm_outFD, "\t%10d OutStandingAllocs\n", a_ovP->OutStandingAllocs);
639 fprintf(cm_outFD, "\t%10d CallBackAlloced\n", a_ovP->CallBackAlloced);
640 fprintf(cm_outFD, "\t%10d CallBackFlushes\n", a_ovP->CallBackFlushes);
642 fprintf(cm_outFD, "\t%10d srvRecords\n", a_ovP->srvRecords);
643 fprintf(cm_outFD, "\t%10d srvNumBuckets\n", a_ovP->srvNumBuckets);
644 fprintf(cm_outFD, "\t%10d srvMaxChainLength\n", a_ovP->srvMaxChainLength);
645 fprintf(cm_outFD, "\t%10d srvMaxChainLengthHWM\n",
646 a_ovP->srvMaxChainLengthHWM);
647 fprintf(cm_outFD, "\t%10d srvRecordsHWM\n", a_ovP->srvRecordsHWM);
649 fprintf(cm_outFD, "\t%10d sysName_ID\n", a_ovP->sysName_ID);
651 fprintf(cm_outFD, "\tFile Server up/downtimes, same cell:\n");
652 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[0]));
654 fprintf(cm_outFD, "\tFile Server up/downtimes, diff cell:\n");
655 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[1]));
657 fprintf(cm_outFD, "\tVL Server up/downtimes, same cell:\n");
658 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[0]));
660 fprintf(cm_outFD, "\tVL Server up/downtimes, diff cell:\n");
661 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[1]));
663 } /*Print_cm_OverallPerfInfo */
666 /*------------------------------------------------------------------------
670 * Print out the AFSCB_XSTATSCOLL_PERF_INFO collection we just
680 * All the info we need is nestled into xstat_cm_Results.
684 *------------------------------------------------------------------------*/
687 Print_cm_PerfInfo(void)
688 { /*Print_cm_PerfInfo */
689 static afs_int32 perfLongs = (sizeof(struct afs_stats_CMPerf) >> 2); /*Correct # longs to rcv */
690 afs_int32 numLongs; /*# longwords received */
691 struct afs_stats_CMPerf *perfP; /*Ptr to performance stats */
692 char *printableTime; /*Ptr to printable time string */
695 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
696 if (numLongs != perfLongs) {
698 " ** Data size mismatch in performance collection!\n");
699 fprintf(cm_outFD, "** Expecting %d, got %d\n", perfLongs, numLongs);
703 probeTime = xstat_cm_Results.probeTime;
704 printableTime = ctime(&probeTime);
705 printableTime[strlen(printableTime) - 1] = '\0';
706 perfP = (struct afs_stats_CMPerf *)
707 (xstat_cm_Results.data.AFSCB_CollData_val);
710 "AFSCB_XSTATSCOLL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
711 xstat_cm_Results.collectionNumber,
712 xstat_cm_Results.connP->hostName, xstat_cm_Results.probeNum,
715 Print_cm_OverallPerfInfo(perfP);
717 } /*Print_cm_PerfInfo */
720 /*------------------------------------------------------------------------
724 * Print out the contents of an FS RPC op timing structure.
727 * a_opIdx : Index of the AFS operation we're printing number on.
728 * a_opNames : Ptr to table of operaton names.
729 * a_opTimeP : Ptr to the op timing structure to print.
735 * Nothing interesting.
739 *------------------------------------------------------------------------*/
742 Print_cm_OpTiming(int a_opIdx, char *a_opNames[],
743 struct afs_stats_opTimingData *a_opTimeP)
744 { /*Print_cm_OpTiming */
747 "%15s: %d ops (%d OK); sum=%ld.%06ld, min=%ld.%06ld, max=%ld.%06ld\n",
748 a_opNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses,
749 (long)a_opTimeP->sumTime.tv_sec, (long)a_opTimeP->sumTime.tv_usec,
750 (long)a_opTimeP->minTime.tv_sec, (long)a_opTimeP->minTime.tv_usec,
751 (long)a_opTimeP->maxTime.tv_sec, (long)a_opTimeP->maxTime.tv_usec);
753 } /*Print_cm_OpTiming */
756 /*------------------------------------------------------------------------
757 * Print_cm_XferTiming
760 * Print out the contents of a data transfer structure.
763 * a_opIdx : Index of the AFS operation we're printing number on.
764 * a_xferP : Ptr to the data transfer structure to print.
770 * Nothing interesting.
774 *------------------------------------------------------------------------*/
777 Print_cm_XferTiming(int a_opIdx, char *a_opNames[],
778 struct afs_stats_xferData *a_xferP)
779 { /*Print_cm_XferTiming */
782 "%s: %d xfers (%d OK), time sum=%ld.%06ld, min=%ld.%06ld, max=%ld.%06ld\n",
783 a_opNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses,
784 (long)a_xferP->sumTime.tv_sec, (long)a_xferP->sumTime.tv_usec,
785 (long)a_xferP->minTime.tv_sec, (long)a_xferP->minTime.tv_usec,
786 (long)a_xferP->maxTime.tv_sec, (long)a_xferP->maxTime.tv_usec);
787 fprintf(cm_outFD, "\t[bytes: sum=%d, min=%d, max=%d]\n",
788 a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
790 "\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
791 a_xferP->count[0], a_xferP->count[1], a_xferP->count[2],
792 a_xferP->count[3], a_xferP->count[4], a_xferP->count[5],
793 a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]);
795 } /*Print_cm_XferTiming */
798 /*------------------------------------------------------------------------
802 * Print out the contents of an FS RPC error info structure.
805 * a_opIdx : Index of the AFS operation we're printing.
806 * a_opNames : Ptr to table of operation names.
807 * a_opErrP : Ptr to the op timing structure to print.
813 * Nothing interesting.
817 *------------------------------------------------------------------------*/
820 Print_cm_ErrInfo(int a_opIdx, char *a_opNames[],
821 struct afs_stats_RPCErrors *a_opErrP)
822 { /*Print_cm_ErrInfo */
825 "%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n",
826 a_opNames[a_opIdx], a_opErrP->err_Server, a_opErrP->err_Network,
827 a_opErrP->err_Protection, a_opErrP->err_Volume,
828 a_opErrP->err_VolumeBusies, a_opErrP->err_Other);
830 } /*Print_cm_ErrInfo */
833 /*------------------------------------------------------------------------
834 * Print_cm_RPCPerfInfo
837 * Print out a set of RPC performance numbers.
840 * a_rpcP : Ptr to RPC perf numbers to print.
846 * Nothing interesting.
850 *------------------------------------------------------------------------*/
853 Print_cm_RPCPerfInfo(struct afs_stats_RPCOpInfo *a_rpcP)
854 { /*Print_cm_RPCPerfInfo */
856 int currIdx; /*Loop variable */
859 * Print the contents of each of the opcode-related arrays.
861 fprintf(cm_outFD, "FS Operation Timings:\n---------------------\n");
862 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
863 Print_cm_OpTiming(currIdx, fsOpNames, &(a_rpcP->fsRPCTimes[currIdx]));
865 fprintf(cm_outFD, "\nError Info:\n-----------\n");
866 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
867 Print_cm_ErrInfo(currIdx, fsOpNames, &(a_rpcP->fsRPCErrors[currIdx]));
869 fprintf(cm_outFD, "\nTransfer timings:\n-----------------\n");
870 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++)
871 Print_cm_XferTiming(currIdx, xferOpNames,
872 &(a_rpcP->fsXferTimes[currIdx]));
874 fprintf(cm_outFD, "\nCM Operation Timings:\n---------------------\n");
875 for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++)
876 Print_cm_OpTiming(currIdx, cmOpNames, &(a_rpcP->cmRPCTimes[currIdx]));
878 } /*Print_cm_RPCPerfInfo */
881 /*------------------------------------------------------------------------
882 * Print_cm_FullPerfInfo
885 * Print out a set of full performance numbers.
894 * Nothing interesting.
898 *------------------------------------------------------------------------*/
901 Print_cm_FullPerfInfo(void)
902 { /*Print_cm_FullPerfInfo */
904 struct afs_stats_AuthentInfo *authentP; /*Ptr to authentication stats */
905 struct afs_stats_AccessInfo *accessinfP; /*Ptr to access stats */
906 static afs_int32 fullPerfLongs = (sizeof(struct afs_stats_CMFullPerf) >> 2); /*Correct #longs */
907 afs_int32 numLongs; /*# longs actually received */
908 struct afs_stats_CMFullPerf *fullP; /*Ptr to full perf info */
910 char *printableTime; /*Ptr to printable time string */
912 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
913 if (numLongs != fullPerfLongs) {
915 " ** Data size mismatch in performance collection!\n");
916 fprintf(cm_outFD, " ** Expecting %d, got %d\n", fullPerfLongs,
921 probeTime = xstat_cm_Results.probeTime;
922 printableTime = ctime(&probeTime);
923 printableTime[strlen(printableTime) - 1] = '\0';
924 fullP = (struct afs_stats_CMFullPerf *)
925 (xstat_cm_Results.data.AFSCB_CollData_val);
928 "AFSCB_XSTATSCOLL_FULL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
929 xstat_cm_Results.collectionNumber,
930 xstat_cm_Results.connP->hostName, xstat_cm_Results.probeNum,
934 * Print the overall numbers first, followed by all of the RPC numbers,
935 * then each of the other groupings.
938 "Overall Performance Info:\n-------------------------\n");
939 Print_cm_OverallPerfInfo(&(fullP->perf));
940 fprintf(cm_outFD, "\n");
941 Print_cm_RPCPerfInfo(&(fullP->rpc));
943 authentP = &(fullP->authent);
944 fprintf(cm_outFD, "\nAuthentication info:\n--------------------\n");
946 "\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n",
947 authentP->curr_PAGs, authentP->curr_Records,
948 authentP->curr_AuthRecords, authentP->curr_UnauthRecords,
949 authentP->curr_MaxRecordsInPAG, authentP->curr_LongestChain);
950 fprintf(cm_outFD, "\t%d PAG creations, %d tkt updates\n",
951 authentP->PAGCreations, authentP->TicketUpdates);
953 "\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n",
954 authentP->HWM_PAGs, authentP->HWM_Records,
955 authentP->HWM_MaxRecordsInPAG, authentP->HWM_LongestChain);
957 accessinfP = &(fullP->accessinf);
959 "\n[Un]replicated accesses:\n------------------------\n");
961 "\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n",
962 accessinfP->unreplicatedRefs, accessinfP->replicatedRefs,
963 accessinfP->numReplicasAccessed, accessinfP->maxReplicasPerRef,
964 accessinfP->refFirstReplicaOK);
966 /* There really isn't any authorship info
967 * authorP = &(fullP->author); */
969 } /*Print_cm_FullPerfInfo */
971 /*------------------------------------------------------------------------
975 * Prints the contents of xstat_cm_Results to an output file. The
976 * output is either in a compact (longs only) format or a detailed
977 * format giving the names of each of the datums. Output is appended.
980 * Name of output file.
981 * Flag to indicate if detailed output is required.
987 * All the info we need is nestled into xstat_cm_Results.
991 *------------------------------------------------------------------------*/
993 afsmon_cmOutput(char *a_outfile, /* ptr to output file name */
994 int a_detOutput) /* detailed output ? */
997 static char rn[] = "afsmon_cmOutput"; /* routine name */
998 char *printTime; /* ptr to time string */
999 char *hostname; /* fileserner name */
1000 afs_int32 numLongs; /* longwords in result */
1001 afs_int32 *currLong; /* ptr to longwords in result */
1006 fprintf(debugFD, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
1007 rn, a_outfile, a_detOutput);
1011 /* need to lock this file before writing */
1012 cm_outFD = fopen(a_outfile, "a");
1013 if (cm_outFD == (FILE *) 0) {
1014 sprintf(errMsg, "[ %s ] failed to open output file %s", rn,
1019 /* get the probe time and strip the \n at the end */
1020 probeTime = xstat_cm_Results.probeTime;
1021 printTime = ctime(&probeTime);
1022 printTime[strlen(printTime) - 1] = '\0';
1023 hostname = xstat_cm_Results.connP->hostName;
1025 /* print "time hostname CM" prefix */
1026 fprintf(cm_outFD, "\n%s %s CM ", printTime, hostname);
1028 /* if probe failed print -1 and vanish */
1029 if (xstat_cm_Results.probeOK) {
1030 fprintf(cm_outFD, "-1\n");
1035 /* print out the probe information as long words */
1036 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
1037 currLong = (afs_int32 *) (xstat_cm_Results.data.AFSCB_CollData_val);
1039 for (i = 0; i < numLongs; i++) {
1040 fprintf(cm_outFD, "%d ", *currLong++);
1042 fprintf(cm_outFD, "\n\n");
1044 /* print out detailed statistics */
1046 Print_cm_FullPerfInfo();
1050 if (fclose(cm_outFD))
1052 fprintf(debugFD, "[ %s ] failed to close %s\n", rn, a_outfile);