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=%d.%06d, min=%d.%06d, max=%d.%06d\n",
257 fsOpNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses,
258 a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
259 a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
260 a_opTimeP->maxTime.tv_sec, 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=%d.%06d, min=%d.%06d, max=%d.%06d\n",
291 xferOpNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses,
292 a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
293 a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
294 a_xferP->maxTime.tv_sec, 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%10d epoch\n", a_detP->epoch);
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 */
371 numLongs = a_fs_Results->data.AFS_CollData_len;
372 if (numLongs != fullPerfLongs) {
374 " ** Data size mismatch in full performance collection!\n");
375 fprintf(fs_outFD, " ** Expecting %d, got %d\n", fullPerfLongs,
380 probeTime = a_fs_Results->probeTime;
381 printableTime = ctime(&probeTime);
382 printableTime[strlen(printableTime) - 1] = '\0';
383 fullPerfP = (struct fs_stats_FullPerfStats *)
384 (a_fs_Results->data.AFS_CollData_val);
387 "AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n",
388 a_fs_Results->collectionNumber, a_fs_Results->connP->hostName,
389 a_fs_Results->probeNum, printableTime);
391 Print_fs_OverallPerfInfo(&(fullPerfP->overall));
392 Print_fs_DetailedPerfInfo(&(fullPerfP->det));
394 } /*Print_fs_FullPerfInfo */
397 /*------------------------------------------------------------------------
401 * Prints the contents of xstat_fs_Results to an output file. The
402 * output is either in a compact (longs only) format or a detailed
403 * format giving the names of each of the datums. Output is appended.
406 * Name of output file.
407 * Flag to indicate if detailed output is required.
413 * All the info we need is nestled into xstat_fs_Results.
417 *------------------------------------------------------------------------*/
419 afsmon_fsOutput(char *a_outfile, /* ptr to output file name */
420 int a_detOutput) /* detailed output ? */
423 static char rn[] = "afsmon_fsOutput"; /* routine name */
424 char *printTime; /* ptr to time string */
425 char *hostname; /* fileserner name */
426 afs_int32 numLongs; /* longwords in result */
427 afs_int32 *currLong; /* ptr to longwords in result */
432 fprintf(debugFD, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
433 rn, a_outfile, a_detOutput);
437 fs_outFD = fopen(a_outfile, "a");
438 if (fs_outFD == (FILE *) 0) {
439 sprintf(errMsg, "[ %s ] failed to open output file %s", rn,
444 /* get the probe time and strip the \n at the end */
445 probeTime = xstat_fs_Results.probeTime;
446 printTime = ctime(&probeTime);
447 printTime[strlen(printTime) - 1] = '\0';
448 hostname = xstat_fs_Results.connP->hostName;
450 /* print "time hostname FS" */
451 fprintf(fs_outFD, "\n%s %s FS ", printTime, hostname);
453 /* if probe failed print -1 and return */
454 if (xstat_fs_Results.probeOK) {
455 fprintf(fs_outFD, "-1\n");
460 /* print out the probe information as long words */
461 numLongs = xstat_fs_Results.data.AFS_CollData_len;
462 currLong = (afs_int32 *) (xstat_fs_Results.data.AFS_CollData_val);
464 for (i = 0; i < numLongs; i++) {
465 fprintf(fs_outFD, "%d ", *currLong++);
467 fprintf(fs_outFD, "\n\n");
469 /* print detailed information */
471 Print_fs_FullPerfInfo(&xstat_fs_Results);
475 if (fclose(fs_outFD))
477 fprintf(debugFD, "[ %s ] failed to close %s\n", rn, a_outfile);
484 /*___________________________________________________________________________
486 *__________________________________________________________________________*/
490 /*------------------------------------------------------------------------
491 * Print_cm_UpDownStats
494 * Print the up/downtime stats for the given class of server records
498 * a_upDownP : Ptr to the server up/down info.
504 * Nothing interesting.
508 *------------------------------------------------------------------------*/
511 Print_cm_UpDownStats(struct afs_stats_SrvUpDownInfo *a_upDownP) /*Ptr to server up/down info */
512 { /*Print_cm_UpDownStats */
515 * First, print the simple values.
517 fprintf(cm_outFD, "\t\t%10d numTtlRecords\n", a_upDownP->numTtlRecords);
518 fprintf(cm_outFD, "\t\t%10d numUpRecords\n", a_upDownP->numUpRecords);
519 fprintf(cm_outFD, "\t\t%10d numDownRecords\n", a_upDownP->numDownRecords);
520 fprintf(cm_outFD, "\t\t%10d sumOfRecordAges\n",
521 a_upDownP->sumOfRecordAges);
522 fprintf(cm_outFD, "\t\t%10d ageOfYoungestRecord\n",
523 a_upDownP->ageOfYoungestRecord);
524 fprintf(cm_outFD, "\t\t%10d ageOfOldestRecord\n",
525 a_upDownP->ageOfOldestRecord);
526 fprintf(cm_outFD, "\t\t%10d numDowntimeIncidents\n",
527 a_upDownP->numDowntimeIncidents);
528 fprintf(cm_outFD, "\t\t%10d numRecordsNeverDown\n",
529 a_upDownP->numRecordsNeverDown);
530 fprintf(cm_outFD, "\t\t%10d maxDowntimesInARecord\n",
531 a_upDownP->maxDowntimesInARecord);
532 fprintf(cm_outFD, "\t\t%10d sumOfDowntimes\n", a_upDownP->sumOfDowntimes);
533 fprintf(cm_outFD, "\t\t%10d shortestDowntime\n",
534 a_upDownP->shortestDowntime);
535 fprintf(cm_outFD, "\t\t%10d longestDowntime\n",
536 a_upDownP->longestDowntime);
539 * Now, print the array values.
541 fprintf(cm_outFD, "\t\tDowntime duration distribution:\n");
542 fprintf(cm_outFD, "\t\t\t%8d: 0 min .. 10 min\n",
543 a_upDownP->downDurations[0]);
544 fprintf(cm_outFD, "\t\t\t%8d: 10 min .. 30 min\n",
545 a_upDownP->downDurations[1]);
546 fprintf(cm_outFD, "\t\t\t%8d: 30 min .. 1 hr\n",
547 a_upDownP->downDurations[2]);
548 fprintf(cm_outFD, "\t\t\t%8d: 1 hr .. 2 hr\n",
549 a_upDownP->downDurations[3]);
550 fprintf(cm_outFD, "\t\t\t%8d: 2 hr .. 4 hr\n",
551 a_upDownP->downDurations[4]);
552 fprintf(cm_outFD, "\t\t\t%8d: 4 hr .. 8 hr\n",
553 a_upDownP->downDurations[5]);
554 fprintf(cm_outFD, "\t\t\t%8d: > 8 hr\n", a_upDownP->downDurations[6]);
556 fprintf(cm_outFD, "\t\tDowntime incident distribution:\n");
557 fprintf(cm_outFD, "\t\t\t%8d: 0 times\n", a_upDownP->downIncidents[0]);
558 fprintf(cm_outFD, "\t\t\t%8d: 1 time\n", a_upDownP->downIncidents[1]);
559 fprintf(cm_outFD, "\t\t\t%8d: 2 .. 5 times\n",
560 a_upDownP->downIncidents[2]);
561 fprintf(cm_outFD, "\t\t\t%8d: 6 .. 10 times\n",
562 a_upDownP->downIncidents[3]);
563 fprintf(cm_outFD, "\t\t\t%8d: 10 .. 50 times\n",
564 a_upDownP->downIncidents[4]);
565 fprintf(cm_outFD, "\t\t\t%8d: > 50 times\n", a_upDownP->downIncidents[5]);
567 } /*Print_cm_UpDownStats */
570 /*------------------------------------------------------------------------
571 * Print_cm_OverallPerfInfo
574 * Print out overall performance numbers.
577 * a_ovP : Ptr to the overall performance numbers.
583 * All the info we need is nestled into xstat_cm_Results.
587 *------------------------------------------------------------------------*/
590 Print_cm_OverallPerfInfo(struct afs_stats_CMPerf *a_ovP)
591 { /*Print_cm_OverallPerfInfo */
593 fprintf(cm_outFD, "\t%10d numPerfCalls\n", a_ovP->numPerfCalls);
595 fprintf(cm_outFD, "\t%10d epoch\n", a_ovP->epoch);
596 fprintf(cm_outFD, "\t%10d numCellsVisible\n", a_ovP->numCellsVisible);
597 fprintf(cm_outFD, "\t%10d numCellsContacted\n", a_ovP->numCellsContacted);
598 fprintf(cm_outFD, "\t%10d dlocalAccesses\n", a_ovP->dlocalAccesses);
599 fprintf(cm_outFD, "\t%10d vlocalAccesses\n", a_ovP->vlocalAccesses);
600 fprintf(cm_outFD, "\t%10d dremoteAccesses\n", a_ovP->dremoteAccesses);
601 fprintf(cm_outFD, "\t%10d vremoteAccesses\n", a_ovP->vremoteAccesses);
602 fprintf(cm_outFD, "\t%10d cacheNumEntries\n", a_ovP->cacheNumEntries);
603 fprintf(cm_outFD, "\t%10d cacheBlocksTotal\n", a_ovP->cacheBlocksTotal);
604 fprintf(cm_outFD, "\t%10d cacheBlocksInUse\n", a_ovP->cacheBlocksInUse);
605 fprintf(cm_outFD, "\t%10d cacheBlocksOrig\n", a_ovP->cacheBlocksOrig);
606 fprintf(cm_outFD, "\t%10d cacheMaxDirtyChunks\n",
607 a_ovP->cacheMaxDirtyChunks);
608 fprintf(cm_outFD, "\t%10d cacheCurrDirtyChunks\n",
609 a_ovP->cacheCurrDirtyChunks);
610 fprintf(cm_outFD, "\t%10d dcacheHits\n", a_ovP->dcacheHits);
611 fprintf(cm_outFD, "\t%10d vcacheHits\n", a_ovP->vcacheHits);
612 fprintf(cm_outFD, "\t%10d dcacheMisses\n", a_ovP->dcacheMisses);
613 fprintf(cm_outFD, "\t%10d vcacheMisses\n", a_ovP->vcacheMisses);
614 fprintf(cm_outFD, "\t%10d cacheFilesReused\n", a_ovP->cacheFilesReused);
615 fprintf(cm_outFD, "\t%10d vcacheXAllocs\n", a_ovP->vcacheXAllocs);
617 fprintf(cm_outFD, "\t%10d bufAlloced\n", a_ovP->bufAlloced);
618 fprintf(cm_outFD, "\t%10d bufHits\n", a_ovP->bufHits);
619 fprintf(cm_outFD, "\t%10d bufMisses\n", a_ovP->bufMisses);
620 fprintf(cm_outFD, "\t%10d bufFlushDirty\n", a_ovP->bufFlushDirty);
622 fprintf(cm_outFD, "\t%10d LargeBlocksActive\n", a_ovP->LargeBlocksActive);
623 fprintf(cm_outFD, "\t%10d LargeBlocksAlloced\n",
624 a_ovP->LargeBlocksAlloced);
625 fprintf(cm_outFD, "\t%10d SmallBlocksActive\n", a_ovP->SmallBlocksActive);
626 fprintf(cm_outFD, "\t%10d SmallBlocksAlloced\n",
627 a_ovP->SmallBlocksAlloced);
628 fprintf(cm_outFD, "\t%10d OutStandingMemUsage\n",
629 a_ovP->OutStandingMemUsage);
630 fprintf(cm_outFD, "\t%10d OutStandingAllocs\n", a_ovP->OutStandingAllocs);
631 fprintf(cm_outFD, "\t%10d CallBackAlloced\n", a_ovP->CallBackAlloced);
632 fprintf(cm_outFD, "\t%10d CallBackFlushes\n", a_ovP->CallBackFlushes);
634 fprintf(cm_outFD, "\t%10d srvRecords\n", a_ovP->srvRecords);
635 fprintf(cm_outFD, "\t%10d srvNumBuckets\n", a_ovP->srvNumBuckets);
636 fprintf(cm_outFD, "\t%10d srvMaxChainLength\n", a_ovP->srvMaxChainLength);
637 fprintf(cm_outFD, "\t%10d srvMaxChainLengthHWM\n",
638 a_ovP->srvMaxChainLengthHWM);
639 fprintf(cm_outFD, "\t%10d srvRecordsHWM\n", a_ovP->srvRecordsHWM);
641 fprintf(cm_outFD, "\t%10d sysName_ID\n", a_ovP->sysName_ID);
643 fprintf(cm_outFD, "\tFile Server up/downtimes, same cell:\n");
644 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[0]));
646 fprintf(cm_outFD, "\tFile Server up/downtimes, diff cell:\n");
647 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[1]));
649 fprintf(cm_outFD, "\tVL Server up/downtimes, same cell:\n");
650 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[0]));
652 fprintf(cm_outFD, "\tVL Server up/downtimes, diff cell:\n");
653 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[1]));
655 } /*Print_cm_OverallPerfInfo */
658 /*------------------------------------------------------------------------
662 * Print out the AFSCB_XSTATSCOLL_PERF_INFO collection we just
672 * All the info we need is nestled into xstat_cm_Results.
676 *------------------------------------------------------------------------*/
679 Print_cm_PerfInfo(void)
680 { /*Print_cm_PerfInfo */
681 static afs_int32 perfLongs = (sizeof(struct afs_stats_CMPerf) >> 2); /*Correct # longs to rcv */
682 afs_int32 numLongs; /*# longwords received */
683 struct afs_stats_CMPerf *perfP; /*Ptr to performance stats */
684 char *printableTime; /*Ptr to printable time string */
687 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
688 if (numLongs != perfLongs) {
690 " ** Data size mismatch in performance collection!\n");
691 fprintf(cm_outFD, "** Expecting %d, got %d\n", perfLongs, numLongs);
695 probeTime = xstat_cm_Results.probeTime;
696 printableTime = ctime(&probeTime);
697 printableTime[strlen(printableTime) - 1] = '\0';
698 perfP = (struct afs_stats_CMPerf *)
699 (xstat_cm_Results.data.AFSCB_CollData_val);
702 "AFSCB_XSTATSCOLL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
703 xstat_cm_Results.collectionNumber,
704 xstat_cm_Results.connP->hostName, xstat_cm_Results.probeNum,
707 Print_cm_OverallPerfInfo(perfP);
709 } /*Print_cm_PerfInfo */
712 /*------------------------------------------------------------------------
716 * Print out the contents of an FS RPC op timing structure.
719 * a_opIdx : Index of the AFS operation we're printing number on.
720 * a_opNames : Ptr to table of operaton names.
721 * a_opTimeP : Ptr to the op timing structure to print.
727 * Nothing interesting.
731 *------------------------------------------------------------------------*/
734 Print_cm_OpTiming(int a_opIdx, char *a_opNames[],
735 struct afs_stats_opTimingData *a_opTimeP)
736 { /*Print_cm_OpTiming */
739 "%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
740 a_opNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses,
741 a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
742 a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
743 a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
745 } /*Print_cm_OpTiming */
748 /*------------------------------------------------------------------------
749 * Print_cm_XferTiming
752 * Print out the contents of a data transfer structure.
755 * a_opIdx : Index of the AFS operation we're printing number on.
756 * a_xferP : Ptr to the data transfer structure to print.
762 * Nothing interesting.
766 *------------------------------------------------------------------------*/
769 Print_cm_XferTiming(int a_opIdx, char *a_opNames[],
770 struct afs_stats_xferData *a_xferP)
771 { /*Print_cm_XferTiming */
774 "%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
775 a_opNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses,
776 a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
777 a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
778 a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
779 fprintf(cm_outFD, "\t[bytes: sum=%d, min=%d, max=%d]\n",
780 a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
782 "\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
783 a_xferP->count[0], a_xferP->count[1], a_xferP->count[2],
784 a_xferP->count[3], a_xferP->count[4], a_xferP->count[5],
785 a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]);
787 } /*Print_cm_XferTiming */
790 /*------------------------------------------------------------------------
794 * Print out the contents of an FS RPC error info structure.
797 * a_opIdx : Index of the AFS operation we're printing.
798 * a_opNames : Ptr to table of operation names.
799 * a_opErrP : Ptr to the op timing structure to print.
805 * Nothing interesting.
809 *------------------------------------------------------------------------*/
812 Print_cm_ErrInfo(int a_opIdx, char *a_opNames[],
813 struct afs_stats_RPCErrors *a_opErrP)
814 { /*Print_cm_ErrInfo */
817 "%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n",
818 a_opNames[a_opIdx], a_opErrP->err_Server, a_opErrP->err_Network,
819 a_opErrP->err_Protection, a_opErrP->err_Volume,
820 a_opErrP->err_VolumeBusies, a_opErrP->err_Other);
822 } /*Print_cm_ErrInfo */
825 /*------------------------------------------------------------------------
826 * Print_cm_RPCPerfInfo
829 * Print out a set of RPC performance numbers.
832 * a_rpcP : Ptr to RPC perf numbers to print.
838 * Nothing interesting.
842 *------------------------------------------------------------------------*/
845 Print_cm_RPCPerfInfo(struct afs_stats_RPCOpInfo *a_rpcP)
846 { /*Print_cm_RPCPerfInfo */
848 int currIdx; /*Loop variable */
851 * Print the contents of each of the opcode-related arrays.
853 fprintf(cm_outFD, "FS Operation Timings:\n---------------------\n");
854 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
855 Print_cm_OpTiming(currIdx, fsOpNames, &(a_rpcP->fsRPCTimes[currIdx]));
857 fprintf(cm_outFD, "\nError Info:\n-----------\n");
858 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
859 Print_cm_ErrInfo(currIdx, fsOpNames, &(a_rpcP->fsRPCErrors[currIdx]));
861 fprintf(cm_outFD, "\nTransfer timings:\n-----------------\n");
862 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++)
863 Print_cm_XferTiming(currIdx, xferOpNames,
864 &(a_rpcP->fsXferTimes[currIdx]));
866 fprintf(cm_outFD, "\nCM Operation Timings:\n---------------------\n");
867 for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++)
868 Print_cm_OpTiming(currIdx, cmOpNames, &(a_rpcP->cmRPCTimes[currIdx]));
870 } /*Print_cm_RPCPerfInfo */
873 /*------------------------------------------------------------------------
874 * Print_cm_FullPerfInfo
877 * Print out a set of full performance numbers.
886 * Nothing interesting.
890 *------------------------------------------------------------------------*/
893 Print_cm_FullPerfInfo(void)
894 { /*Print_cm_FullPerfInfo */
896 struct afs_stats_AuthentInfo *authentP; /*Ptr to authentication stats */
897 struct afs_stats_AccessInfo *accessinfP; /*Ptr to access stats */
898 static afs_int32 fullPerfLongs = (sizeof(struct afs_stats_CMFullPerf) >> 2); /*Correct #longs */
899 afs_int32 numLongs; /*# longs actually received */
900 struct afs_stats_CMFullPerf *fullP; /*Ptr to full perf info */
902 char *printableTime; /*Ptr to printable time string */
904 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
905 if (numLongs != fullPerfLongs) {
907 " ** Data size mismatch in performance collection!\n");
908 fprintf(cm_outFD, " ** Expecting %d, got %d\n", fullPerfLongs,
913 probeTime = xstat_cm_Results.probeTime;
914 printableTime = ctime(&probeTime);
915 printableTime[strlen(printableTime) - 1] = '\0';
916 fullP = (struct afs_stats_CMFullPerf *)
917 (xstat_cm_Results.data.AFSCB_CollData_val);
920 "AFSCB_XSTATSCOLL_FULL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
921 xstat_cm_Results.collectionNumber,
922 xstat_cm_Results.connP->hostName, xstat_cm_Results.probeNum,
926 * Print the overall numbers first, followed by all of the RPC numbers,
927 * then each of the other groupings.
930 "Overall Performance Info:\n-------------------------\n");
931 Print_cm_OverallPerfInfo(&(fullP->perf));
932 fprintf(cm_outFD, "\n");
933 Print_cm_RPCPerfInfo(&(fullP->rpc));
935 authentP = &(fullP->authent);
936 fprintf(cm_outFD, "\nAuthentication info:\n--------------------\n");
938 "\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n",
939 authentP->curr_PAGs, authentP->curr_Records,
940 authentP->curr_AuthRecords, authentP->curr_UnauthRecords,
941 authentP->curr_MaxRecordsInPAG, authentP->curr_LongestChain);
942 fprintf(cm_outFD, "\t%d PAG creations, %d tkt updates\n",
943 authentP->PAGCreations, authentP->TicketUpdates);
945 "\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n",
946 authentP->HWM_PAGs, authentP->HWM_Records,
947 authentP->HWM_MaxRecordsInPAG, authentP->HWM_LongestChain);
949 accessinfP = &(fullP->accessinf);
951 "\n[Un]replicated accesses:\n------------------------\n");
953 "\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n",
954 accessinfP->unreplicatedRefs, accessinfP->replicatedRefs,
955 accessinfP->numReplicasAccessed, accessinfP->maxReplicasPerRef,
956 accessinfP->refFirstReplicaOK);
958 /* There really isn't any authorship info
959 * authorP = &(fullP->author); */
961 } /*Print_cm_FullPerfInfo */
963 /*------------------------------------------------------------------------
967 * Prints the contents of xstat_cm_Results to an output file. The
968 * output is either in a compact (longs only) format or a detailed
969 * format giving the names of each of the datums. Output is appended.
972 * Name of output file.
973 * Flag to indicate if detailed output is required.
979 * All the info we need is nestled into xstat_cm_Results.
983 *------------------------------------------------------------------------*/
985 afsmon_cmOutput(char *a_outfile, /* ptr to output file name */
986 int a_detOutput) /* detailed output ? */
989 static char rn[] = "afsmon_cmOutput"; /* routine name */
990 char *printTime; /* ptr to time string */
991 char *hostname; /* fileserner name */
992 afs_int32 numLongs; /* longwords in result */
993 afs_int32 *currLong; /* ptr to longwords in result */
998 fprintf(debugFD, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
999 rn, a_outfile, a_detOutput);
1003 /* need to lock this file before writing */
1004 cm_outFD = fopen(a_outfile, "a");
1005 if (cm_outFD == (FILE *) 0) {
1006 sprintf(errMsg, "[ %s ] failed to open output file %s", rn,
1011 /* get the probe time and strip the \n at the end */
1012 probeTime = xstat_cm_Results.probeTime;
1013 printTime = ctime(&probeTime);
1014 printTime[strlen(printTime) - 1] = '\0';
1015 hostname = xstat_cm_Results.connP->hostName;
1017 /* print "time hostname CM" prefix */
1018 fprintf(cm_outFD, "\n%s %s CM ", printTime, hostname);
1020 /* if probe failed print -1 and vanish */
1021 if (xstat_cm_Results.probeOK) {
1022 fprintf(cm_outFD, "-1\n");
1027 /* print out the probe information as long words */
1028 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
1029 currLong = (afs_int32 *) (xstat_cm_Results.data.AFSCB_CollData_val);
1031 for (i = 0; i < numLongs; i++) {
1032 fprintf(cm_outFD, "%d ", *currLong++);
1034 fprintf(cm_outFD, "\n\n");
1036 /* print out detailed statistics */
1038 Print_cm_FullPerfInfo();
1042 if (fclose(cm_outFD))
1044 fprintf(debugFD, "[ %s ] failed to close %s\n", rn, a_outfile);