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 <afs/param.h>
21 #include <afsconfig.h>
25 #include <afs/xstat_fs.h>
26 #include <afs/xstat_cm.h>
30 /* Extern Variables */
31 extern int afsmon_debug; /* debugging on ? */
32 extern FILE *debugFD; /* debug file FD */
33 extern char errMsg[256]; /* error message buffer */
35 extern int afsmon_Exit(); /* exit routine */
37 static FILE *fs_outFD; /* fs output file descriptor */
38 static FILE *cm_outFD; /* cm output file descriptor */
40 /* structures used by FS & CM stats print routines */
42 static char *fsOpNames[] = {
73 static char *cmOpNames[] = {
83 static char *xferOpNames[] = {
88 /*________________________________________________________________________
90 *_______________________________________________________________________*/
92 /*------------------------------------------------------------------------
93 * Print_fs_OverallPerfInfo
96 * Print out overall performance numbers.
99 * a_ovP : Ptr to the overall performance numbers.
105 * Nothing interesting.
109 *------------------------------------------------------------------------*/
111 void Print_fs_OverallPerfInfo(a_ovP)
112 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",a_ovP->vcache_H_Replacements);
139 * Directory package section.
141 fprintf(fs_outFD,"\t%10d dir_Buffers\n", a_ovP->dir_Buffers);
142 fprintf(fs_outFD,"\t%10d dir_Calls\n", a_ovP->dir_Calls);
143 fprintf(fs_outFD,"\t%10d dir_IOs\n\n", a_ovP->dir_IOs);
148 fprintf(fs_outFD,"\t%10d rx_packetRequests\n", a_ovP->rx_packetRequests);
149 fprintf(fs_outFD,"\t%10d rx_noPackets_RcvClass\n", a_ovP->rx_noPackets_RcvClass);
150 fprintf(fs_outFD,"\t%10d rx_noPackets_SendClass\n", a_ovP->rx_noPackets_SendClass);
151 fprintf(fs_outFD,"\t%10d rx_noPackets_SpecialClass\n", a_ovP->rx_noPackets_SpecialClass);
152 fprintf(fs_outFD,"\t%10d rx_socketGreedy\n", a_ovP->rx_socketGreedy);
153 fprintf(fs_outFD,"\t%10d rx_bogusPacketOnRead\n", a_ovP->rx_bogusPacketOnRead);
154 fprintf(fs_outFD,"\t%10d rx_bogusHost\n", a_ovP->rx_bogusHost);
155 fprintf(fs_outFD,"\t%10d rx_noPacketOnRead\n", a_ovP->rx_noPacketOnRead);
156 fprintf(fs_outFD,"\t%10d rx_noPacketBuffersOnRead\n", a_ovP->rx_noPacketBuffersOnRead);
157 fprintf(fs_outFD,"\t%10d rx_selects\n", a_ovP->rx_selects);
158 fprintf(fs_outFD,"\t%10d rx_sendSelects\n", a_ovP->rx_sendSelects);
159 fprintf(fs_outFD,"\t%10d rx_packetsRead_RcvClass\n", a_ovP->rx_packetsRead_RcvClass);
160 fprintf(fs_outFD,"\t%10d rx_packetsRead_SendClass\n", a_ovP->rx_packetsRead_SendClass);
161 fprintf(fs_outFD,"\t%10d rx_packetsRead_SpecialClass\n", a_ovP->rx_packetsRead_SpecialClass);
162 fprintf(fs_outFD,"\t%10d rx_dataPacketsRead\n", a_ovP->rx_dataPacketsRead);
163 fprintf(fs_outFD,"\t%10d rx_ackPacketsRead\n", a_ovP->rx_ackPacketsRead);
164 fprintf(fs_outFD,"\t%10d rx_dupPacketsRead\n", a_ovP->rx_dupPacketsRead);
165 fprintf(fs_outFD,"\t%10d rx_spuriousPacketsRead\n", a_ovP->rx_spuriousPacketsRead);
166 fprintf(fs_outFD,"\t%10d rx_packetsSent_RcvClass\n", a_ovP->rx_packetsSent_RcvClass);
167 fprintf(fs_outFD,"\t%10d rx_packetsSent_SendClass\n", a_ovP->rx_packetsSent_SendClass);
168 fprintf(fs_outFD,"\t%10d rx_packetsSent_SpecialClass\n", a_ovP->rx_packetsSent_SpecialClass);
169 fprintf(fs_outFD,"\t%10d rx_ackPacketsSent\n", a_ovP->rx_ackPacketsSent);
170 fprintf(fs_outFD,"\t%10d rx_pingPacketsSent\n", a_ovP->rx_pingPacketsSent);
171 fprintf(fs_outFD,"\t%10d rx_abortPacketsSent\n",a_ovP->rx_abortPacketsSent);
172 fprintf(fs_outFD,"\t%10d rx_busyPacketsSent\n", a_ovP->rx_busyPacketsSent);
173 fprintf(fs_outFD,"\t%10d rx_dataPacketsSent\n", a_ovP->rx_dataPacketsSent);
174 fprintf(fs_outFD,"\t%10d rx_dataPacketsReSent\n", a_ovP->rx_dataPacketsReSent);
175 fprintf(fs_outFD,"\t%10d rx_dataPacketsPushed\n", a_ovP->rx_dataPacketsPushed);
176 fprintf(fs_outFD,"\t%10d rx_ignoreAckedPacket\n", a_ovP->rx_ignoreAckedPacket);
177 fprintf(fs_outFD,"\t%10d rx_totalRtt_Sec\n", a_ovP->rx_totalRtt_Sec);
178 fprintf(fs_outFD,"\t%10d rx_totalRtt_Usec\n", a_ovP->rx_totalRtt_Usec);
179 fprintf(fs_outFD,"\t%10d rx_minRtt_Sec\n", a_ovP->rx_minRtt_Sec);
180 fprintf(fs_outFD,"\t%10d rx_minRtt_Usec\n", a_ovP->rx_minRtt_Usec);
181 fprintf(fs_outFD,"\t%10d rx_maxRtt_Sec\n", a_ovP->rx_maxRtt_Sec);
182 fprintf(fs_outFD,"\t%10d rx_maxRtt_Usec\n", a_ovP->rx_maxRtt_Usec);
183 fprintf(fs_outFD,"\t%10d rx_nRttSamples\n", a_ovP->rx_nRttSamples);
184 fprintf(fs_outFD,"\t%10d rx_nServerConns\n", a_ovP->rx_nServerConns);
185 fprintf(fs_outFD,"\t%10d rx_nClientConns\n", a_ovP->rx_nClientConns);
186 fprintf(fs_outFD,"\t%10d rx_nPeerStructs\n", a_ovP->rx_nPeerStructs);
187 fprintf(fs_outFD,"\t%10d rx_nCallStructs\n", a_ovP->rx_nCallStructs);
188 fprintf(fs_outFD,"\t%10d rx_nFreeCallStructs\n\n", a_ovP->rx_nFreeCallStructs);
191 * Host module fields.
193 fprintf(fs_outFD,"\t%10d host_NumHostEntries\n", a_ovP->host_NumHostEntries);
194 fprintf(fs_outFD,"\t%10d host_HostBlocks\n", a_ovP->host_HostBlocks);
195 fprintf(fs_outFD,"\t%10d host_NonDeletedHosts\n", a_ovP->host_NonDeletedHosts);
196 fprintf(fs_outFD,"\t%10d host_HostsInSameNetOrSubnet\n", a_ovP->host_HostsInSameNetOrSubnet);
197 fprintf(fs_outFD,"\t%10d host_HostsInDiffSubnet\n", a_ovP->host_HostsInDiffSubnet);
198 fprintf(fs_outFD,"\t%10d host_HostsInDiffNetwork\n",a_ovP->host_HostsInDiffNetwork);
199 fprintf(fs_outFD,"\t%10d host_NumClients\n", a_ovP->host_NumClients);
200 fprintf(fs_outFD,"\t%10d host_ClientBlocks\n\n", a_ovP->host_ClientBlocks);
202 } /*Print_fs_OverallPerfInfo*/
205 /*------------------------------------------------------------------------
209 * Print out the contents of an RPC op timing structure.
212 * a_opIdx : Index of the AFS operation we're printing number on.
213 * a_opTimeP : Ptr to the op timing structure to print.
219 * Nothing interesting.
223 *------------------------------------------------------------------------*/
225 void Print_fs_OpTiming(a_opIdx, a_opTimeP)
227 struct fs_stats_opTimingData *a_opTimeP;
229 { /*Print_fs_OpTiming*/
231 fprintf(fs_outFD,"%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
233 a_opTimeP->numOps, a_opTimeP->numSuccesses,
234 a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
235 a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
236 a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
238 } /*Print_fs_OpTiming*/
241 /*------------------------------------------------------------------------
242 * Print_fs_XferTiming
245 * Print out the contents of a data transfer structure.
248 * a_opIdx : Index of the AFS operation we're printing number on.
249 * a_xferP : Ptr to the data transfer structure to print.
255 * Nothing interesting.
259 *------------------------------------------------------------------------*/
261 void Print_fs_XferTiming(a_opIdx, a_xferP)
263 struct fs_stats_xferData *a_xferP;
265 { /*Print_fs_XferTiming*/
267 fprintf(fs_outFD,"%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
268 xferOpNames[a_opIdx],
269 a_xferP->numXfers, a_xferP->numSuccesses,
270 a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
271 a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
272 a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
273 fprintf(fs_outFD,"\t[bytes: sum=%d, min=%d, max=%d]\n",
274 a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
275 fprintf(fs_outFD,"\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
286 } /*Print_fs_XferTiming*/
289 /*------------------------------------------------------------------------
290 * Print_fs_DetailedPerfInfo
293 * Print out a set of detailed performance numbers.
296 * a_detP : Ptr to detailed perf numbers to print.
302 * Nothing interesting.
306 *------------------------------------------------------------------------*/
308 void Print_fs_DetailedPerfInfo(a_detP)
309 struct fs_stats_DetailedStats *a_detP;
311 { /*Print_fs_DetailedPerfInfo*/
313 int currIdx; /*Loop variable*/
315 fprintf(fs_outFD,"\t%10d epoch\n", a_detP->epoch);
317 for (currIdx = 0; currIdx < FS_STATS_NUM_RPC_OPS; currIdx++)
318 Print_fs_OpTiming(currIdx, &(a_detP->rpcOpTimes[currIdx]));
320 for (currIdx = 0; currIdx < FS_STATS_NUM_XFER_OPS; currIdx++)
321 Print_fs_XferTiming(currIdx, &(a_detP->xferOpTimes[currIdx]));
323 } /*Print_fs_DetailedPerfInfo*/
326 /*------------------------------------------------------------------------
327 * Print_fs_FullPerfInfo
330 * Print out the AFS_XSTATSCOLL_FULL_PERF_INFO collection we just
340 * All the info we need is nestled into xstat_fs_Results.
344 *------------------------------------------------------------------------*/
346 void Print_fs_FullPerfInfo(a_fs_Results)
347 struct xstat_fs_ProbeResults *a_fs_Results; /* ptr to fs results */
348 { /*Print_fs_FullPerfInfo*/
350 static char rn[] = "Print_fs_FullPerfInfo"; /*Routine name*/
351 static afs_int32 fullPerfLongs =
352 (sizeof(struct fs_stats_FullPerfStats) >> 2); /*Correct # longs to rcv*/
353 afs_int32 numLongs; /*# longwords received*/
354 struct fs_stats_FullPerfStats *fullPerfP; /*Ptr to full perf stats*/
355 char *printableTime; /*Ptr to printable time string*/
358 numLongs = a_fs_Results->data.AFS_CollData_len;
359 if (numLongs != fullPerfLongs) {
360 fprintf(fs_outFD," ** Data size mismatch in full performance collection!\n");
361 fprintf(fs_outFD," ** Expecting %d, got %d\n", fullPerfLongs, numLongs);
365 printableTime = ctime((time_t *)&(a_fs_Results->probeTime));
366 printableTime[strlen(printableTime)-1] = '\0';
367 fullPerfP = (struct fs_stats_FullPerfStats *)
368 (a_fs_Results->data.AFS_CollData_val);
370 fprintf(fs_outFD,"AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n",
371 a_fs_Results->collectionNumber,
372 a_fs_Results->connP->hostName,
373 a_fs_Results->probeNum,
376 Print_fs_OverallPerfInfo(&(fullPerfP->overall));
377 Print_fs_DetailedPerfInfo(&(fullPerfP->det));
379 } /*Print_fs_FullPerfInfo*/
382 /*------------------------------------------------------------------------
386 * Prints the contents of xstat_fs_Results to an output file. The
387 * output is either in a compact (longs only) format or a detailed
388 * format giving the names of each of the datums. Output is appended.
391 * Name of output file.
392 * Flag to indicate if detailed output is required.
398 * All the info we need is nestled into xstat_fs_Results.
402 *------------------------------------------------------------------------*/
404 afsmon_fsOutput(a_outfile, a_detOutput)
405 char *a_outfile; /* ptr to output file name */
406 int a_detOutput; /* detailed output ? */
409 static char rn[] = "afsmon_fsOutput"; /* routine name */
410 char *printTime; /* ptr to time string */
411 char *hostname; /* fileserner name */
412 afs_int32 numLongs; /* longwords in result */
413 afs_int32 *currLong; /* ptr to longwords in result */
417 fprintf(debugFD,"[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
418 rn, a_outfile, a_detOutput);
422 fs_outFD = fopen(a_outfile,"a");
423 if (fs_outFD == (FILE *)0) {
424 sprintf(errMsg,"[ %s ] failed to open output file %s",rn,a_outfile);
428 /* get the probe time and strip the \n at the end */
429 printTime = ctime((time_t *)&(xstat_fs_Results.probeTime));
430 printTime[strlen(printTime) - 1] = '\0';
431 hostname = xstat_fs_Results.connP->hostName;
433 /* print "time hostname FS" */
434 fprintf(fs_outFD,"\n%s %s FS ",printTime,hostname);
436 /* if probe failed print -1 and return */
437 if (xstat_fs_Results.probeOK) {
438 fprintf(fs_outFD,"-1\n");
443 /* print out the probe information as long words */
444 numLongs = xstat_fs_Results.data.AFS_CollData_len;
445 currLong = (afs_int32 *)(xstat_fs_Results.data.AFS_CollData_val);
447 for(i=0; i<numLongs; i++) {
448 fprintf(fs_outFD,"%d ",*currLong++);
450 fprintf(fs_outFD,"\n\n");
452 /* print detailed information */
454 Print_fs_FullPerfInfo(&xstat_fs_Results);
458 if ( fclose(fs_outFD))
460 fprintf(debugFD,"[ %s ] failed to close %s\n",rn,a_outfile);
467 /*___________________________________________________________________________
469 *__________________________________________________________________________*/
473 /*------------------------------------------------------------------------
474 * Print_cm_UpDownStats
477 * Print the up/downtime stats for the given class of server records
481 * a_upDownP : Ptr to the server up/down info.
487 * Nothing interesting.
491 *------------------------------------------------------------------------*/
493 void Print_cm_UpDownStats(a_upDownP)
494 struct afs_stats_SrvUpDownInfo *a_upDownP; /*Ptr to server up/down info*/
496 { /*Print_cm_UpDownStats*/
499 * First, print the simple values.
501 fprintf(cm_outFD,"\t\t%10d numTtlRecords\n", a_upDownP->numTtlRecords);
502 fprintf(cm_outFD,"\t\t%10d numUpRecords\n", a_upDownP->numUpRecords);
503 fprintf(cm_outFD,"\t\t%10d numDownRecords\n", a_upDownP->numDownRecords);
504 fprintf(cm_outFD,"\t\t%10d sumOfRecordAges\n", a_upDownP->sumOfRecordAges);
505 fprintf(cm_outFD,"\t\t%10d ageOfYoungestRecord\n", a_upDownP->ageOfYoungestRecord);
506 fprintf(cm_outFD,"\t\t%10d ageOfOldestRecord\n", a_upDownP->ageOfOldestRecord);
507 fprintf(cm_outFD,"\t\t%10d numDowntimeIncidents\n", a_upDownP->numDowntimeIncidents);
508 fprintf(cm_outFD,"\t\t%10d numRecordsNeverDown\n", a_upDownP->numRecordsNeverDown);
509 fprintf(cm_outFD,"\t\t%10d maxDowntimesInARecord\n", a_upDownP->maxDowntimesInARecord);
510 fprintf(cm_outFD,"\t\t%10d sumOfDowntimes\n", a_upDownP->sumOfDowntimes);
511 fprintf(cm_outFD,"\t\t%10d shortestDowntime\n", a_upDownP->shortestDowntime);
512 fprintf(cm_outFD,"\t\t%10d longestDowntime\n", a_upDownP->longestDowntime);
515 * Now, print the array values.
517 fprintf(cm_outFD,"\t\tDowntime duration distribution:\n");
518 fprintf(cm_outFD,"\t\t\t%8d: 0 min .. 10 min\n", a_upDownP->downDurations[0]);
519 fprintf(cm_outFD,"\t\t\t%8d: 10 min .. 30 min\n", a_upDownP->downDurations[1]);
520 fprintf(cm_outFD,"\t\t\t%8d: 30 min .. 1 hr\n", a_upDownP->downDurations[2]);
521 fprintf(cm_outFD,"\t\t\t%8d: 1 hr .. 2 hr\n", a_upDownP->downDurations[3]);
522 fprintf(cm_outFD,"\t\t\t%8d: 2 hr .. 4 hr\n", a_upDownP->downDurations[4]);
523 fprintf(cm_outFD,"\t\t\t%8d: 4 hr .. 8 hr\n", a_upDownP->downDurations[5]);
524 fprintf(cm_outFD,"\t\t\t%8d: > 8 hr\n", a_upDownP->downDurations[6]);
526 fprintf(cm_outFD,"\t\tDowntime incident distribution:\n");
527 fprintf(cm_outFD,"\t\t\t%8d: 0 times\n", a_upDownP->downIncidents[0]);
528 fprintf(cm_outFD,"\t\t\t%8d: 1 time\n", a_upDownP->downIncidents[1]);
529 fprintf(cm_outFD,"\t\t\t%8d: 2 .. 5 times\n", a_upDownP->downIncidents[2]);
530 fprintf(cm_outFD,"\t\t\t%8d: 6 .. 10 times\n", a_upDownP->downIncidents[3]);
531 fprintf(cm_outFD,"\t\t\t%8d: 10 .. 50 times\n", a_upDownP->downIncidents[4]);
532 fprintf(cm_outFD,"\t\t\t%8d: > 50 times\n", a_upDownP->downIncidents[5]);
534 } /*Print_cm_UpDownStats*/
537 /*------------------------------------------------------------------------
538 * Print_cm_OverallPerfInfo
541 * Print out overall performance numbers.
544 * a_ovP : Ptr to the overall performance numbers.
550 * All the info we need is nestled into xstat_cm_Results.
554 *------------------------------------------------------------------------*/
556 void Print_cm_OverallPerfInfo(a_ovP)
557 struct afs_stats_CMPerf *a_ovP;
559 { /*Print_cm_OverallPerfInfo*/
561 fprintf(cm_outFD,"\t%10d numPerfCalls\n", a_ovP->numPerfCalls);
563 fprintf(cm_outFD,"\t%10d epoch\n", a_ovP->epoch);
564 fprintf(cm_outFD,"\t%10d numCellsVisible\n", a_ovP->numCellsVisible);
565 fprintf(cm_outFD,"\t%10d numCellsContacted\n", a_ovP->numCellsContacted);
566 fprintf(cm_outFD,"\t%10d dlocalAccesses\n", a_ovP->dlocalAccesses);
567 fprintf(cm_outFD,"\t%10d vlocalAccesses\n", a_ovP->vlocalAccesses);
568 fprintf(cm_outFD,"\t%10d dremoteAccesses\n", a_ovP->dremoteAccesses);
569 fprintf(cm_outFD,"\t%10d vremoteAccesses\n", a_ovP->vremoteAccesses);
570 fprintf(cm_outFD,"\t%10d cacheNumEntries\n", a_ovP->cacheNumEntries);
571 fprintf(cm_outFD,"\t%10d cacheBlocksTotal\n", a_ovP->cacheBlocksTotal);
572 fprintf(cm_outFD,"\t%10d cacheBlocksInUse\n", a_ovP->cacheBlocksInUse);
573 fprintf(cm_outFD,"\t%10d cacheBlocksOrig\n", a_ovP->cacheBlocksOrig);
574 fprintf(cm_outFD,"\t%10d cacheMaxDirtyChunks\n",a_ovP->cacheMaxDirtyChunks);
575 fprintf(cm_outFD,"\t%10d cacheCurrDirtyChunks\n", a_ovP->cacheCurrDirtyChunks);
576 fprintf(cm_outFD,"\t%10d dcacheHits\n", a_ovP->dcacheHits);
577 fprintf(cm_outFD,"\t%10d vcacheHits\n", a_ovP->vcacheHits);
578 fprintf(cm_outFD,"\t%10d dcacheMisses\n", a_ovP->dcacheMisses);
579 fprintf(cm_outFD,"\t%10d vcacheMisses\n", a_ovP->vcacheMisses);
580 fprintf(cm_outFD,"\t%10d cacheFilesReused\n", a_ovP->cacheFilesReused);
581 fprintf(cm_outFD,"\t%10d vcacheXAllocs\n", a_ovP->vcacheXAllocs);
583 fprintf(cm_outFD,"\t%10d bufAlloced\n", a_ovP->bufAlloced);
584 fprintf(cm_outFD,"\t%10d bufHits\n", a_ovP->bufHits);
585 fprintf(cm_outFD,"\t%10d bufMisses\n", a_ovP->bufMisses);
586 fprintf(cm_outFD,"\t%10d bufFlushDirty\n", a_ovP->bufFlushDirty);
588 fprintf(cm_outFD,"\t%10d LargeBlocksActive\n", a_ovP->LargeBlocksActive);
589 fprintf(cm_outFD,"\t%10d LargeBlocksAlloced\n", a_ovP->LargeBlocksAlloced);
590 fprintf(cm_outFD,"\t%10d SmallBlocksActive\n", a_ovP->SmallBlocksActive);
591 fprintf(cm_outFD,"\t%10d SmallBlocksAlloced\n", a_ovP->SmallBlocksAlloced);
592 fprintf(cm_outFD,"\t%10d OutStandingMemUsage\n", a_ovP->OutStandingMemUsage);
593 fprintf(cm_outFD,"\t%10d OutStandingAllocs\n", a_ovP->OutStandingAllocs);
594 fprintf(cm_outFD,"\t%10d CallBackAlloced\n", a_ovP->CallBackAlloced);
595 fprintf(cm_outFD,"\t%10d CallBackFlushes\n", a_ovP->CallBackFlushes);
597 fprintf(cm_outFD,"\t%10d srvRecords\n", a_ovP->srvRecords);
598 fprintf(cm_outFD,"\t%10d srvNumBuckets\n", a_ovP->srvNumBuckets);
599 fprintf(cm_outFD,"\t%10d srvMaxChainLength\n", a_ovP->srvMaxChainLength);
600 fprintf(cm_outFD,"\t%10d srvMaxChainLengthHWM\n", a_ovP->srvMaxChainLengthHWM);
601 fprintf(cm_outFD,"\t%10d srvRecordsHWM\n", a_ovP->srvRecordsHWM);
603 fprintf(cm_outFD,"\t%10d sysName_ID\n", a_ovP->sysName_ID);
605 fprintf(cm_outFD,"\tFile Server up/downtimes, same cell:\n");
606 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[0]));
608 fprintf(cm_outFD,"\tFile Server up/downtimes, diff cell:\n");
609 Print_cm_UpDownStats(&(a_ovP->fs_UpDown[1]));
611 fprintf(cm_outFD,"\tVL Server up/downtimes, same cell:\n");
612 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[0]));
614 fprintf(cm_outFD,"\tVL Server up/downtimes, diff cell:\n");
615 Print_cm_UpDownStats(&(a_ovP->vl_UpDown[1]));
617 } /*Print_cm_OverallPerfInfo*/
620 /*------------------------------------------------------------------------
624 * Print out the AFSCB_XSTATSCOLL_PERF_INFO collection we just
634 * All the info we need is nestled into xstat_cm_Results.
638 *------------------------------------------------------------------------*/
640 void Print_cm_PerfInfo()
642 { /*Print_cm_PerfInfo*/
644 static char rn[] = "Print_cm_PerfInfo"; /*Routine name*/
645 static afs_int32 perfLongs =
646 (sizeof(struct afs_stats_CMPerf) >> 2); /*Correct # longs to rcv*/
647 afs_int32 numLongs; /*# longwords received*/
648 struct afs_stats_CMPerf *perfP; /*Ptr to performance stats*/
649 char *printableTime; /*Ptr to printable time string*/
651 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
652 if (numLongs != perfLongs) {
653 fprintf(cm_outFD," ** Data size mismatch in performance collection!\n");
654 fprintf(cm_outFD,"** Expecting %d, got %d\n", perfLongs, numLongs);
658 printableTime = ctime((time_t *)&(xstat_cm_Results.probeTime));
659 printableTime[strlen(printableTime)-1] = '\0';
660 perfP = (struct afs_stats_CMPerf *)
661 (xstat_cm_Results.data.AFSCB_CollData_val);
663 fprintf(cm_outFD,"AFSCB_XSTATSCOLL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
664 xstat_cm_Results.collectionNumber,
665 xstat_cm_Results.connP->hostName,
666 xstat_cm_Results.probeNum,
669 Print_cm_OverallPerfInfo(perfP);
671 } /*Print_cm_PerfInfo*/
674 /*------------------------------------------------------------------------
678 * Print out the contents of an FS RPC op timing structure.
681 * a_opIdx : Index of the AFS operation we're printing number on.
682 * a_opNames : Ptr to table of operaton names.
683 * a_opTimeP : Ptr to the op timing structure to print.
689 * Nothing interesting.
693 *------------------------------------------------------------------------*/
695 void Print_cm_OpTiming(a_opIdx, a_opNames, a_opTimeP)
698 struct afs_stats_opTimingData *a_opTimeP;
700 { /*Print_cm_OpTiming*/
702 fprintf(cm_outFD,"%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
704 a_opTimeP->numOps, a_opTimeP->numSuccesses,
705 a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec,
706 a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec,
707 a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec);
709 } /*Print_cm_OpTiming*/
712 /*------------------------------------------------------------------------
713 * Print_cm_XferTiming
716 * Print out the contents of a data transfer structure.
719 * a_opIdx : Index of the AFS operation we're printing number on.
720 * a_xferP : Ptr to the data transfer structure to print.
726 * Nothing interesting.
730 *------------------------------------------------------------------------*/
732 void Print_cm_XferTiming(a_opIdx, a_opNames, a_xferP)
735 struct afs_stats_xferData *a_xferP;
737 { /*Print_cm_XferTiming*/
739 fprintf(cm_outFD,"%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n",
741 a_xferP->numXfers, a_xferP->numSuccesses,
742 a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec,
743 a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec,
744 a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec);
745 fprintf(cm_outFD,"\t[bytes: sum=%d, min=%d, max=%d]\n",
746 a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes);
747 fprintf(cm_outFD,"\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
758 } /*Print_cm_XferTiming*/
761 /*------------------------------------------------------------------------
765 * Print out the contents of an FS RPC error info structure.
768 * a_opIdx : Index of the AFS operation we're printing.
769 * a_opNames : Ptr to table of operation names.
770 * a_opErrP : Ptr to the op timing structure to print.
776 * Nothing interesting.
780 *------------------------------------------------------------------------*/
782 void Print_cm_ErrInfo(a_opIdx, a_opNames, a_opErrP)
785 struct afs_stats_RPCErrors *a_opErrP;
787 { /*Print_cm_ErrInfo*/
789 fprintf(cm_outFD,"%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n",
791 a_opErrP->err_Server,
792 a_opErrP->err_Network,
793 a_opErrP->err_Protection,
794 a_opErrP->err_Volume,
795 a_opErrP->err_VolumeBusies,
796 a_opErrP->err_Other);
798 } /*Print_cm_ErrInfo*/
801 /*------------------------------------------------------------------------
802 * Print_cm_RPCPerfInfo
805 * Print out a set of RPC performance numbers.
808 * a_rpcP : Ptr to RPC perf numbers to print.
814 * Nothing interesting.
818 *------------------------------------------------------------------------*/
820 void Print_cm_RPCPerfInfo(a_rpcP)
821 struct afs_stats_RPCOpInfo *a_rpcP;
823 { /*Print_cm_RPCPerfInfo*/
825 int currIdx; /*Loop variable*/
828 * Print the contents of each of the opcode-related arrays.
830 fprintf(cm_outFD,"FS Operation Timings:\n---------------------\n");
831 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
832 Print_cm_OpTiming(currIdx, fsOpNames, &(a_rpcP->fsRPCTimes[currIdx]));
834 fprintf(cm_outFD,"\nError Info:\n-----------\n");
835 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++)
836 Print_cm_ErrInfo(currIdx, fsOpNames, &(a_rpcP->fsRPCErrors[currIdx]));
838 fprintf(cm_outFD,"\nTransfer timings:\n-----------------\n");
839 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++)
840 Print_cm_XferTiming(currIdx, xferOpNames, &(a_rpcP->fsXferTimes[currIdx]));
842 fprintf(cm_outFD,"\nCM Operation Timings:\n---------------------\n");
843 for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++)
844 Print_cm_OpTiming(currIdx, cmOpNames, &(a_rpcP->cmRPCTimes[currIdx]));
846 } /*Print_cm_RPCPerfInfo*/
849 /*------------------------------------------------------------------------
850 * Print_cm_FullPerfInfo
853 * Print out a set of full performance numbers.
862 * Nothing interesting.
866 *------------------------------------------------------------------------*/
868 void Print_cm_FullPerfInfo()
870 { /*Print_cm_FullPerfInfo*/
872 static char rn[] = "Print_cm_FullPerfInfo"; /* routine name */
873 struct afs_stats_AuthentInfo *authentP; /*Ptr to authentication stats*/
874 struct afs_stats_AccessInfo *accessinfP; /*Ptr to access stats*/
875 static afs_int32 fullPerfLongs =
876 (sizeof (struct afs_stats_CMFullPerf) >> 2); /*Correct #longs*/
877 afs_int32 numLongs; /*# longs actually received*/
878 struct afs_stats_CMFullPerf *fullP; /*Ptr to full perf info*/
880 char *printableTime; /*Ptr to printable time string*/
882 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
883 if (numLongs != fullPerfLongs) {
884 fprintf(cm_outFD," ** Data size mismatch in performance collection!\n");
885 fprintf(cm_outFD," ** Expecting %d, got %d\n",fullPerfLongs, numLongs);
889 printableTime = ctime((time_t *)&(xstat_cm_Results.probeTime));
890 printableTime[strlen(printableTime)-1] = '\0';
891 fullP = (struct afs_stats_CMFullPerf *)
892 (xstat_cm_Results.data.AFSCB_CollData_val);
894 fprintf(cm_outFD,"AFSCB_XSTATSCOLL_FULL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
895 xstat_cm_Results.collectionNumber,
896 xstat_cm_Results.connP->hostName,
897 xstat_cm_Results.probeNum,
901 * Print the overall numbers first, followed by all of the RPC numbers,
902 * then each of the other groupings.
904 fprintf(cm_outFD,"Overall Performance Info:\n-------------------------\n");
905 Print_cm_OverallPerfInfo(&(fullP->perf));
906 fprintf(cm_outFD,"\n");
907 Print_cm_RPCPerfInfo(&(fullP->rpc));
909 authentP = &(fullP->authent);
910 fprintf(cm_outFD,"\nAuthentication info:\n--------------------\n");
911 fprintf(cm_outFD,"\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n",
913 authentP->curr_Records,
914 authentP->curr_AuthRecords,
915 authentP->curr_UnauthRecords,
916 authentP->curr_MaxRecordsInPAG,
917 authentP->curr_LongestChain);
918 fprintf(cm_outFD,"\t%d PAG creations, %d tkt updates\n",
919 authentP->PAGCreations,
920 authentP->TicketUpdates);
921 fprintf(cm_outFD,"\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n",
923 authentP->HWM_Records,
924 authentP->HWM_MaxRecordsInPAG,
925 authentP->HWM_LongestChain);
927 accessinfP = &(fullP->accessinf);
928 fprintf(cm_outFD,"\n[Un]replicated accesses:\n------------------------\n");
929 fprintf(cm_outFD,"\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n",
930 accessinfP->unreplicatedRefs,
931 accessinfP->replicatedRefs,
932 accessinfP->numReplicasAccessed,
933 accessinfP->maxReplicasPerRef,
934 accessinfP->refFirstReplicaOK);
936 /* There really isn't any authorship info
937 authorP = &(fullP->author); */
939 } /*Print_cm_FullPerfInfo*/
941 /*------------------------------------------------------------------------
945 * Prints the contents of xstat_cm_Results to an output file. The
946 * output is either in a compact (longs only) format or a detailed
947 * format giving the names of each of the datums. Output is appended.
950 * Name of output file.
951 * Flag to indicate if detailed output is required.
957 * All the info we need is nestled into xstat_cm_Results.
961 *------------------------------------------------------------------------*/
963 afsmon_cmOutput(a_outfile, a_detOutput)
964 char *a_outfile; /* ptr to output file name */
965 int a_detOutput; /* detailed output ? */
968 static char rn[] = "afsmon_cmOutput"; /* routine name */
969 char *printTime; /* ptr to time string */
970 char *hostname; /* fileserner name */
971 afs_int32 numLongs; /* longwords in result */
972 afs_int32 *currLong; /* ptr to longwords in result */
976 fprintf(debugFD,"[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
977 rn, a_outfile, a_detOutput);
981 /* need to lock this file before writing */
982 cm_outFD = fopen(a_outfile,"a");
983 if (cm_outFD == (FILE *)0) {
984 sprintf(errMsg,"[ %s ] failed to open output file %s",rn,a_outfile);
988 /* get the probe time and strip the \n at the end */
989 printTime = ctime((time_t *)&(xstat_cm_Results.probeTime));
990 printTime[strlen(printTime) - 1] = '\0';
991 hostname = xstat_cm_Results.connP->hostName;
993 /* print "time hostname CM" prefix */
994 fprintf(cm_outFD,"\n%s %s CM ",printTime,hostname);
996 /* if probe failed print -1 and vanish */
997 if (xstat_cm_Results.probeOK) {
998 fprintf(cm_outFD,"-1\n");
1003 /* print out the probe information as long words */
1004 numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
1005 currLong = (afs_int32 *)(xstat_cm_Results.data.AFSCB_CollData_val);
1007 for(i=0; i<numLongs; i++) {
1008 fprintf(cm_outFD,"%d ",*currLong++);
1010 fprintf(cm_outFD,"\n\n");
1012 /* print out detailed statistics */
1014 Print_cm_FullPerfInfo();
1018 if ( fclose(cm_outFD))
1020 fprintf(debugFD,"[ %s ] failed to close %s\n",rn,a_outfile);