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 static char *CbCounterStrings[] = {
106 /*________________________________________________________________________
108 *_______________________________________________________________________*/
110 /*------------------------------------------------------------------------
111 * Print_fs_OverallPerfInfo
114 * Print out overall performance numbers.
117 * a_ovP : Ptr to the overall performance numbers.
123 * Nothing interesting.
127 *------------------------------------------------------------------------*/
130 Print_fs_OverallPerfInfo(struct afs_PerfStats *a_ovP)
131 { /*Print_fs_OverallPerfInfo */
133 fprintf(fs_outFD, "\t%10d numPerfCalls\n\n", a_ovP->numPerfCalls);
137 * Vnode cache section.
139 fprintf(fs_outFD, "\t%10d vcache_L_Entries\n", a_ovP->vcache_L_Entries);
140 fprintf(fs_outFD, "\t%10d vcache_L_Allocs\n", a_ovP->vcache_L_Allocs);
141 fprintf(fs_outFD, "\t%10d vcache_L_Gets\n", a_ovP->vcache_L_Gets);
142 fprintf(fs_outFD, "\t%10d vcache_L_Reads\n", a_ovP->vcache_L_Reads);
143 fprintf(fs_outFD, "\t%10d vcache_L_Writes\n\n", a_ovP->vcache_L_Writes);
145 fprintf(fs_outFD, "\t%10d vcache_S_Entries\n", a_ovP->vcache_S_Entries);
146 fprintf(fs_outFD, "\t%10d vcache_S_Allocs\n", a_ovP->vcache_S_Allocs);
147 fprintf(fs_outFD, "\t%10d vcache_S_Gets\n", a_ovP->vcache_S_Gets);
148 fprintf(fs_outFD, "\t%10d vcache_S_Reads\n", a_ovP->vcache_S_Reads);
149 fprintf(fs_outFD, "\t%10d vcache_S_Writes\n\n", a_ovP->vcache_S_Writes);
151 fprintf(fs_outFD, "\t%10d vcache_H_Entries\n", a_ovP->vcache_H_Entries);
152 fprintf(fs_outFD, "\t%10d vcache_H_Gets\n", a_ovP->vcache_H_Gets);
153 fprintf(fs_outFD, "\t%10d vcache_H_Replacements\n\n",
154 a_ovP->vcache_H_Replacements);
157 * Directory package section.
159 fprintf(fs_outFD, "\t%10d dir_Buffers\n", a_ovP->dir_Buffers);
160 fprintf(fs_outFD, "\t%10d dir_Calls\n", a_ovP->dir_Calls);
161 fprintf(fs_outFD, "\t%10d dir_IOs\n\n", a_ovP->dir_IOs);
166 fprintf(fs_outFD, "\t%10d rx_packetRequests\n", a_ovP->rx_packetRequests);
167 fprintf(fs_outFD, "\t%10d rx_noPackets_RcvClass\n",
168 a_ovP->rx_noPackets_RcvClass);
169 fprintf(fs_outFD, "\t%10d rx_noPackets_SendClass\n",
170 a_ovP->rx_noPackets_SendClass);
171 fprintf(fs_outFD, "\t%10d rx_noPackets_SpecialClass\n",
172 a_ovP->rx_noPackets_SpecialClass);
173 fprintf(fs_outFD, "\t%10d rx_socketGreedy\n", a_ovP->rx_socketGreedy);
174 fprintf(fs_outFD, "\t%10d rx_bogusPacketOnRead\n",
175 a_ovP->rx_bogusPacketOnRead);
176 fprintf(fs_outFD, "\t%10d rx_bogusHost\n", a_ovP->rx_bogusHost);
177 fprintf(fs_outFD, "\t%10d rx_noPacketOnRead\n", a_ovP->rx_noPacketOnRead);
178 fprintf(fs_outFD, "\t%10d rx_noPacketBuffersOnRead\n",
179 a_ovP->rx_noPacketBuffersOnRead);
180 fprintf(fs_outFD, "\t%10d rx_selects\n", a_ovP->rx_selects);
181 fprintf(fs_outFD, "\t%10d rx_sendSelects\n", a_ovP->rx_sendSelects);
182 fprintf(fs_outFD, "\t%10d rx_packetsRead_RcvClass\n",
183 a_ovP->rx_packetsRead_RcvClass);
184 fprintf(fs_outFD, "\t%10d rx_packetsRead_SendClass\n",
185 a_ovP->rx_packetsRead_SendClass);
186 fprintf(fs_outFD, "\t%10d rx_packetsRead_SpecialClass\n",
187 a_ovP->rx_packetsRead_SpecialClass);
188 fprintf(fs_outFD, "\t%10d rx_dataPacketsRead\n",
189 a_ovP->rx_dataPacketsRead);
190 fprintf(fs_outFD, "\t%10d rx_ackPacketsRead\n", a_ovP->rx_ackPacketsRead);
191 fprintf(fs_outFD, "\t%10d rx_dupPacketsRead\n", a_ovP->rx_dupPacketsRead);
192 fprintf(fs_outFD, "\t%10d rx_spuriousPacketsRead\n",
193 a_ovP->rx_spuriousPacketsRead);
194 fprintf(fs_outFD, "\t%10d rx_packetsSent_RcvClass\n",
195 a_ovP->rx_packetsSent_RcvClass);
196 fprintf(fs_outFD, "\t%10d rx_packetsSent_SendClass\n",
197 a_ovP->rx_packetsSent_SendClass);
198 fprintf(fs_outFD, "\t%10d rx_packetsSent_SpecialClass\n",
199 a_ovP->rx_packetsSent_SpecialClass);
200 fprintf(fs_outFD, "\t%10d rx_ackPacketsSent\n", a_ovP->rx_ackPacketsSent);
201 fprintf(fs_outFD, "\t%10d rx_pingPacketsSent\n",
202 a_ovP->rx_pingPacketsSent);
203 fprintf(fs_outFD, "\t%10d rx_abortPacketsSent\n",
204 a_ovP->rx_abortPacketsSent);
205 fprintf(fs_outFD, "\t%10d rx_busyPacketsSent\n",
206 a_ovP->rx_busyPacketsSent);
207 fprintf(fs_outFD, "\t%10d rx_dataPacketsSent\n",
208 a_ovP->rx_dataPacketsSent);
209 fprintf(fs_outFD, "\t%10d rx_dataPacketsReSent\n",
210 a_ovP->rx_dataPacketsReSent);
211 fprintf(fs_outFD, "\t%10d rx_dataPacketsPushed\n",
212 a_ovP->rx_dataPacketsPushed);
213 fprintf(fs_outFD, "\t%10d rx_ignoreAckedPacket\n",
214 a_ovP->rx_ignoreAckedPacket);
215 fprintf(fs_outFD, "\t%10d rx_totalRtt_Sec\n", a_ovP->rx_totalRtt_Sec);
216 fprintf(fs_outFD, "\t%10d rx_totalRtt_Usec\n", a_ovP->rx_totalRtt_Usec);
217 fprintf(fs_outFD, "\t%10d rx_minRtt_Sec\n", a_ovP->rx_minRtt_Sec);
218 fprintf(fs_outFD, "\t%10d rx_minRtt_Usec\n", a_ovP->rx_minRtt_Usec);
219 fprintf(fs_outFD, "\t%10d rx_maxRtt_Sec\n", a_ovP->rx_maxRtt_Sec);
220 fprintf(fs_outFD, "\t%10d rx_maxRtt_Usec\n", a_ovP->rx_maxRtt_Usec);
221 fprintf(fs_outFD, "\t%10d rx_nRttSamples\n", a_ovP->rx_nRttSamples);
222 fprintf(fs_outFD, "\t%10d rx_nServerConns\n", a_ovP->rx_nServerConns);
223 fprintf(fs_outFD, "\t%10d rx_nClientConns\n", a_ovP->rx_nClientConns);
224 fprintf(fs_outFD, "\t%10d rx_nPeerStructs\n", a_ovP->rx_nPeerStructs);
225 fprintf(fs_outFD, "\t%10d rx_nCallStructs\n", a_ovP->rx_nCallStructs);
226 fprintf(fs_outFD, "\t%10d rx_nFreeCallStructs\n",
227 a_ovP->rx_nFreeCallStructs);
228 fprintf(fs_outFD, "\t%10d rx_nBusies\n\n", a_ovP->rx_nBusies);
230 fprintf(fs_outFD, "\t%10d fs_nBusies\n", a_ovP->fs_nBusies);
231 fprintf(fs_outFD, "\t%10d fs_GetCapabilities\n\n", a_ovP->fs_nGetCaps);
234 * Host module fields.
236 fprintf(fs_outFD, "\t%10d host_NumHostEntries\n",
237 a_ovP->host_NumHostEntries);
238 fprintf(fs_outFD, "\t%10d host_HostBlocks\n", a_ovP->host_HostBlocks);
239 fprintf(fs_outFD, "\t%10d host_NonDeletedHosts\n",
240 a_ovP->host_NonDeletedHosts);
241 fprintf(fs_outFD, "\t%10d host_HostsInSameNetOrSubnet\n",
242 a_ovP->host_HostsInSameNetOrSubnet);
243 fprintf(fs_outFD, "\t%10d host_HostsInDiffSubnet\n",
244 a_ovP->host_HostsInDiffSubnet);
245 fprintf(fs_outFD, "\t%10d host_HostsInDiffNetwork\n",
246 a_ovP->host_HostsInDiffNetwork);
247 fprintf(fs_outFD, "\t%10d host_NumClients\n", a_ovP->host_NumClients);
248 fprintf(fs_outFD, "\t%10d host_ClientBlocks\n\n",
249 a_ovP->host_ClientBlocks);
251 fprintf(fs_outFD, "\t%10d sysname_ID\n", a_ovP->sysname_ID);
252 } /*Print_fs_OverallPerfInfo */
255 /*------------------------------------------------------------------------
259 * Print out the contents of an RPC op timing structure.
262 * a_opIdx : Index of the AFS operation we're printing number on.
263 * a_opTimeP : Ptr to the op timing structure to print.
269 * Nothing interesting.
273 *------------------------------------------------------------------------*/
276 Print_fs_OpTiming(int a_opIdx, struct fs_stats_opTimingData *a_opTimeP)
277 { /*Print_fs_OpTiming */
280 "%15s: %d ops (%d OK); sum=%ld.%06ld, min=%ld.%06ld, max=%ld.%06ld\n",
281 fsOpNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses,
282 (long)a_opTimeP->sumTime.tv_sec, (long)a_opTimeP->sumTime.tv_usec,
283 (long)a_opTimeP->minTime.tv_sec, (long)a_opTimeP->minTime.tv_usec,
284 (long)a_opTimeP->maxTime.tv_sec, (long)a_opTimeP->maxTime.tv_usec);
286 } /*Print_fs_OpTiming */
289 /*------------------------------------------------------------------------
290 * Print_fs_XferTiming
293 * Print out the contents of a data transfer structure.
296 * a_opIdx : Index of the AFS operation we're printing number on.
297 * a_xferP : Ptr to the data transfer structure to print.
303 * Nothing interesting.
307 *------------------------------------------------------------------------*/
310 Print_fs_XferTiming(int a_opIdx, struct fs_stats_xferData *a_xferP)
311 { /*Print_fs_XferTiming */
314 "%s: %d xfers (%d OK), time sum=%ld.%06ld, min=%ld.%06ld, max=%ld.%06ld\n",
315 xferOpNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses,
316 (long)a_xferP->sumTime.tv_sec, (long)a_xferP->sumTime.tv_usec,
317 (long)a_xferP->minTime.tv_sec, (long)a_xferP->minTime.tv_usec,
318 (long)a_xferP->maxTime.tv_sec, (long)a_xferP->maxTime.tv_usec);
319 fprintf(fs_outFD, "\t[bytes: sum=%d, min=%d, max=%d]\n",
320 a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
322 "\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
323 a_xferP->count[0], a_xferP->count[1], a_xferP->count[2],
324 a_xferP->count[3], a_xferP->count[4], a_xferP->count[5],
325 a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]);
327 } /*Print_fs_XferTiming */
330 /*------------------------------------------------------------------------
331 * Print_fs_DetailedPerfInfo
334 * Print out a set of detailed performance numbers.
337 * a_detP : Ptr to detailed perf numbers to print.
343 * Nothing interesting.
347 *------------------------------------------------------------------------*/
350 Print_fs_DetailedPerfInfo(struct fs_stats_DetailedStats *a_detP)
351 { /*Print_fs_DetailedPerfInfo */
353 int currIdx; /*Loop variable */
355 fprintf(fs_outFD, "\t%10ld epoch\n", (long)a_detP->epoch.tv_sec);
357 for (currIdx = 0; currIdx < FS_STATS_NUM_RPC_OPS; currIdx++)
358 Print_fs_OpTiming(currIdx, &(a_detP->rpcOpTimes[currIdx]));
360 for (currIdx = 0; currIdx < FS_STATS_NUM_XFER_OPS; currIdx++)
361 Print_fs_XferTiming(currIdx, &(a_detP->xferOpTimes[currIdx]));
363 } /*Print_fs_DetailedPerfInfo */
366 /*------------------------------------------------------------------------
367 * Print_fs_FullPerfInfo
370 * Print out the AFS_XSTATSCOLL_FULL_PERF_INFO collection we just
380 * All the info we need is nestled into xstat_fs_Results.
384 *------------------------------------------------------------------------*/
387 Print_fs_FullPerfInfo(struct xstat_fs_ProbeResults *a_fs_Results)
388 { /*Print_fs_FullPerfInfo */
389 static afs_int32 fullPerfLongs = (sizeof(struct fs_stats_FullPerfStats) >> 2); /*Correct # longs to rcv */
390 afs_int32 numLongs; /*# longwords received */
391 struct fs_stats_FullPerfStats *fullPerfP; /*Ptr to full perf stats */
392 struct fs_stats_FullPerfStats buffer;
393 char *printableTime; /*Ptr to printable time string */
398 probeTime = a_fs_Results->probeTime;
399 printableTime = ctime(&probeTime);
400 printableTime[strlen(printableTime) - 1] = '\0';
403 "AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n",
404 a_fs_Results->collectionNumber, a_fs_Results->connP->hostName,
405 a_fs_Results->probeNum, printableTime);
407 code = xstat_fs_DecodeFullPerfStats(&fullPerfP,
408 a_fs_Results->data.AFS_CollData_val,
409 a_fs_Results->data.AFS_CollData_len,
412 numLongs = a_fs_Results->data.AFS_CollData_len;
414 " ** Data size mismatch in full performance collection!\n");
415 fprintf(fs_outFD, " ** Expecting %d, got %d\n", fullPerfLongs,
419 Print_fs_OverallPerfInfo(&(fullPerfP->overall));
420 Print_fs_DetailedPerfInfo(&(fullPerfP->det));
423 } /*Print_fs_FullPerfInfo */
425 /*------------------------------------------------------------------------
426 * Print_fs_CallbackStats
429 * Print out the AFS_XSTATSCOLL_CBSTATS collection we just
439 * All the info we need is nestled into xstat_fs_Results.
443 *------------------------------------------------------------------------*/
445 Print_fs_CallBackStats(struct xstat_fs_ProbeResults *a_fs_Results)
449 int numInt32s = xstat_fs_Results.data.AFS_CollData_len;
450 afs_int32 *val = xstat_fs_Results.data.AFS_CollData_val;
453 probeTime = a_fs_Results->probeTime;
454 printableTime = ctime(&probeTime);
455 printableTime[strlen(printableTime) - 1] = '\0';
457 "AFS_XSTATSCOLL_CBSTATS (coll %d) for FS %s\n[Probe %d, %s]\n\n",
458 a_fs_Results->collectionNumber, a_fs_Results->connP->hostName,
459 a_fs_Results->probeNum, printableTime);
461 numInt32s = min(numInt32s, sizeof(CbCounterStrings)/sizeof(*CbCounterStrings));
462 for (i=0; i<numInt32s; i++) {
463 fprintf(fs_outFD, "\t%10u %s\n", val[i], CbCounterStrings[i]);
465 } /*Print_fs_CallbackStats */
467 /*------------------------------------------------------------------------
471 * Prints the contents of xstat_fs_Results to an output file. The
472 * output is either in a compact (longs only) format or a detailed
473 * format giving the names of each of the datums. Output is appended.
476 * Name of output file.
477 * Flag to indicate if detailed output is required.
483 * All the info we need is nestled into xstat_fs_Results.
487 *------------------------------------------------------------------------*/
489 afsmon_fsOutput(char *a_outfile, /* ptr to output file name */
490 int a_detOutput) /* detailed output ? */
493 static char rn[] = "afsmon_fsOutput"; /* routine name */
494 char *printTime; /* ptr to time string */
495 char *hostname; /* fileserner name */
496 afs_int32 numLongs; /* longwords in result */
497 afs_int32 *currLong; /* ptr to longwords in result */
502 fprintf(debugFD, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
503 rn, a_outfile, a_detOutput);
507 fs_outFD = fopen(a_outfile, "a");
508 if (fs_outFD == (FILE *) 0) {
509 sprintf(errMsg, "[ %s ] failed to open output file %s", rn,
514 /* get the probe time and strip the \n at the end */
515 probeTime = xstat_fs_Results.probeTime;
516 printTime = ctime(&probeTime);
517 printTime[strlen(printTime) - 1] = '\0';
518 hostname = xstat_fs_Results.connP->hostName;
520 /* print "time hostname FS" */
521 fprintf(fs_outFD, "\n%s %s FS ", printTime, hostname);
523 /* if probe failed print -1 and return */
524 if (xstat_fs_Results.probeOK) {
525 fprintf(fs_outFD, "-1\n");
530 /* print out the probe information as long words */
531 numLongs = xstat_fs_Results.data.AFS_CollData_len;
532 currLong = (afs_int32 *) (xstat_fs_Results.data.AFS_CollData_val);
534 for (i = 0; i < numLongs; i++) {
535 fprintf(fs_outFD, "%d ", *currLong++);
537 fprintf(fs_outFD, "\n\n");
539 /* print detailed information */
541 if (xstat_fs_Results.collectionNumber ==
542 AFS_XSTATSCOLL_FULL_PERF_INFO) {
543 Print_fs_FullPerfInfo(&xstat_fs_Results);
545 } else if (xstat_fs_Results.collectionNumber ==
546 AFS_XSTATSCOLL_CBSTATS) {
547 Print_fs_CallBackStats(&xstat_fs_Results);
552 if (fclose(fs_outFD))
554 fprintf(debugFD, "[ %s ] failed to close %s\n", rn, a_outfile);
561 /*___________________________________________________________________________
563 *__________________________________________________________________________*/
567 /*------------------------------------------------------------------------
568 * Print_cm_UpDownStats
571 * Print the up/downtime stats for the given class of server records
575 * a_upDownP : Ptr to the server up/down info.
581 * Nothing interesting.
585 *------------------------------------------------------------------------*/
588 Print_cm_UpDownStats(struct afs_stats_SrvUpDownInfo *a_upDownP) /*Ptr to server up/down info */
589 { /*Print_cm_UpDownStats */
592 * First, print the simple values.
594 fprintf(cm_outFD, "\t\t%10d numTtlRecords\n", a_upDownP->numTtlRecords);
595 fprintf(cm_outFD, "\t\t%10d numUpRecords\n", a_upDownP->numUpRecords);
596 fprintf(cm_outFD, "\t\t%10d numDownRecords\n", a_upDownP->numDownRecords);
597 fprintf(cm_outFD, "\t\t%10d sumOfRecordAges\n",
598 a_upDownP->sumOfRecordAges);
599 fprintf(cm_outFD, "\t\t%10d ageOfYoungestRecord\n",
600 a_upDownP->ageOfYoungestRecord);
601 fprintf(cm_outFD, "\t\t%10d ageOfOldestRecord\n",
602 a_upDownP->ageOfOldestRecord);
603 fprintf(cm_outFD, "\t\t%10d numDowntimeIncidents\n",
604 a_upDownP->numDowntimeIncidents);
605 fprintf(cm_outFD, "\t\t%10d numRecordsNeverDown\n",
606 a_upDownP->numRecordsNeverDown);
607 fprintf(cm_outFD, "\t\t%10d maxDowntimesInARecord\n",
608 a_upDownP->maxDowntimesInARecord);
609 fprintf(cm_outFD, "\t\t%10d sumOfDowntimes\n", a_upDownP->sumOfDowntimes);
610 fprintf(cm_outFD, "\t\t%10d shortestDowntime\n",
611 a_upDownP->shortestDowntime);
612 fprintf(cm_outFD, "\t\t%10d longestDowntime\n",
613 a_upDownP->longestDowntime);
616 * Now, print the array values.
618 fprintf(cm_outFD, "\t\tDowntime duration distribution:\n");
619 fprintf(cm_outFD, "\t\t\t%8d: 0 min .. 10 min\n",
620 a_upDownP->downDurations[0]);
621 fprintf(cm_outFD, "\t\t\t%8d: 10 min .. 30 min\n",
622 a_upDownP->downDurations[1]);
623 fprintf(cm_outFD, "\t\t\t%8d: 30 min .. 1 hr\n",
624 a_upDownP->downDurations[2]);
625 fprintf(cm_outFD, "\t\t\t%8d: 1 hr .. 2 hr\n",
626 a_upDownP->downDurations[3]);
627 fprintf(cm_outFD, "\t\t\t%8d: 2 hr .. 4 hr\n",
628 a_upDownP->downDurations[4]);
629 fprintf(cm_outFD, "\t\t\t%8d: 4 hr .. 8 hr\n",
630 a_upDownP->downDurations[5]);
631 fprintf(cm_outFD, "\t\t\t%8d: > 8 hr\n", a_upDownP->downDurations[6]);
633 fprintf(cm_outFD, "\t\tDowntime incident distribution:\n");
634 fprintf(cm_outFD, "\t\t\t%8d: 0 times\n", a_upDownP->downIncidents[0]);
635 fprintf(cm_outFD, "\t\t\t%8d: 1 time\n", a_upDownP->downIncidents[1]);
636 fprintf(cm_outFD, "\t\t\t%8d: 2 .. 5 times\n",
637 a_upDownP->downIncidents[2]);
638 fprintf(cm_outFD, "\t\t\t%8d: 6 .. 10 times\n",
639 a_upDownP->downIncidents[3]);
640 fprintf(cm_outFD, "\t\t\t%8d: 10 .. 50 times\n",
641 a_upDownP->downIncidents[4]);
642 fprintf(cm_outFD, "\t\t\t%8d: > 50 times\n", a_upDownP->downIncidents[5]);
644 } /*Print_cm_UpDownStats */
647 /*------------------------------------------------------------------------
648 * Print_cm_OverallPerfInfo
651 * Print out overall performance numbers.
654 * a_ovP : Ptr to the overall performance numbers.
660 * All the info we need is nestled into xstat_cm_Results.
664 *------------------------------------------------------------------------*/
667 Print_cm_OverallPerfInfo(struct afs_stats_CMPerf *a_ovP)
668 { /*Print_cm_OverallPerfInfo */
670 fprintf(cm_outFD, "\t%10d numPerfCalls\n", a_ovP->numPerfCalls);
672 fprintf(cm_outFD, "\t%10d epoch\n", a_ovP->epoch);
673 fprintf(cm_outFD, "\t%10d numCellsVisible\n", a_ovP->numCellsVisible);
674 fprintf(cm_outFD, "\t%10d numCellsContacted\n", a_ovP->numCellsContacted);
675 fprintf(cm_outFD, "\t%10d dlocalAccesses\n", a_ovP->dlocalAccesses);
676 fprintf(cm_outFD, "\t%10d vlocalAccesses\n", a_ovP->vlocalAccesses);
677 fprintf(cm_outFD, "\t%10d dremoteAccesses\n", a_ovP->dremoteAccesses);
678 fprintf(cm_outFD, "\t%10d vremoteAccesses\n", a_ovP->vremoteAccesses);
679 fprintf(cm_outFD, "\t%10d cacheNumEntries\n", a_ovP->cacheNumEntries);
680 fprintf(cm_outFD, "\t%10d cacheBlocksTotal\n", a_ovP->cacheBlocksTotal);
681 fprintf(cm_outFD, "\t%10d cacheBlocksInUse\n", a_ovP->cacheBlocksInUse);
682 fprintf(cm_outFD, "\t%10d cacheBlocksOrig\n", a_ovP->cacheBlocksOrig);
683 fprintf(cm_outFD, "\t%10d cacheMaxDirtyChunks\n",
684 a_ovP->cacheMaxDirtyChunks);
685 fprintf(cm_outFD, "\t%10d cacheCurrDirtyChunks\n",
686 a_ovP->cacheCurrDirtyChunks);
687 fprintf(cm_outFD, "\t%10d dcacheHits\n", a_ovP->dcacheHits);
688 fprintf(cm_outFD, "\t%10d vcacheHits\n", a_ovP->vcacheHits);
689 fprintf(cm_outFD, "\t%10d dcacheMisses\n", a_ovP->dcacheMisses);
690 fprintf(cm_outFD, "\t%10d vcacheMisses\n", a_ovP->vcacheMisses);
691 fprintf(cm_outFD, "\t%10d cacheFilesReused\n", a_ovP->cacheFilesReused);
692 fprintf(cm_outFD, "\t%10d vcacheXAllocs\n", a_ovP->vcacheXAllocs);
694 fprintf(cm_outFD, "\t%10d bufAlloced\n", a_ovP->bufAlloced);
695 fprintf(cm_outFD, "\t%10d bufHits\n", a_ovP->bufHits);
696 fprintf(cm_outFD, "\t%10d bufMisses\n", a_ovP->bufMisses);
697 fprintf(cm_outFD, "\t%10d bufFlushDirty\n", a_ovP->bufFlushDirty);
699 fprintf(cm_outFD, "\t%10d LargeBlocksActive\n", a_ovP->LargeBlocksActive);
700 fprintf(cm_outFD, "\t%10d LargeBlocksAlloced\n",
701 a_ovP->LargeBlocksAlloced);
702 fprintf(cm_outFD, "\t%10d SmallBlocksActive\n", a_ovP->SmallBlocksActive);
703 fprintf(cm_outFD, "\t%10d SmallBlocksAlloced\n",
704 a_ovP->SmallBlocksAlloced);
705 fprintf(cm_outFD, "\t%10d OutStandingMemUsage\n",
706 a_ovP->OutStandingMemUsage);
707 fprintf(cm_outFD, "\t%10d OutStandingAllocs\n", a_ovP->OutStandingAllocs);
708 fprintf(cm_outFD, "\t%10d CallBackAlloced\n", a_ovP->CallBackAlloced);
709 fprintf(cm_outFD, "\t%10d CallBackFlushes\n", a_ovP->CallBackFlushes);
711 fprintf(cm_outFD, "\t%10d srvRecords\n", a_ovP->srvRecords);
712 fprintf(cm_outFD, "\t%10d srvNumBuckets\n", a_ovP->srvNumBuckets);
713 fprintf(cm_outFD, "\t%10d srvMaxChainLength\n", a_ovP->srvMaxChainLength);
714 fprintf(cm_outFD, "\t%10d srvMaxChainLengthHWM\n",
715 a_ovP->srvMaxChainLengthHWM);
716 fprintf(cm_outFD, "\t%10d srvRecordsHWM\n", a_ovP->srvRecordsHWM);
718 fprintf(cm_outFD, "\t%10d sysName_ID\n", a_ovP->sysName_ID);
720 fprintf(cm_outFD, "\tFile Server up/downtimes, same cell:\n");
721 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[0]));
723 fprintf(cm_outFD, "\tFile Server up/downtimes, diff cell:\n");
724 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[1]));
726 fprintf(cm_outFD, "\tVL Server up/downtimes, same cell:\n");
727 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[0]));
729 fprintf(cm_outFD, "\tVL Server up/downtimes, diff cell:\n");
730 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[1]));
732 } /*Print_cm_OverallPerfInfo */
735 /*------------------------------------------------------------------------
739 * Print out the AFSCB_XSTATSCOLL_PERF_INFO collection we just
749 * All the info we need is nestled into xstat_cm_Results.
753 *------------------------------------------------------------------------*/
756 Print_cm_PerfInfo(void)
757 { /*Print_cm_PerfInfo */
758 static afs_int32 perfLongs = (sizeof(struct afs_stats_CMPerf) >> 2); /*Correct # longs to rcv */
759 afs_int32 numLongs; /*# longwords received */
760 struct afs_stats_CMPerf *perfP; /*Ptr to performance stats */
761 char *printableTime; /*Ptr to printable time string */
764 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
765 if (numLongs != perfLongs) {
767 " ** Data size mismatch in performance collection!\n");
768 fprintf(cm_outFD, "** Expecting %d, got %d\n", perfLongs, numLongs);
772 probeTime = xstat_cm_Results.probeTime;
773 printableTime = ctime(&probeTime);
774 printableTime[strlen(printableTime) - 1] = '\0';
775 perfP = (struct afs_stats_CMPerf *)
776 (xstat_cm_Results.data.AFSCB_CollData_val);
779 "AFSCB_XSTATSCOLL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
780 xstat_cm_Results.collectionNumber,
781 xstat_cm_Results.connP->hostName, xstat_cm_Results.probeNum,
784 Print_cm_OverallPerfInfo(perfP);
786 } /*Print_cm_PerfInfo */
789 /*------------------------------------------------------------------------
793 * Print out the contents of an FS RPC op timing structure.
796 * a_opIdx : Index of the AFS operation we're printing number on.
797 * a_opNames : Ptr to table of operaton names.
798 * a_opTimeP : Ptr to the op timing structure to print.
804 * Nothing interesting.
808 *------------------------------------------------------------------------*/
811 Print_cm_OpTiming(int a_opIdx, char *a_opNames[],
812 struct afs_stats_opTimingData *a_opTimeP)
813 { /*Print_cm_OpTiming */
816 "%15s: %d ops (%d OK); sum=%ld.%06ld, min=%ld.%06ld, max=%ld.%06ld\n",
817 a_opNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses,
818 (long)a_opTimeP->sumTime.tv_sec, (long)a_opTimeP->sumTime.tv_usec,
819 (long)a_opTimeP->minTime.tv_sec, (long)a_opTimeP->minTime.tv_usec,
820 (long)a_opTimeP->maxTime.tv_sec, (long)a_opTimeP->maxTime.tv_usec);
822 } /*Print_cm_OpTiming */
825 /*------------------------------------------------------------------------
826 * Print_cm_XferTiming
829 * Print out the contents of a data transfer structure.
832 * a_opIdx : Index of the AFS operation we're printing number on.
833 * a_xferP : Ptr to the data transfer structure to print.
839 * Nothing interesting.
843 *------------------------------------------------------------------------*/
846 Print_cm_XferTiming(int a_opIdx, char *a_opNames[],
847 struct afs_stats_xferData *a_xferP)
848 { /*Print_cm_XferTiming */
851 "%s: %d xfers (%d OK), time sum=%ld.%06ld, min=%ld.%06ld, max=%ld.%06ld\n",
852 a_opNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses,
853 (long)a_xferP->sumTime.tv_sec, (long)a_xferP->sumTime.tv_usec,
854 (long)a_xferP->minTime.tv_sec, (long)a_xferP->minTime.tv_usec,
855 (long)a_xferP->maxTime.tv_sec, (long)a_xferP->maxTime.tv_usec);
856 fprintf(cm_outFD, "\t[bytes: sum=%d, min=%d, max=%d]\n",
857 a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
859 "\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
860 a_xferP->count[0], a_xferP->count[1], a_xferP->count[2],
861 a_xferP->count[3], a_xferP->count[4], a_xferP->count[5],
862 a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]);
864 } /*Print_cm_XferTiming */
867 /*------------------------------------------------------------------------
871 * Print out the contents of an FS RPC error info structure.
874 * a_opIdx : Index of the AFS operation we're printing.
875 * a_opNames : Ptr to table of operation names.
876 * a_opErrP : Ptr to the op timing structure to print.
882 * Nothing interesting.
886 *------------------------------------------------------------------------*/
889 Print_cm_ErrInfo(int a_opIdx, char *a_opNames[],
890 struct afs_stats_RPCErrors *a_opErrP)
891 { /*Print_cm_ErrInfo */
894 "%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n",
895 a_opNames[a_opIdx], a_opErrP->err_Server, a_opErrP->err_Network,
896 a_opErrP->err_Protection, a_opErrP->err_Volume,
897 a_opErrP->err_VolumeBusies, a_opErrP->err_Other);
899 } /*Print_cm_ErrInfo */
902 /*------------------------------------------------------------------------
903 * Print_cm_RPCPerfInfo
906 * Print out a set of RPC performance numbers.
909 * a_rpcP : Ptr to RPC perf numbers to print.
915 * Nothing interesting.
919 *------------------------------------------------------------------------*/
922 Print_cm_RPCPerfInfo(struct afs_stats_RPCOpInfo *a_rpcP)
923 { /*Print_cm_RPCPerfInfo */
925 int currIdx; /*Loop variable */
928 * Print the contents of each of the opcode-related arrays.
930 fprintf(cm_outFD, "FS Operation Timings:\n---------------------\n");
931 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
932 Print_cm_OpTiming(currIdx, fsOpNames, &(a_rpcP->fsRPCTimes[currIdx]));
934 fprintf(cm_outFD, "\nError Info:\n-----------\n");
935 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
936 Print_cm_ErrInfo(currIdx, fsOpNames, &(a_rpcP->fsRPCErrors[currIdx]));
938 fprintf(cm_outFD, "\nTransfer timings:\n-----------------\n");
939 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++)
940 Print_cm_XferTiming(currIdx, xferOpNames,
941 &(a_rpcP->fsXferTimes[currIdx]));
943 fprintf(cm_outFD, "\nCM Operation Timings:\n---------------------\n");
944 for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++)
945 Print_cm_OpTiming(currIdx, cmOpNames, &(a_rpcP->cmRPCTimes[currIdx]));
947 } /*Print_cm_RPCPerfInfo */
950 /*------------------------------------------------------------------------
951 * Print_cm_FullPerfInfo
954 * Print out a set of full performance numbers.
963 * Nothing interesting.
967 *------------------------------------------------------------------------*/
970 Print_cm_FullPerfInfo(void)
971 { /*Print_cm_FullPerfInfo */
973 struct afs_stats_AuthentInfo *authentP; /*Ptr to authentication stats */
974 struct afs_stats_AccessInfo *accessinfP; /*Ptr to access stats */
975 static afs_int32 fullPerfLongs = (sizeof(struct afs_stats_CMFullPerf) >> 2); /*Correct #longs */
976 afs_int32 numLongs; /*# longs actually received */
977 struct afs_stats_CMFullPerf *fullP; /*Ptr to full perf info */
979 char *printableTime; /*Ptr to printable time string */
981 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
982 if (numLongs != fullPerfLongs) {
984 " ** Data size mismatch in performance collection!\n");
985 fprintf(cm_outFD, " ** Expecting %d, got %d\n", fullPerfLongs,
990 probeTime = xstat_cm_Results.probeTime;
991 printableTime = ctime(&probeTime);
992 printableTime[strlen(printableTime) - 1] = '\0';
993 fullP = (struct afs_stats_CMFullPerf *)
994 (xstat_cm_Results.data.AFSCB_CollData_val);
997 "AFSCB_XSTATSCOLL_FULL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
998 xstat_cm_Results.collectionNumber,
999 xstat_cm_Results.connP->hostName, xstat_cm_Results.probeNum,
1003 * Print the overall numbers first, followed by all of the RPC numbers,
1004 * then each of the other groupings.
1007 "Overall Performance Info:\n-------------------------\n");
1008 Print_cm_OverallPerfInfo(&(fullP->perf));
1009 fprintf(cm_outFD, "\n");
1010 Print_cm_RPCPerfInfo(&(fullP->rpc));
1012 authentP = &(fullP->authent);
1013 fprintf(cm_outFD, "\nAuthentication info:\n--------------------\n");
1015 "\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n",
1016 authentP->curr_PAGs, authentP->curr_Records,
1017 authentP->curr_AuthRecords, authentP->curr_UnauthRecords,
1018 authentP->curr_MaxRecordsInPAG, authentP->curr_LongestChain);
1019 fprintf(cm_outFD, "\t%d PAG creations, %d tkt updates\n",
1020 authentP->PAGCreations, authentP->TicketUpdates);
1022 "\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n",
1023 authentP->HWM_PAGs, authentP->HWM_Records,
1024 authentP->HWM_MaxRecordsInPAG, authentP->HWM_LongestChain);
1026 accessinfP = &(fullP->accessinf);
1028 "\n[Un]replicated accesses:\n------------------------\n");
1030 "\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n",
1031 accessinfP->unreplicatedRefs, accessinfP->replicatedRefs,
1032 accessinfP->numReplicasAccessed, accessinfP->maxReplicasPerRef,
1033 accessinfP->refFirstReplicaOK);
1035 /* There really isn't any authorship info
1036 * authorP = &(fullP->author); */
1038 } /*Print_cm_FullPerfInfo */
1040 /*------------------------------------------------------------------------
1044 * Prints the contents of xstat_cm_Results to an output file. The
1045 * output is either in a compact (longs only) format or a detailed
1046 * format giving the names of each of the datums. Output is appended.
1049 * Name of output file.
1050 * Flag to indicate if detailed output is required.
1056 * All the info we need is nestled into xstat_cm_Results.
1060 *------------------------------------------------------------------------*/
1062 afsmon_cmOutput(char *a_outfile, /* ptr to output file name */
1063 int a_detOutput) /* detailed output ? */
1066 static char rn[] = "afsmon_cmOutput"; /* routine name */
1067 char *printTime; /* ptr to time string */
1068 char *hostname; /* fileserner name */
1069 afs_int32 numLongs; /* longwords in result */
1070 afs_int32 *currLong; /* ptr to longwords in result */
1075 fprintf(debugFD, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
1076 rn, a_outfile, a_detOutput);
1080 /* need to lock this file before writing */
1081 cm_outFD = fopen(a_outfile, "a");
1082 if (cm_outFD == (FILE *) 0) {
1083 sprintf(errMsg, "[ %s ] failed to open output file %s", rn,
1088 /* get the probe time and strip the \n at the end */
1089 probeTime = xstat_cm_Results.probeTime;
1090 printTime = ctime(&probeTime);
1091 printTime[strlen(printTime) - 1] = '\0';
1092 hostname = xstat_cm_Results.connP->hostName;
1094 /* print "time hostname CM" prefix */
1095 fprintf(cm_outFD, "\n%s %s CM ", printTime, hostname);
1097 /* if probe failed print -1 and vanish */
1098 if (xstat_cm_Results.probeOK) {
1099 fprintf(cm_outFD, "-1\n");
1104 /* print out the probe information as long words */
1105 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
1106 currLong = (afs_int32 *) (xstat_cm_Results.data.AFSCB_CollData_val);
1108 for (i = 0; i < numLongs; i++) {
1109 fprintf(cm_outFD, "%d ", *currLong++);
1111 fprintf(cm_outFD, "\n\n");
1113 /* print out detailed statistics */
1115 Print_cm_FullPerfInfo();
1119 if (fclose(cm_outFD))
1121 fprintf(debugFD, "[ %s ] failed to close %s\n", rn, a_outfile);