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>
27 #include <afs/xstat_fs.h>
28 #include <afs/xstat_cm.h>
30 #include "afsmonitor.h"
33 /* Extern Variables */
34 extern int afsmon_debug; /* debugging on ? */
35 extern FILE *debugFD; /* debug file FD */
36 extern char errMsg[256]; /* error message buffer */
38 static FILE *fs_outFD; /* fs output file descriptor */
39 static FILE *cm_outFD; /* cm output file descriptor */
41 /* structures used by FS & CM stats print routines */
43 static char *fsOpNames[] = {
74 static char *cmOpNames[] = {
84 static char *xferOpNames[] = {
89 /*________________________________________________________________________
91 *_______________________________________________________________________*/
93 /*------------------------------------------------------------------------
94 * Print_fs_OverallPerfInfo
97 * Print out overall performance numbers.
100 * a_ovP : Ptr to the overall performance numbers.
106 * Nothing interesting.
110 *------------------------------------------------------------------------*/
113 Print_fs_OverallPerfInfo(struct afs_PerfStats *a_ovP)
114 { /*Print_fs_OverallPerfInfo */
116 fprintf(fs_outFD, "\t%10d numPerfCalls\n\n", a_ovP->numPerfCalls);
120 * Vnode cache section.
122 fprintf(fs_outFD, "\t%10d vcache_L_Entries\n", a_ovP->vcache_L_Entries);
123 fprintf(fs_outFD, "\t%10d vcache_L_Allocs\n", a_ovP->vcache_L_Allocs);
124 fprintf(fs_outFD, "\t%10d vcache_L_Gets\n", a_ovP->vcache_L_Gets);
125 fprintf(fs_outFD, "\t%10d vcache_L_Reads\n", a_ovP->vcache_L_Reads);
126 fprintf(fs_outFD, "\t%10d vcache_L_Writes\n\n", a_ovP->vcache_L_Writes);
128 fprintf(fs_outFD, "\t%10d vcache_S_Entries\n", a_ovP->vcache_S_Entries);
129 fprintf(fs_outFD, "\t%10d vcache_S_Allocs\n", a_ovP->vcache_S_Allocs);
130 fprintf(fs_outFD, "\t%10d vcache_S_Gets\n", a_ovP->vcache_S_Gets);
131 fprintf(fs_outFD, "\t%10d vcache_S_Reads\n", a_ovP->vcache_S_Reads);
132 fprintf(fs_outFD, "\t%10d vcache_S_Writes\n\n", a_ovP->vcache_S_Writes);
134 fprintf(fs_outFD, "\t%10d vcache_H_Entries\n", a_ovP->vcache_H_Entries);
135 fprintf(fs_outFD, "\t%10d vcache_H_Gets\n", a_ovP->vcache_H_Gets);
136 fprintf(fs_outFD, "\t%10d vcache_H_Replacements\n\n",
137 a_ovP->vcache_H_Replacements);
140 * Directory package section.
142 fprintf(fs_outFD, "\t%10d dir_Buffers\n", a_ovP->dir_Buffers);
143 fprintf(fs_outFD, "\t%10d dir_Calls\n", a_ovP->dir_Calls);
144 fprintf(fs_outFD, "\t%10d dir_IOs\n\n", a_ovP->dir_IOs);
149 fprintf(fs_outFD, "\t%10d rx_packetRequests\n", a_ovP->rx_packetRequests);
150 fprintf(fs_outFD, "\t%10d rx_noPackets_RcvClass\n",
151 a_ovP->rx_noPackets_RcvClass);
152 fprintf(fs_outFD, "\t%10d rx_noPackets_SendClass\n",
153 a_ovP->rx_noPackets_SendClass);
154 fprintf(fs_outFD, "\t%10d rx_noPackets_SpecialClass\n",
155 a_ovP->rx_noPackets_SpecialClass);
156 fprintf(fs_outFD, "\t%10d rx_socketGreedy\n", a_ovP->rx_socketGreedy);
157 fprintf(fs_outFD, "\t%10d rx_bogusPacketOnRead\n",
158 a_ovP->rx_bogusPacketOnRead);
159 fprintf(fs_outFD, "\t%10d rx_bogusHost\n", a_ovP->rx_bogusHost);
160 fprintf(fs_outFD, "\t%10d rx_noPacketOnRead\n", a_ovP->rx_noPacketOnRead);
161 fprintf(fs_outFD, "\t%10d rx_noPacketBuffersOnRead\n",
162 a_ovP->rx_noPacketBuffersOnRead);
163 fprintf(fs_outFD, "\t%10d rx_selects\n", a_ovP->rx_selects);
164 fprintf(fs_outFD, "\t%10d rx_sendSelects\n", a_ovP->rx_sendSelects);
165 fprintf(fs_outFD, "\t%10d rx_packetsRead_RcvClass\n",
166 a_ovP->rx_packetsRead_RcvClass);
167 fprintf(fs_outFD, "\t%10d rx_packetsRead_SendClass\n",
168 a_ovP->rx_packetsRead_SendClass);
169 fprintf(fs_outFD, "\t%10d rx_packetsRead_SpecialClass\n",
170 a_ovP->rx_packetsRead_SpecialClass);
171 fprintf(fs_outFD, "\t%10d rx_dataPacketsRead\n",
172 a_ovP->rx_dataPacketsRead);
173 fprintf(fs_outFD, "\t%10d rx_ackPacketsRead\n", a_ovP->rx_ackPacketsRead);
174 fprintf(fs_outFD, "\t%10d rx_dupPacketsRead\n", a_ovP->rx_dupPacketsRead);
175 fprintf(fs_outFD, "\t%10d rx_spuriousPacketsRead\n",
176 a_ovP->rx_spuriousPacketsRead);
177 fprintf(fs_outFD, "\t%10d rx_packetsSent_RcvClass\n",
178 a_ovP->rx_packetsSent_RcvClass);
179 fprintf(fs_outFD, "\t%10d rx_packetsSent_SendClass\n",
180 a_ovP->rx_packetsSent_SendClass);
181 fprintf(fs_outFD, "\t%10d rx_packetsSent_SpecialClass\n",
182 a_ovP->rx_packetsSent_SpecialClass);
183 fprintf(fs_outFD, "\t%10d rx_ackPacketsSent\n", a_ovP->rx_ackPacketsSent);
184 fprintf(fs_outFD, "\t%10d rx_pingPacketsSent\n",
185 a_ovP->rx_pingPacketsSent);
186 fprintf(fs_outFD, "\t%10d rx_abortPacketsSent\n",
187 a_ovP->rx_abortPacketsSent);
188 fprintf(fs_outFD, "\t%10d rx_busyPacketsSent\n",
189 a_ovP->rx_busyPacketsSent);
190 fprintf(fs_outFD, "\t%10d rx_dataPacketsSent\n",
191 a_ovP->rx_dataPacketsSent);
192 fprintf(fs_outFD, "\t%10d rx_dataPacketsReSent\n",
193 a_ovP->rx_dataPacketsReSent);
194 fprintf(fs_outFD, "\t%10d rx_dataPacketsPushed\n",
195 a_ovP->rx_dataPacketsPushed);
196 fprintf(fs_outFD, "\t%10d rx_ignoreAckedPacket\n",
197 a_ovP->rx_ignoreAckedPacket);
198 fprintf(fs_outFD, "\t%10d rx_totalRtt_Sec\n", a_ovP->rx_totalRtt_Sec);
199 fprintf(fs_outFD, "\t%10d rx_totalRtt_Usec\n", a_ovP->rx_totalRtt_Usec);
200 fprintf(fs_outFD, "\t%10d rx_minRtt_Sec\n", a_ovP->rx_minRtt_Sec);
201 fprintf(fs_outFD, "\t%10d rx_minRtt_Usec\n", a_ovP->rx_minRtt_Usec);
202 fprintf(fs_outFD, "\t%10d rx_maxRtt_Sec\n", a_ovP->rx_maxRtt_Sec);
203 fprintf(fs_outFD, "\t%10d rx_maxRtt_Usec\n", a_ovP->rx_maxRtt_Usec);
204 fprintf(fs_outFD, "\t%10d rx_nRttSamples\n", a_ovP->rx_nRttSamples);
205 fprintf(fs_outFD, "\t%10d rx_nServerConns\n", a_ovP->rx_nServerConns);
206 fprintf(fs_outFD, "\t%10d rx_nClientConns\n", a_ovP->rx_nClientConns);
207 fprintf(fs_outFD, "\t%10d rx_nPeerStructs\n", a_ovP->rx_nPeerStructs);
208 fprintf(fs_outFD, "\t%10d rx_nCallStructs\n", a_ovP->rx_nCallStructs);
209 fprintf(fs_outFD, "\t%10d rx_nFreeCallStructs\n\n",
210 a_ovP->rx_nFreeCallStructs);
213 * Host module fields.
215 fprintf(fs_outFD, "\t%10d host_NumHostEntries\n",
216 a_ovP->host_NumHostEntries);
217 fprintf(fs_outFD, "\t%10d host_HostBlocks\n", a_ovP->host_HostBlocks);
218 fprintf(fs_outFD, "\t%10d host_NonDeletedHosts\n",
219 a_ovP->host_NonDeletedHosts);
220 fprintf(fs_outFD, "\t%10d host_HostsInSameNetOrSubnet\n",
221 a_ovP->host_HostsInSameNetOrSubnet);
222 fprintf(fs_outFD, "\t%10d host_HostsInDiffSubnet\n",
223 a_ovP->host_HostsInDiffSubnet);
224 fprintf(fs_outFD, "\t%10d host_HostsInDiffNetwork\n",
225 a_ovP->host_HostsInDiffNetwork);
226 fprintf(fs_outFD, "\t%10d host_NumClients\n", a_ovP->host_NumClients);
227 fprintf(fs_outFD, "\t%10d host_ClientBlocks\n\n",
228 a_ovP->host_ClientBlocks);
230 } /*Print_fs_OverallPerfInfo */
233 /*------------------------------------------------------------------------
237 * Print out the contents of an RPC op timing structure.
240 * a_opIdx : Index of the AFS operation we're printing number on.
241 * a_opTimeP : Ptr to the op timing structure to print.
247 * Nothing interesting.
251 *------------------------------------------------------------------------*/
254 Print_fs_OpTiming(int a_opIdx, struct fs_stats_opTimingData *a_opTimeP)
255 { /*Print_fs_OpTiming */
258 "%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
259 fsOpNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses,
260 a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
261 a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
262 a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
264 } /*Print_fs_OpTiming */
267 /*------------------------------------------------------------------------
268 * Print_fs_XferTiming
271 * Print out the contents of a data transfer structure.
274 * a_opIdx : Index of the AFS operation we're printing number on.
275 * a_xferP : Ptr to the data transfer structure to print.
281 * Nothing interesting.
285 *------------------------------------------------------------------------*/
288 Print_fs_XferTiming(int a_opIdx, struct fs_stats_xferData *a_xferP)
289 { /*Print_fs_XferTiming */
292 "%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
293 xferOpNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses,
294 a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
295 a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
296 a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
297 fprintf(fs_outFD, "\t[bytes: sum=%d, min=%d, max=%d]\n",
298 a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
300 "\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
301 a_xferP->count[0], a_xferP->count[1], a_xferP->count[2],
302 a_xferP->count[3], a_xferP->count[4], a_xferP->count[5],
303 a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]);
305 } /*Print_fs_XferTiming */
308 /*------------------------------------------------------------------------
309 * Print_fs_DetailedPerfInfo
312 * Print out a set of detailed performance numbers.
315 * a_detP : Ptr to detailed perf numbers to print.
321 * Nothing interesting.
325 *------------------------------------------------------------------------*/
328 Print_fs_DetailedPerfInfo(struct fs_stats_DetailedStats *a_detP)
329 { /*Print_fs_DetailedPerfInfo */
331 int currIdx; /*Loop variable */
333 fprintf(fs_outFD, "\t%10d epoch\n", a_detP->epoch);
335 for (currIdx = 0; currIdx < FS_STATS_NUM_RPC_OPS; currIdx++)
336 Print_fs_OpTiming(currIdx, &(a_detP->rpcOpTimes[currIdx]));
338 for (currIdx = 0; currIdx < FS_STATS_NUM_XFER_OPS; currIdx++)
339 Print_fs_XferTiming(currIdx, &(a_detP->xferOpTimes[currIdx]));
341 } /*Print_fs_DetailedPerfInfo */
344 /*------------------------------------------------------------------------
345 * Print_fs_FullPerfInfo
348 * Print out the AFS_XSTATSCOLL_FULL_PERF_INFO collection we just
358 * All the info we need is nestled into xstat_fs_Results.
362 *------------------------------------------------------------------------*/
365 Print_fs_FullPerfInfo(struct xstat_fs_ProbeResults *a_fs_Results)
366 { /*Print_fs_FullPerfInfo */
367 static afs_int32 fullPerfLongs = (sizeof(struct fs_stats_FullPerfStats) >> 2); /*Correct # longs to rcv */
368 afs_int32 numLongs; /*# longwords received */
369 struct fs_stats_FullPerfStats *fullPerfP; /*Ptr to full perf stats */
370 char *printableTime; /*Ptr to printable time string */
373 numLongs = a_fs_Results->data.AFS_CollData_len;
374 if (numLongs != fullPerfLongs) {
376 " ** Data size mismatch in full performance collection!\n");
377 fprintf(fs_outFD, " ** Expecting %d, got %d\n", fullPerfLongs,
382 probeTime = a_fs_Results->probeTime;
383 printableTime = ctime(&probeTime);
384 printableTime[strlen(printableTime) - 1] = '\0';
385 fullPerfP = (struct fs_stats_FullPerfStats *)
386 (a_fs_Results->data.AFS_CollData_val);
389 "AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n",
390 a_fs_Results->collectionNumber, a_fs_Results->connP->hostName,
391 a_fs_Results->probeNum, printableTime);
393 Print_fs_OverallPerfInfo(&(fullPerfP->overall));
394 Print_fs_DetailedPerfInfo(&(fullPerfP->det));
396 } /*Print_fs_FullPerfInfo */
399 /*------------------------------------------------------------------------
403 * Prints the contents of xstat_fs_Results to an output file. The
404 * output is either in a compact (longs only) format or a detailed
405 * format giving the names of each of the datums. Output is appended.
408 * Name of output file.
409 * Flag to indicate if detailed output is required.
415 * All the info we need is nestled into xstat_fs_Results.
419 *------------------------------------------------------------------------*/
421 afsmon_fsOutput(char *a_outfile, /* ptr to output file name */
422 int a_detOutput) /* detailed output ? */
425 static char rn[] = "afsmon_fsOutput"; /* routine name */
426 char *printTime; /* ptr to time string */
427 char *hostname; /* fileserner name */
428 afs_int32 numLongs; /* longwords in result */
429 afs_int32 *currLong; /* ptr to longwords in result */
434 fprintf(debugFD, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
435 rn, a_outfile, a_detOutput);
439 fs_outFD = fopen(a_outfile, "a");
440 if (fs_outFD == (FILE *) 0) {
441 sprintf(errMsg, "[ %s ] failed to open output file %s", rn,
446 /* get the probe time and strip the \n at the end */
447 probeTime = xstat_fs_Results.probeTime;
448 printTime = ctime(&probeTime);
449 printTime[strlen(printTime) - 1] = '\0';
450 hostname = xstat_fs_Results.connP->hostName;
452 /* print "time hostname FS" */
453 fprintf(fs_outFD, "\n%s %s FS ", printTime, hostname);
455 /* if probe failed print -1 and return */
456 if (xstat_fs_Results.probeOK) {
457 fprintf(fs_outFD, "-1\n");
462 /* print out the probe information as long words */
463 numLongs = xstat_fs_Results.data.AFS_CollData_len;
464 currLong = (afs_int32 *) (xstat_fs_Results.data.AFS_CollData_val);
466 for (i = 0; i < numLongs; i++) {
467 fprintf(fs_outFD, "%d ", *currLong++);
469 fprintf(fs_outFD, "\n\n");
471 /* print detailed information */
473 Print_fs_FullPerfInfo(&xstat_fs_Results);
477 if (fclose(fs_outFD))
479 fprintf(debugFD, "[ %s ] failed to close %s\n", rn, a_outfile);
486 /*___________________________________________________________________________
488 *__________________________________________________________________________*/
492 /*------------------------------------------------------------------------
493 * Print_cm_UpDownStats
496 * Print the up/downtime stats for the given class of server records
500 * a_upDownP : Ptr to the server up/down info.
506 * Nothing interesting.
510 *------------------------------------------------------------------------*/
513 Print_cm_UpDownStats(struct afs_stats_SrvUpDownInfo *a_upDownP) /*Ptr to server up/down info */
514 { /*Print_cm_UpDownStats */
517 * First, print the simple values.
519 fprintf(cm_outFD, "\t\t%10d numTtlRecords\n", a_upDownP->numTtlRecords);
520 fprintf(cm_outFD, "\t\t%10d numUpRecords\n", a_upDownP->numUpRecords);
521 fprintf(cm_outFD, "\t\t%10d numDownRecords\n", a_upDownP->numDownRecords);
522 fprintf(cm_outFD, "\t\t%10d sumOfRecordAges\n",
523 a_upDownP->sumOfRecordAges);
524 fprintf(cm_outFD, "\t\t%10d ageOfYoungestRecord\n",
525 a_upDownP->ageOfYoungestRecord);
526 fprintf(cm_outFD, "\t\t%10d ageOfOldestRecord\n",
527 a_upDownP->ageOfOldestRecord);
528 fprintf(cm_outFD, "\t\t%10d numDowntimeIncidents\n",
529 a_upDownP->numDowntimeIncidents);
530 fprintf(cm_outFD, "\t\t%10d numRecordsNeverDown\n",
531 a_upDownP->numRecordsNeverDown);
532 fprintf(cm_outFD, "\t\t%10d maxDowntimesInARecord\n",
533 a_upDownP->maxDowntimesInARecord);
534 fprintf(cm_outFD, "\t\t%10d sumOfDowntimes\n", a_upDownP->sumOfDowntimes);
535 fprintf(cm_outFD, "\t\t%10d shortestDowntime\n",
536 a_upDownP->shortestDowntime);
537 fprintf(cm_outFD, "\t\t%10d longestDowntime\n",
538 a_upDownP->longestDowntime);
541 * Now, print the array values.
543 fprintf(cm_outFD, "\t\tDowntime duration distribution:\n");
544 fprintf(cm_outFD, "\t\t\t%8d: 0 min .. 10 min\n",
545 a_upDownP->downDurations[0]);
546 fprintf(cm_outFD, "\t\t\t%8d: 10 min .. 30 min\n",
547 a_upDownP->downDurations[1]);
548 fprintf(cm_outFD, "\t\t\t%8d: 30 min .. 1 hr\n",
549 a_upDownP->downDurations[2]);
550 fprintf(cm_outFD, "\t\t\t%8d: 1 hr .. 2 hr\n",
551 a_upDownP->downDurations[3]);
552 fprintf(cm_outFD, "\t\t\t%8d: 2 hr .. 4 hr\n",
553 a_upDownP->downDurations[4]);
554 fprintf(cm_outFD, "\t\t\t%8d: 4 hr .. 8 hr\n",
555 a_upDownP->downDurations[5]);
556 fprintf(cm_outFD, "\t\t\t%8d: > 8 hr\n", a_upDownP->downDurations[6]);
558 fprintf(cm_outFD, "\t\tDowntime incident distribution:\n");
559 fprintf(cm_outFD, "\t\t\t%8d: 0 times\n", a_upDownP->downIncidents[0]);
560 fprintf(cm_outFD, "\t\t\t%8d: 1 time\n", a_upDownP->downIncidents[1]);
561 fprintf(cm_outFD, "\t\t\t%8d: 2 .. 5 times\n",
562 a_upDownP->downIncidents[2]);
563 fprintf(cm_outFD, "\t\t\t%8d: 6 .. 10 times\n",
564 a_upDownP->downIncidents[3]);
565 fprintf(cm_outFD, "\t\t\t%8d: 10 .. 50 times\n",
566 a_upDownP->downIncidents[4]);
567 fprintf(cm_outFD, "\t\t\t%8d: > 50 times\n", a_upDownP->downIncidents[5]);
569 } /*Print_cm_UpDownStats */
572 /*------------------------------------------------------------------------
573 * Print_cm_OverallPerfInfo
576 * Print out overall performance numbers.
579 * a_ovP : Ptr to the overall performance numbers.
585 * All the info we need is nestled into xstat_cm_Results.
589 *------------------------------------------------------------------------*/
592 Print_cm_OverallPerfInfo(struct afs_stats_CMPerf *a_ovP)
593 { /*Print_cm_OverallPerfInfo */
595 fprintf(cm_outFD, "\t%10d numPerfCalls\n", a_ovP->numPerfCalls);
597 fprintf(cm_outFD, "\t%10d epoch\n", a_ovP->epoch);
598 fprintf(cm_outFD, "\t%10d numCellsVisible\n", a_ovP->numCellsVisible);
599 fprintf(cm_outFD, "\t%10d numCellsContacted\n", a_ovP->numCellsContacted);
600 fprintf(cm_outFD, "\t%10d dlocalAccesses\n", a_ovP->dlocalAccesses);
601 fprintf(cm_outFD, "\t%10d vlocalAccesses\n", a_ovP->vlocalAccesses);
602 fprintf(cm_outFD, "\t%10d dremoteAccesses\n", a_ovP->dremoteAccesses);
603 fprintf(cm_outFD, "\t%10d vremoteAccesses\n", a_ovP->vremoteAccesses);
604 fprintf(cm_outFD, "\t%10d cacheNumEntries\n", a_ovP->cacheNumEntries);
605 fprintf(cm_outFD, "\t%10d cacheBlocksTotal\n", a_ovP->cacheBlocksTotal);
606 fprintf(cm_outFD, "\t%10d cacheBlocksInUse\n", a_ovP->cacheBlocksInUse);
607 fprintf(cm_outFD, "\t%10d cacheBlocksOrig\n", a_ovP->cacheBlocksOrig);
608 fprintf(cm_outFD, "\t%10d cacheMaxDirtyChunks\n",
609 a_ovP->cacheMaxDirtyChunks);
610 fprintf(cm_outFD, "\t%10d cacheCurrDirtyChunks\n",
611 a_ovP->cacheCurrDirtyChunks);
612 fprintf(cm_outFD, "\t%10d dcacheHits\n", a_ovP->dcacheHits);
613 fprintf(cm_outFD, "\t%10d vcacheHits\n", a_ovP->vcacheHits);
614 fprintf(cm_outFD, "\t%10d dcacheMisses\n", a_ovP->dcacheMisses);
615 fprintf(cm_outFD, "\t%10d vcacheMisses\n", a_ovP->vcacheMisses);
616 fprintf(cm_outFD, "\t%10d cacheFilesReused\n", a_ovP->cacheFilesReused);
617 fprintf(cm_outFD, "\t%10d vcacheXAllocs\n", a_ovP->vcacheXAllocs);
619 fprintf(cm_outFD, "\t%10d bufAlloced\n", a_ovP->bufAlloced);
620 fprintf(cm_outFD, "\t%10d bufHits\n", a_ovP->bufHits);
621 fprintf(cm_outFD, "\t%10d bufMisses\n", a_ovP->bufMisses);
622 fprintf(cm_outFD, "\t%10d bufFlushDirty\n", a_ovP->bufFlushDirty);
624 fprintf(cm_outFD, "\t%10d LargeBlocksActive\n", a_ovP->LargeBlocksActive);
625 fprintf(cm_outFD, "\t%10d LargeBlocksAlloced\n",
626 a_ovP->LargeBlocksAlloced);
627 fprintf(cm_outFD, "\t%10d SmallBlocksActive\n", a_ovP->SmallBlocksActive);
628 fprintf(cm_outFD, "\t%10d SmallBlocksAlloced\n",
629 a_ovP->SmallBlocksAlloced);
630 fprintf(cm_outFD, "\t%10d OutStandingMemUsage\n",
631 a_ovP->OutStandingMemUsage);
632 fprintf(cm_outFD, "\t%10d OutStandingAllocs\n", a_ovP->OutStandingAllocs);
633 fprintf(cm_outFD, "\t%10d CallBackAlloced\n", a_ovP->CallBackAlloced);
634 fprintf(cm_outFD, "\t%10d CallBackFlushes\n", a_ovP->CallBackFlushes);
636 fprintf(cm_outFD, "\t%10d srvRecords\n", a_ovP->srvRecords);
637 fprintf(cm_outFD, "\t%10d srvNumBuckets\n", a_ovP->srvNumBuckets);
638 fprintf(cm_outFD, "\t%10d srvMaxChainLength\n", a_ovP->srvMaxChainLength);
639 fprintf(cm_outFD, "\t%10d srvMaxChainLengthHWM\n",
640 a_ovP->srvMaxChainLengthHWM);
641 fprintf(cm_outFD, "\t%10d srvRecordsHWM\n", a_ovP->srvRecordsHWM);
643 fprintf(cm_outFD, "\t%10d sysName_ID\n", a_ovP->sysName_ID);
645 fprintf(cm_outFD, "\tFile Server up/downtimes, same cell:\n");
646 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[0]));
648 fprintf(cm_outFD, "\tFile Server up/downtimes, diff cell:\n");
649 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[1]));
651 fprintf(cm_outFD, "\tVL Server up/downtimes, same cell:\n");
652 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[0]));
654 fprintf(cm_outFD, "\tVL Server up/downtimes, diff cell:\n");
655 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[1]));
657 } /*Print_cm_OverallPerfInfo */
660 /*------------------------------------------------------------------------
664 * Print out the AFSCB_XSTATSCOLL_PERF_INFO collection we just
674 * All the info we need is nestled into xstat_cm_Results.
678 *------------------------------------------------------------------------*/
681 Print_cm_PerfInfo(void)
682 { /*Print_cm_PerfInfo */
683 static afs_int32 perfLongs = (sizeof(struct afs_stats_CMPerf) >> 2); /*Correct # longs to rcv */
684 afs_int32 numLongs; /*# longwords received */
685 struct afs_stats_CMPerf *perfP; /*Ptr to performance stats */
686 char *printableTime; /*Ptr to printable time string */
689 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
690 if (numLongs != perfLongs) {
692 " ** Data size mismatch in performance collection!\n");
693 fprintf(cm_outFD, "** Expecting %d, got %d\n", perfLongs, numLongs);
697 probeTime = xstat_cm_Results.probeTime;
698 printableTime = ctime(&probeTime);
699 printableTime[strlen(printableTime) - 1] = '\0';
700 perfP = (struct afs_stats_CMPerf *)
701 (xstat_cm_Results.data.AFSCB_CollData_val);
704 "AFSCB_XSTATSCOLL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
705 xstat_cm_Results.collectionNumber,
706 xstat_cm_Results.connP->hostName, xstat_cm_Results.probeNum,
709 Print_cm_OverallPerfInfo(perfP);
711 } /*Print_cm_PerfInfo */
714 /*------------------------------------------------------------------------
718 * Print out the contents of an FS RPC op timing structure.
721 * a_opIdx : Index of the AFS operation we're printing number on.
722 * a_opNames : Ptr to table of operaton names.
723 * a_opTimeP : Ptr to the op timing structure to print.
729 * Nothing interesting.
733 *------------------------------------------------------------------------*/
736 Print_cm_OpTiming(int a_opIdx, char *a_opNames[],
737 struct afs_stats_opTimingData *a_opTimeP)
738 { /*Print_cm_OpTiming */
741 "%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
742 a_opNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses,
743 a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
744 a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
745 a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
747 } /*Print_cm_OpTiming */
750 /*------------------------------------------------------------------------
751 * Print_cm_XferTiming
754 * Print out the contents of a data transfer structure.
757 * a_opIdx : Index of the AFS operation we're printing number on.
758 * a_xferP : Ptr to the data transfer structure to print.
764 * Nothing interesting.
768 *------------------------------------------------------------------------*/
771 Print_cm_XferTiming(int a_opIdx, char *a_opNames[],
772 struct afs_stats_xferData *a_xferP)
773 { /*Print_cm_XferTiming */
776 "%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
777 a_opNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses,
778 a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
779 a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
780 a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
781 fprintf(cm_outFD, "\t[bytes: sum=%d, min=%d, max=%d]\n",
782 a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
784 "\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
785 a_xferP->count[0], a_xferP->count[1], a_xferP->count[2],
786 a_xferP->count[3], a_xferP->count[4], a_xferP->count[5],
787 a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]);
789 } /*Print_cm_XferTiming */
792 /*------------------------------------------------------------------------
796 * Print out the contents of an FS RPC error info structure.
799 * a_opIdx : Index of the AFS operation we're printing.
800 * a_opNames : Ptr to table of operation names.
801 * a_opErrP : Ptr to the op timing structure to print.
807 * Nothing interesting.
811 *------------------------------------------------------------------------*/
814 Print_cm_ErrInfo(int a_opIdx, char *a_opNames[],
815 struct afs_stats_RPCErrors *a_opErrP)
816 { /*Print_cm_ErrInfo */
819 "%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n",
820 a_opNames[a_opIdx], a_opErrP->err_Server, a_opErrP->err_Network,
821 a_opErrP->err_Protection, a_opErrP->err_Volume,
822 a_opErrP->err_VolumeBusies, a_opErrP->err_Other);
824 } /*Print_cm_ErrInfo */
827 /*------------------------------------------------------------------------
828 * Print_cm_RPCPerfInfo
831 * Print out a set of RPC performance numbers.
834 * a_rpcP : Ptr to RPC perf numbers to print.
840 * Nothing interesting.
844 *------------------------------------------------------------------------*/
847 Print_cm_RPCPerfInfo(struct afs_stats_RPCOpInfo *a_rpcP)
848 { /*Print_cm_RPCPerfInfo */
850 int currIdx; /*Loop variable */
853 * Print the contents of each of the opcode-related arrays.
855 fprintf(cm_outFD, "FS Operation Timings:\n---------------------\n");
856 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
857 Print_cm_OpTiming(currIdx, fsOpNames, &(a_rpcP->fsRPCTimes[currIdx]));
859 fprintf(cm_outFD, "\nError Info:\n-----------\n");
860 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
861 Print_cm_ErrInfo(currIdx, fsOpNames, &(a_rpcP->fsRPCErrors[currIdx]));
863 fprintf(cm_outFD, "\nTransfer timings:\n-----------------\n");
864 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++)
865 Print_cm_XferTiming(currIdx, xferOpNames,
866 &(a_rpcP->fsXferTimes[currIdx]));
868 fprintf(cm_outFD, "\nCM Operation Timings:\n---------------------\n");
869 for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++)
870 Print_cm_OpTiming(currIdx, cmOpNames, &(a_rpcP->cmRPCTimes[currIdx]));
872 } /*Print_cm_RPCPerfInfo */
875 /*------------------------------------------------------------------------
876 * Print_cm_FullPerfInfo
879 * Print out a set of full performance numbers.
888 * Nothing interesting.
892 *------------------------------------------------------------------------*/
895 Print_cm_FullPerfInfo(void)
896 { /*Print_cm_FullPerfInfo */
898 struct afs_stats_AuthentInfo *authentP; /*Ptr to authentication stats */
899 struct afs_stats_AccessInfo *accessinfP; /*Ptr to access stats */
900 static afs_int32 fullPerfLongs = (sizeof(struct afs_stats_CMFullPerf) >> 2); /*Correct #longs */
901 afs_int32 numLongs; /*# longs actually received */
902 struct afs_stats_CMFullPerf *fullP; /*Ptr to full perf info */
904 char *printableTime; /*Ptr to printable time string */
906 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
907 if (numLongs != fullPerfLongs) {
909 " ** Data size mismatch in performance collection!\n");
910 fprintf(cm_outFD, " ** Expecting %d, got %d\n", fullPerfLongs,
915 probeTime = xstat_cm_Results.probeTime;
916 printableTime = ctime(&probeTime);
917 printableTime[strlen(printableTime) - 1] = '\0';
918 fullP = (struct afs_stats_CMFullPerf *)
919 (xstat_cm_Results.data.AFSCB_CollData_val);
922 "AFSCB_XSTATSCOLL_FULL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
923 xstat_cm_Results.collectionNumber,
924 xstat_cm_Results.connP->hostName, xstat_cm_Results.probeNum,
928 * Print the overall numbers first, followed by all of the RPC numbers,
929 * then each of the other groupings.
932 "Overall Performance Info:\n-------------------------\n");
933 Print_cm_OverallPerfInfo(&(fullP->perf));
934 fprintf(cm_outFD, "\n");
935 Print_cm_RPCPerfInfo(&(fullP->rpc));
937 authentP = &(fullP->authent);
938 fprintf(cm_outFD, "\nAuthentication info:\n--------------------\n");
940 "\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n",
941 authentP->curr_PAGs, authentP->curr_Records,
942 authentP->curr_AuthRecords, authentP->curr_UnauthRecords,
943 authentP->curr_MaxRecordsInPAG, authentP->curr_LongestChain);
944 fprintf(cm_outFD, "\t%d PAG creations, %d tkt updates\n",
945 authentP->PAGCreations, authentP->TicketUpdates);
947 "\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n",
948 authentP->HWM_PAGs, authentP->HWM_Records,
949 authentP->HWM_MaxRecordsInPAG, authentP->HWM_LongestChain);
951 accessinfP = &(fullP->accessinf);
953 "\n[Un]replicated accesses:\n------------------------\n");
955 "\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n",
956 accessinfP->unreplicatedRefs, accessinfP->replicatedRefs,
957 accessinfP->numReplicasAccessed, accessinfP->maxReplicasPerRef,
958 accessinfP->refFirstReplicaOK);
960 /* There really isn't any authorship info
961 * authorP = &(fullP->author); */
963 } /*Print_cm_FullPerfInfo */
965 /*------------------------------------------------------------------------
969 * Prints the contents of xstat_cm_Results to an output file. The
970 * output is either in a compact (longs only) format or a detailed
971 * format giving the names of each of the datums. Output is appended.
974 * Name of output file.
975 * Flag to indicate if detailed output is required.
981 * All the info we need is nestled into xstat_cm_Results.
985 *------------------------------------------------------------------------*/
987 afsmon_cmOutput(char *a_outfile, /* ptr to output file name */
988 int a_detOutput) /* detailed output ? */
991 static char rn[] = "afsmon_cmOutput"; /* routine name */
992 char *printTime; /* ptr to time string */
993 char *hostname; /* fileserner name */
994 afs_int32 numLongs; /* longwords in result */
995 afs_int32 *currLong; /* ptr to longwords in result */
1000 fprintf(debugFD, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
1001 rn, a_outfile, a_detOutput);
1005 /* need to lock this file before writing */
1006 cm_outFD = fopen(a_outfile, "a");
1007 if (cm_outFD == (FILE *) 0) {
1008 sprintf(errMsg, "[ %s ] failed to open output file %s", rn,
1013 /* get the probe time and strip the \n at the end */
1014 probeTime = xstat_cm_Results.probeTime;
1015 printTime = ctime(&probeTime);
1016 printTime[strlen(printTime) - 1] = '\0';
1017 hostname = xstat_cm_Results.connP->hostName;
1019 /* print "time hostname CM" prefix */
1020 fprintf(cm_outFD, "\n%s %s CM ", printTime, hostname);
1022 /* if probe failed print -1 and vanish */
1023 if (xstat_cm_Results.probeOK) {
1024 fprintf(cm_outFD, "-1\n");
1029 /* print out the probe information as long words */
1030 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
1031 currLong = (afs_int32 *) (xstat_cm_Results.data.AFSCB_CollData_val);
1033 for (i = 0; i < numLongs; i++) {
1034 fprintf(cm_outFD, "%d ", *currLong++);
1036 fprintf(cm_outFD, "\n\n");
1038 /* print out detailed statistics */
1040 Print_cm_FullPerfInfo();
1044 if (fclose(cm_outFD))
1046 fprintf(debugFD, "[ %s ] failed to close %s\n", rn, a_outfile);