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 *-------------------------------------------------------------------------*/
18 #include <afsconfig.h>
19 #include <afs/param.h>
26 #include <afs/xstat_fs.h>
27 #include <afs/xstat_cm.h>
29 #include "afsmonitor.h"
32 /* Extern Variables */
33 extern int afsmon_debug
; /* debugging on ? */
34 extern FILE *debugFD
; /* debug file FD */
35 extern char errMsg
[256]; /* error message buffer */
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
[] = {
75 static char *cmOpNames
[] = {
85 static char *xferOpNames
[] = {
90 static char *CbCounterStrings
[] = {
109 /*________________________________________________________________________
111 *_______________________________________________________________________*/
113 /*------------------------------------------------------------------------
114 * Print_fs_OverallPerfInfo
117 * Print out overall performance numbers.
120 * a_ovP : Ptr to the overall performance numbers.
126 * Nothing interesting.
130 *------------------------------------------------------------------------*/
133 Print_fs_OverallPerfInfo(struct afs_PerfStats
*a_ovP
)
134 { /*Print_fs_OverallPerfInfo */
136 fprintf(fs_outFD
, "\t%10d numPerfCalls\n\n", a_ovP
->numPerfCalls
);
140 * Vnode cache section.
142 fprintf(fs_outFD
, "\t%10d vcache_L_Entries\n", a_ovP
->vcache_L_Entries
);
143 fprintf(fs_outFD
, "\t%10d vcache_L_Allocs\n", a_ovP
->vcache_L_Allocs
);
144 fprintf(fs_outFD
, "\t%10d vcache_L_Gets\n", a_ovP
->vcache_L_Gets
);
145 fprintf(fs_outFD
, "\t%10d vcache_L_Reads\n", a_ovP
->vcache_L_Reads
);
146 fprintf(fs_outFD
, "\t%10d vcache_L_Writes\n\n", a_ovP
->vcache_L_Writes
);
148 fprintf(fs_outFD
, "\t%10d vcache_S_Entries\n", a_ovP
->vcache_S_Entries
);
149 fprintf(fs_outFD
, "\t%10d vcache_S_Allocs\n", a_ovP
->vcache_S_Allocs
);
150 fprintf(fs_outFD
, "\t%10d vcache_S_Gets\n", a_ovP
->vcache_S_Gets
);
151 fprintf(fs_outFD
, "\t%10d vcache_S_Reads\n", a_ovP
->vcache_S_Reads
);
152 fprintf(fs_outFD
, "\t%10d vcache_S_Writes\n\n", a_ovP
->vcache_S_Writes
);
154 fprintf(fs_outFD
, "\t%10d vcache_H_Entries\n", a_ovP
->vcache_H_Entries
);
155 fprintf(fs_outFD
, "\t%10d vcache_H_Gets\n", a_ovP
->vcache_H_Gets
);
156 fprintf(fs_outFD
, "\t%10d vcache_H_Replacements\n\n",
157 a_ovP
->vcache_H_Replacements
);
160 * Directory package section.
162 fprintf(fs_outFD
, "\t%10d dir_Buffers\n", a_ovP
->dir_Buffers
);
163 fprintf(fs_outFD
, "\t%10d dir_Calls\n", a_ovP
->dir_Calls
);
164 fprintf(fs_outFD
, "\t%10d dir_IOs\n\n", a_ovP
->dir_IOs
);
169 fprintf(fs_outFD
, "\t%10d rx_packetRequests\n", a_ovP
->rx_packetRequests
);
170 fprintf(fs_outFD
, "\t%10d rx_noPackets_RcvClass\n",
171 a_ovP
->rx_noPackets_RcvClass
);
172 fprintf(fs_outFD
, "\t%10d rx_noPackets_SendClass\n",
173 a_ovP
->rx_noPackets_SendClass
);
174 fprintf(fs_outFD
, "\t%10d rx_noPackets_SpecialClass\n",
175 a_ovP
->rx_noPackets_SpecialClass
);
176 fprintf(fs_outFD
, "\t%10d rx_socketGreedy\n", a_ovP
->rx_socketGreedy
);
177 fprintf(fs_outFD
, "\t%10d rx_bogusPacketOnRead\n",
178 a_ovP
->rx_bogusPacketOnRead
);
179 fprintf(fs_outFD
, "\t%10d rx_bogusHost\n", a_ovP
->rx_bogusHost
);
180 fprintf(fs_outFD
, "\t%10d rx_noPacketOnRead\n", a_ovP
->rx_noPacketOnRead
);
181 fprintf(fs_outFD
, "\t%10d rx_noPacketBuffersOnRead\n",
182 a_ovP
->rx_noPacketBuffersOnRead
);
183 fprintf(fs_outFD
, "\t%10d rx_selects\n", a_ovP
->rx_selects
);
184 fprintf(fs_outFD
, "\t%10d rx_sendSelects\n", a_ovP
->rx_sendSelects
);
185 fprintf(fs_outFD
, "\t%10d rx_packetsRead_RcvClass\n",
186 a_ovP
->rx_packetsRead_RcvClass
);
187 fprintf(fs_outFD
, "\t%10d rx_packetsRead_SendClass\n",
188 a_ovP
->rx_packetsRead_SendClass
);
189 fprintf(fs_outFD
, "\t%10d rx_packetsRead_SpecialClass\n",
190 a_ovP
->rx_packetsRead_SpecialClass
);
191 fprintf(fs_outFD
, "\t%10d rx_dataPacketsRead\n",
192 a_ovP
->rx_dataPacketsRead
);
193 fprintf(fs_outFD
, "\t%10d rx_ackPacketsRead\n", a_ovP
->rx_ackPacketsRead
);
194 fprintf(fs_outFD
, "\t%10d rx_dupPacketsRead\n", a_ovP
->rx_dupPacketsRead
);
195 fprintf(fs_outFD
, "\t%10d rx_spuriousPacketsRead\n",
196 a_ovP
->rx_spuriousPacketsRead
);
197 fprintf(fs_outFD
, "\t%10d rx_packetsSent_RcvClass\n",
198 a_ovP
->rx_packetsSent_RcvClass
);
199 fprintf(fs_outFD
, "\t%10d rx_packetsSent_SendClass\n",
200 a_ovP
->rx_packetsSent_SendClass
);
201 fprintf(fs_outFD
, "\t%10d rx_packetsSent_SpecialClass\n",
202 a_ovP
->rx_packetsSent_SpecialClass
);
203 fprintf(fs_outFD
, "\t%10d rx_ackPacketsSent\n", a_ovP
->rx_ackPacketsSent
);
204 fprintf(fs_outFD
, "\t%10d rx_pingPacketsSent\n",
205 a_ovP
->rx_pingPacketsSent
);
206 fprintf(fs_outFD
, "\t%10d rx_abortPacketsSent\n",
207 a_ovP
->rx_abortPacketsSent
);
208 fprintf(fs_outFD
, "\t%10d rx_busyPacketsSent\n",
209 a_ovP
->rx_busyPacketsSent
);
210 fprintf(fs_outFD
, "\t%10d rx_dataPacketsSent\n",
211 a_ovP
->rx_dataPacketsSent
);
212 fprintf(fs_outFD
, "\t%10d rx_dataPacketsReSent\n",
213 a_ovP
->rx_dataPacketsReSent
);
214 fprintf(fs_outFD
, "\t%10d rx_dataPacketsPushed\n",
215 a_ovP
->rx_dataPacketsPushed
);
216 fprintf(fs_outFD
, "\t%10d rx_ignoreAckedPacket\n",
217 a_ovP
->rx_ignoreAckedPacket
);
218 fprintf(fs_outFD
, "\t%10d rx_totalRtt_Sec\n", a_ovP
->rx_totalRtt_Sec
);
219 fprintf(fs_outFD
, "\t%10d rx_totalRtt_Usec\n", a_ovP
->rx_totalRtt_Usec
);
220 fprintf(fs_outFD
, "\t%10d rx_minRtt_Sec\n", a_ovP
->rx_minRtt_Sec
);
221 fprintf(fs_outFD
, "\t%10d rx_minRtt_Usec\n", a_ovP
->rx_minRtt_Usec
);
222 fprintf(fs_outFD
, "\t%10d rx_maxRtt_Sec\n", a_ovP
->rx_maxRtt_Sec
);
223 fprintf(fs_outFD
, "\t%10d rx_maxRtt_Usec\n", a_ovP
->rx_maxRtt_Usec
);
224 fprintf(fs_outFD
, "\t%10d rx_nRttSamples\n", a_ovP
->rx_nRttSamples
);
225 fprintf(fs_outFD
, "\t%10d rx_nServerConns\n", a_ovP
->rx_nServerConns
);
226 fprintf(fs_outFD
, "\t%10d rx_nClientConns\n", a_ovP
->rx_nClientConns
);
227 fprintf(fs_outFD
, "\t%10d rx_nPeerStructs\n", a_ovP
->rx_nPeerStructs
);
228 fprintf(fs_outFD
, "\t%10d rx_nCallStructs\n", a_ovP
->rx_nCallStructs
);
229 fprintf(fs_outFD
, "\t%10d rx_nFreeCallStructs\n",
230 a_ovP
->rx_nFreeCallStructs
);
231 fprintf(fs_outFD
, "\t%10d rx_nBusies\n\n", a_ovP
->rx_nBusies
);
233 fprintf(fs_outFD
, "\t%10d fs_nBusies\n", a_ovP
->fs_nBusies
);
234 fprintf(fs_outFD
, "\t%10d fs_GetCapabilities\n\n", a_ovP
->fs_nGetCaps
);
237 * Host module fields.
239 fprintf(fs_outFD
, "\t%10d host_NumHostEntries\n",
240 a_ovP
->host_NumHostEntries
);
241 fprintf(fs_outFD
, "\t%10d host_HostBlocks\n", a_ovP
->host_HostBlocks
);
242 fprintf(fs_outFD
, "\t%10d host_NonDeletedHosts\n",
243 a_ovP
->host_NonDeletedHosts
);
244 fprintf(fs_outFD
, "\t%10d host_HostsInSameNetOrSubnet\n",
245 a_ovP
->host_HostsInSameNetOrSubnet
);
246 fprintf(fs_outFD
, "\t%10d host_HostsInDiffSubnet\n",
247 a_ovP
->host_HostsInDiffSubnet
);
248 fprintf(fs_outFD
, "\t%10d host_HostsInDiffNetwork\n",
249 a_ovP
->host_HostsInDiffNetwork
);
250 fprintf(fs_outFD
, "\t%10d host_NumClients\n", a_ovP
->host_NumClients
);
251 fprintf(fs_outFD
, "\t%10d host_ClientBlocks\n\n",
252 a_ovP
->host_ClientBlocks
);
254 fprintf(fs_outFD
, "\t%10d sysname_ID\n", a_ovP
->sysname_ID
);
255 } /*Print_fs_OverallPerfInfo */
258 /*------------------------------------------------------------------------
262 * Print out the contents of an RPC op timing structure.
265 * a_opIdx : Index of the AFS operation we're printing number on.
266 * a_opTimeP : Ptr to the op timing structure to print.
272 * Nothing interesting.
276 *------------------------------------------------------------------------*/
279 Print_fs_OpTiming(int a_opIdx
, struct fs_stats_opTimingData
*a_opTimeP
)
280 { /*Print_fs_OpTiming */
283 "%15s: %d ops (%d OK); sum=%ld.%06ld, min=%ld.%06ld, max=%ld.%06ld\n",
284 fsOpNames
[a_opIdx
], a_opTimeP
->numOps
, a_opTimeP
->numSuccesses
,
285 (long)a_opTimeP
->sumTime
.tv_sec
, (long)a_opTimeP
->sumTime
.tv_usec
,
286 (long)a_opTimeP
->minTime
.tv_sec
, (long)a_opTimeP
->minTime
.tv_usec
,
287 (long)a_opTimeP
->maxTime
.tv_sec
, (long)a_opTimeP
->maxTime
.tv_usec
);
289 } /*Print_fs_OpTiming */
292 /*------------------------------------------------------------------------
293 * Print_fs_XferTiming
296 * Print out the contents of a data transfer structure.
299 * a_opIdx : Index of the AFS operation we're printing number on.
300 * a_xferP : Ptr to the data transfer structure to print.
306 * Nothing interesting.
310 *------------------------------------------------------------------------*/
313 Print_fs_XferTiming(int a_opIdx
, struct fs_stats_xferData
*a_xferP
)
314 { /*Print_fs_XferTiming */
317 "%s: %d xfers (%d OK), time sum=%ld.%06ld, min=%ld.%06ld, max=%ld.%06ld\n",
318 xferOpNames
[a_opIdx
], a_xferP
->numXfers
, a_xferP
->numSuccesses
,
319 (long)a_xferP
->sumTime
.tv_sec
, (long)a_xferP
->sumTime
.tv_usec
,
320 (long)a_xferP
->minTime
.tv_sec
, (long)a_xferP
->minTime
.tv_usec
,
321 (long)a_xferP
->maxTime
.tv_sec
, (long)a_xferP
->maxTime
.tv_usec
);
322 fprintf(fs_outFD
, "\t[bytes: sum=%d, min=%d, max=%d]\n",
323 a_xferP
->sumBytes
, a_xferP
->minBytes
, a_xferP
->maxBytes
);
325 "\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
326 a_xferP
->count
[0], a_xferP
->count
[1], a_xferP
->count
[2],
327 a_xferP
->count
[3], a_xferP
->count
[4], a_xferP
->count
[5],
328 a_xferP
->count
[6], a_xferP
->count
[7], a_xferP
->count
[8]);
330 } /*Print_fs_XferTiming */
333 /*------------------------------------------------------------------------
334 * Print_fs_DetailedPerfInfo
337 * Print out a set of detailed performance numbers.
340 * a_detP : Ptr to detailed perf numbers to print.
346 * Nothing interesting.
350 *------------------------------------------------------------------------*/
353 Print_fs_DetailedPerfInfo(struct fs_stats_DetailedStats
*a_detP
)
354 { /*Print_fs_DetailedPerfInfo */
356 int currIdx
; /*Loop variable */
358 fprintf(fs_outFD
, "\t%10ld epoch\n", (long)a_detP
->epoch
.tv_sec
);
360 for (currIdx
= 0; currIdx
< FS_STATS_NUM_RPC_OPS
; currIdx
++)
361 Print_fs_OpTiming(currIdx
, &(a_detP
->rpcOpTimes
[currIdx
]));
363 for (currIdx
= 0; currIdx
< FS_STATS_NUM_XFER_OPS
; currIdx
++)
364 Print_fs_XferTiming(currIdx
, &(a_detP
->xferOpTimes
[currIdx
]));
366 } /*Print_fs_DetailedPerfInfo */
369 /*------------------------------------------------------------------------
370 * Print_fs_FullPerfInfo
373 * Print out the AFS_XSTATSCOLL_FULL_PERF_INFO collection we just
383 * All the info we need is nestled into xstat_fs_Results.
387 *------------------------------------------------------------------------*/
390 Print_fs_FullPerfInfo(struct xstat_fs_ProbeResults
*a_fs_Results
)
391 { /*Print_fs_FullPerfInfo */
392 static afs_int32 fullPerfLongs
= (sizeof(struct fs_stats_FullPerfStats
) >> 2); /*Correct # longs to rcv */
393 afs_int32 numLongs
; /*# longwords received */
394 struct fs_stats_FullPerfStats
*fullPerfP
; /*Ptr to full perf stats */
395 struct fs_stats_FullPerfStats buffer
;
396 char *printableTime
; /*Ptr to printable time string */
401 probeTime
= a_fs_Results
->probeTime
;
402 printableTime
= ctime(&probeTime
);
403 printableTime
[strlen(printableTime
) - 1] = '\0';
406 "AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n",
407 a_fs_Results
->collectionNumber
, a_fs_Results
->connP
->hostName
,
408 a_fs_Results
->probeNum
, printableTime
);
410 code
= xstat_fs_DecodeFullPerfStats(&fullPerfP
,
411 a_fs_Results
->data
.AFS_CollData_val
,
412 a_fs_Results
->data
.AFS_CollData_len
,
415 numLongs
= a_fs_Results
->data
.AFS_CollData_len
;
417 " ** Data size mismatch in full performance collection!\n");
418 fprintf(fs_outFD
, " ** Expecting %d, got %d\n", fullPerfLongs
,
422 Print_fs_OverallPerfInfo(&(fullPerfP
->overall
));
423 Print_fs_DetailedPerfInfo(&(fullPerfP
->det
));
426 } /*Print_fs_FullPerfInfo */
428 /*------------------------------------------------------------------------
429 * Print_fs_CallbackStats
432 * Print out the AFS_XSTATSCOLL_CBSTATS collection we just
442 * All the info we need is nestled into xstat_fs_Results.
446 *------------------------------------------------------------------------*/
448 Print_fs_CallBackStats(struct xstat_fs_ProbeResults
*a_fs_Results
)
452 int numInt32s
= xstat_fs_Results
.data
.AFS_CollData_len
;
453 afs_int32
*val
= xstat_fs_Results
.data
.AFS_CollData_val
;
456 probeTime
= a_fs_Results
->probeTime
;
457 printableTime
= ctime(&probeTime
);
458 printableTime
[strlen(printableTime
) - 1] = '\0';
460 "AFS_XSTATSCOLL_CBSTATS (coll %d) for FS %s\n[Probe %d, %s]\n\n",
461 a_fs_Results
->collectionNumber
, a_fs_Results
->connP
->hostName
,
462 a_fs_Results
->probeNum
, printableTime
);
464 numInt32s
= min(numInt32s
, sizeof(CbCounterStrings
)/sizeof(*CbCounterStrings
));
465 for (i
=0; i
<numInt32s
; i
++) {
466 fprintf(fs_outFD
, "\t%10u %s\n", val
[i
], CbCounterStrings
[i
]);
468 } /*Print_fs_CallbackStats */
470 /*------------------------------------------------------------------------
474 * Prints the contents of xstat_fs_Results to an output file. The
475 * output is either in a compact (longs only) format or a detailed
476 * format giving the names of each of the datums. Output is appended.
479 * Name of output file.
480 * Flag to indicate if detailed output is required.
486 * All the info we need is nestled into xstat_fs_Results.
490 *------------------------------------------------------------------------*/
492 afsmon_fsOutput(char *a_outfile
, /* ptr to output file name */
493 int a_detOutput
) /* detailed output ? */
496 static char rn
[] = "afsmon_fsOutput"; /* routine name */
497 char *printTime
; /* ptr to time string */
498 char *hostname
; /* fileserner name */
499 afs_int32 numLongs
; /* longwords in result */
500 afs_int32
*currLong
; /* ptr to longwords in result */
505 fprintf(debugFD
, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
506 rn
, a_outfile
, a_detOutput
);
510 fs_outFD
= fopen(a_outfile
, "a");
511 if (fs_outFD
== (FILE *) 0) {
512 sprintf(errMsg
, "[ %s ] failed to open output file %s", rn
,
517 /* get the probe time and strip the \n at the end */
518 probeTime
= xstat_fs_Results
.probeTime
;
519 printTime
= ctime(&probeTime
);
520 printTime
[strlen(printTime
) - 1] = '\0';
521 hostname
= xstat_fs_Results
.connP
->hostName
;
523 /* print "time hostname FS" */
524 fprintf(fs_outFD
, "\n%s %s FS ", printTime
, hostname
);
526 /* if probe failed print -1 and return */
527 if (xstat_fs_Results
.probeOK
) {
528 fprintf(fs_outFD
, "-1\n");
533 /* print out the probe information as long words */
534 numLongs
= xstat_fs_Results
.data
.AFS_CollData_len
;
535 currLong
= (afs_int32
*) (xstat_fs_Results
.data
.AFS_CollData_val
);
537 for (i
= 0; i
< numLongs
; i
++) {
538 fprintf(fs_outFD
, "%d ", *currLong
++);
540 fprintf(fs_outFD
, "\n\n");
542 /* print detailed information */
544 if (xstat_fs_Results
.collectionNumber
==
545 AFS_XSTATSCOLL_FULL_PERF_INFO
) {
546 Print_fs_FullPerfInfo(&xstat_fs_Results
);
548 } else if (xstat_fs_Results
.collectionNumber
==
549 AFS_XSTATSCOLL_CBSTATS
) {
550 Print_fs_CallBackStats(&xstat_fs_Results
);
555 if (fclose(fs_outFD
))
557 fprintf(debugFD
, "[ %s ] failed to close %s\n", rn
, a_outfile
);
564 /*___________________________________________________________________________
566 *__________________________________________________________________________*/
570 /*------------------------------------------------------------------------
571 * Print_cm_UpDownStats
574 * Print the up/downtime stats for the given class of server records
578 * a_upDownP : Ptr to the server up/down info.
584 * Nothing interesting.
588 *------------------------------------------------------------------------*/
591 Print_cm_UpDownStats(struct afs_stats_SrvUpDownInfo
*a_upDownP
) /*Ptr to server up/down info */
592 { /*Print_cm_UpDownStats */
595 * First, print the simple values.
597 fprintf(cm_outFD
, "\t\t%10d numTtlRecords\n", a_upDownP
->numTtlRecords
);
598 fprintf(cm_outFD
, "\t\t%10d numUpRecords\n", a_upDownP
->numUpRecords
);
599 fprintf(cm_outFD
, "\t\t%10d numDownRecords\n", a_upDownP
->numDownRecords
);
600 fprintf(cm_outFD
, "\t\t%10d sumOfRecordAges\n",
601 a_upDownP
->sumOfRecordAges
);
602 fprintf(cm_outFD
, "\t\t%10d ageOfYoungestRecord\n",
603 a_upDownP
->ageOfYoungestRecord
);
604 fprintf(cm_outFD
, "\t\t%10d ageOfOldestRecord\n",
605 a_upDownP
->ageOfOldestRecord
);
606 fprintf(cm_outFD
, "\t\t%10d numDowntimeIncidents\n",
607 a_upDownP
->numDowntimeIncidents
);
608 fprintf(cm_outFD
, "\t\t%10d numRecordsNeverDown\n",
609 a_upDownP
->numRecordsNeverDown
);
610 fprintf(cm_outFD
, "\t\t%10d maxDowntimesInARecord\n",
611 a_upDownP
->maxDowntimesInARecord
);
612 fprintf(cm_outFD
, "\t\t%10d sumOfDowntimes\n", a_upDownP
->sumOfDowntimes
);
613 fprintf(cm_outFD
, "\t\t%10d shortestDowntime\n",
614 a_upDownP
->shortestDowntime
);
615 fprintf(cm_outFD
, "\t\t%10d longestDowntime\n",
616 a_upDownP
->longestDowntime
);
619 * Now, print the array values.
621 fprintf(cm_outFD
, "\t\tDowntime duration distribution:\n");
622 fprintf(cm_outFD
, "\t\t\t%8d: 0 min .. 10 min\n",
623 a_upDownP
->downDurations
[0]);
624 fprintf(cm_outFD
, "\t\t\t%8d: 10 min .. 30 min\n",
625 a_upDownP
->downDurations
[1]);
626 fprintf(cm_outFD
, "\t\t\t%8d: 30 min .. 1 hr\n",
627 a_upDownP
->downDurations
[2]);
628 fprintf(cm_outFD
, "\t\t\t%8d: 1 hr .. 2 hr\n",
629 a_upDownP
->downDurations
[3]);
630 fprintf(cm_outFD
, "\t\t\t%8d: 2 hr .. 4 hr\n",
631 a_upDownP
->downDurations
[4]);
632 fprintf(cm_outFD
, "\t\t\t%8d: 4 hr .. 8 hr\n",
633 a_upDownP
->downDurations
[5]);
634 fprintf(cm_outFD
, "\t\t\t%8d: > 8 hr\n", a_upDownP
->downDurations
[6]);
636 fprintf(cm_outFD
, "\t\tDowntime incident distribution:\n");
637 fprintf(cm_outFD
, "\t\t\t%8d: 0 times\n", a_upDownP
->downIncidents
[0]);
638 fprintf(cm_outFD
, "\t\t\t%8d: 1 time\n", a_upDownP
->downIncidents
[1]);
639 fprintf(cm_outFD
, "\t\t\t%8d: 2 .. 5 times\n",
640 a_upDownP
->downIncidents
[2]);
641 fprintf(cm_outFD
, "\t\t\t%8d: 6 .. 10 times\n",
642 a_upDownP
->downIncidents
[3]);
643 fprintf(cm_outFD
, "\t\t\t%8d: 10 .. 50 times\n",
644 a_upDownP
->downIncidents
[4]);
645 fprintf(cm_outFD
, "\t\t\t%8d: > 50 times\n", a_upDownP
->downIncidents
[5]);
647 } /*Print_cm_UpDownStats */
650 /*------------------------------------------------------------------------
651 * Print_cm_OverallPerfInfo
654 * Print out overall performance numbers.
657 * a_ovP : Ptr to the overall performance numbers.
663 * All the info we need is nestled into xstat_cm_Results.
667 *------------------------------------------------------------------------*/
670 Print_cm_OverallPerfInfo(struct afs_stats_CMPerf
*a_ovP
)
671 { /*Print_cm_OverallPerfInfo */
673 fprintf(cm_outFD
, "\t%10d numPerfCalls\n", a_ovP
->numPerfCalls
);
675 fprintf(cm_outFD
, "\t%10d epoch\n", a_ovP
->epoch
);
676 fprintf(cm_outFD
, "\t%10d numCellsVisible\n", a_ovP
->numCellsVisible
);
677 fprintf(cm_outFD
, "\t%10d numCellsContacted\n", a_ovP
->numCellsContacted
);
678 fprintf(cm_outFD
, "\t%10d dlocalAccesses\n", a_ovP
->dlocalAccesses
);
679 fprintf(cm_outFD
, "\t%10d vlocalAccesses\n", a_ovP
->vlocalAccesses
);
680 fprintf(cm_outFD
, "\t%10d dremoteAccesses\n", a_ovP
->dremoteAccesses
);
681 fprintf(cm_outFD
, "\t%10d vremoteAccesses\n", a_ovP
->vremoteAccesses
);
682 fprintf(cm_outFD
, "\t%10d cacheNumEntries\n", a_ovP
->cacheNumEntries
);
683 fprintf(cm_outFD
, "\t%10d cacheBlocksTotal\n", a_ovP
->cacheBlocksTotal
);
684 fprintf(cm_outFD
, "\t%10d cacheBlocksInUse\n", a_ovP
->cacheBlocksInUse
);
685 fprintf(cm_outFD
, "\t%10d cacheBlocksOrig\n", a_ovP
->cacheBlocksOrig
);
686 fprintf(cm_outFD
, "\t%10d cacheMaxDirtyChunks\n",
687 a_ovP
->cacheMaxDirtyChunks
);
688 fprintf(cm_outFD
, "\t%10d cacheCurrDirtyChunks\n",
689 a_ovP
->cacheCurrDirtyChunks
);
690 fprintf(cm_outFD
, "\t%10d dcacheHits\n", a_ovP
->dcacheHits
);
691 fprintf(cm_outFD
, "\t%10d vcacheHits\n", a_ovP
->vcacheHits
);
692 fprintf(cm_outFD
, "\t%10d dcacheMisses\n", a_ovP
->dcacheMisses
);
693 fprintf(cm_outFD
, "\t%10d vcacheMisses\n", a_ovP
->vcacheMisses
);
694 fprintf(cm_outFD
, "\t%10d cacheFilesReused\n", a_ovP
->cacheFilesReused
);
695 fprintf(cm_outFD
, "\t%10d vcacheXAllocs\n", a_ovP
->vcacheXAllocs
);
697 fprintf(cm_outFD
, "\t%10d bufAlloced\n", a_ovP
->bufAlloced
);
698 fprintf(cm_outFD
, "\t%10d bufHits\n", a_ovP
->bufHits
);
699 fprintf(cm_outFD
, "\t%10d bufMisses\n", a_ovP
->bufMisses
);
700 fprintf(cm_outFD
, "\t%10d bufFlushDirty\n", a_ovP
->bufFlushDirty
);
702 fprintf(cm_outFD
, "\t%10d LargeBlocksActive\n", a_ovP
->LargeBlocksActive
);
703 fprintf(cm_outFD
, "\t%10d LargeBlocksAlloced\n",
704 a_ovP
->LargeBlocksAlloced
);
705 fprintf(cm_outFD
, "\t%10d SmallBlocksActive\n", a_ovP
->SmallBlocksActive
);
706 fprintf(cm_outFD
, "\t%10d SmallBlocksAlloced\n",
707 a_ovP
->SmallBlocksAlloced
);
708 fprintf(cm_outFD
, "\t%10d OutStandingMemUsage\n",
709 a_ovP
->OutStandingMemUsage
);
710 fprintf(cm_outFD
, "\t%10d OutStandingAllocs\n", a_ovP
->OutStandingAllocs
);
711 fprintf(cm_outFD
, "\t%10d CallBackAlloced\n", a_ovP
->CallBackAlloced
);
712 fprintf(cm_outFD
, "\t%10d CallBackFlushes\n", a_ovP
->CallBackFlushes
);
714 fprintf(cm_outFD
, "\t%10d srvRecords\n", a_ovP
->srvRecords
);
715 fprintf(cm_outFD
, "\t%10d srvNumBuckets\n", a_ovP
->srvNumBuckets
);
716 fprintf(cm_outFD
, "\t%10d srvMaxChainLength\n", a_ovP
->srvMaxChainLength
);
717 fprintf(cm_outFD
, "\t%10d srvMaxChainLengthHWM\n",
718 a_ovP
->srvMaxChainLengthHWM
);
719 fprintf(cm_outFD
, "\t%10d srvRecordsHWM\n", a_ovP
->srvRecordsHWM
);
721 fprintf(cm_outFD
, "\t%10d sysName_ID\n", a_ovP
->sysName_ID
);
723 fprintf(cm_outFD
, "\tFile Server up/downtimes, same cell:\n");
724 Print_cm_UpDownStats(&(a_ovP
->fs_UpDown
[0]));
726 fprintf(cm_outFD
, "\tFile Server up/downtimes, diff cell:\n");
727 Print_cm_UpDownStats(&(a_ovP
->fs_UpDown
[1]));
729 fprintf(cm_outFD
, "\tVL Server up/downtimes, same cell:\n");
730 Print_cm_UpDownStats(&(a_ovP
->vl_UpDown
[0]));
732 fprintf(cm_outFD
, "\tVL Server up/downtimes, diff cell:\n");
733 Print_cm_UpDownStats(&(a_ovP
->vl_UpDown
[1]));
735 } /*Print_cm_OverallPerfInfo */
738 /*------------------------------------------------------------------------
742 * Print out the AFSCB_XSTATSCOLL_PERF_INFO collection we just
752 * All the info we need is nestled into xstat_cm_Results.
756 *------------------------------------------------------------------------*/
759 Print_cm_PerfInfo(void)
760 { /*Print_cm_PerfInfo */
761 static afs_int32 perfLongs
= (sizeof(struct afs_stats_CMPerf
) >> 2); /*Correct # longs to rcv */
762 afs_int32 numLongs
; /*# longwords received */
763 struct afs_stats_CMPerf
*perfP
; /*Ptr to performance stats */
764 char *printableTime
; /*Ptr to printable time string */
767 numLongs
= xstat_cm_Results
.data
.AFSCB_CollData_len
;
768 if (numLongs
!= perfLongs
) {
770 " ** Data size mismatch in performance collection!\n");
771 fprintf(cm_outFD
, "** Expecting %d, got %d\n", perfLongs
, numLongs
);
775 probeTime
= xstat_cm_Results
.probeTime
;
776 printableTime
= ctime(&probeTime
);
777 printableTime
[strlen(printableTime
) - 1] = '\0';
778 perfP
= (struct afs_stats_CMPerf
*)
779 (xstat_cm_Results
.data
.AFSCB_CollData_val
);
782 "AFSCB_XSTATSCOLL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
783 xstat_cm_Results
.collectionNumber
,
784 xstat_cm_Results
.connP
->hostName
, xstat_cm_Results
.probeNum
,
787 Print_cm_OverallPerfInfo(perfP
);
789 } /*Print_cm_PerfInfo */
792 /*------------------------------------------------------------------------
796 * Print out the contents of an FS RPC op timing structure.
799 * a_opIdx : Index of the AFS operation we're printing number on.
800 * a_opNames : Ptr to table of operaton names.
801 * a_opTimeP : Ptr to the op timing structure to print.
807 * Nothing interesting.
811 *------------------------------------------------------------------------*/
814 Print_cm_OpTiming(int a_opIdx
, char *a_opNames
[],
815 struct afs_stats_opTimingData
*a_opTimeP
)
816 { /*Print_cm_OpTiming */
819 "%15s: %d ops (%d OK); sum=%ld.%06ld, min=%ld.%06ld, max=%ld.%06ld\n",
820 a_opNames
[a_opIdx
], a_opTimeP
->numOps
, a_opTimeP
->numSuccesses
,
821 (long)a_opTimeP
->sumTime
.tv_sec
, (long)a_opTimeP
->sumTime
.tv_usec
,
822 (long)a_opTimeP
->minTime
.tv_sec
, (long)a_opTimeP
->minTime
.tv_usec
,
823 (long)a_opTimeP
->maxTime
.tv_sec
, (long)a_opTimeP
->maxTime
.tv_usec
);
825 } /*Print_cm_OpTiming */
828 /*------------------------------------------------------------------------
829 * Print_cm_XferTiming
832 * Print out the contents of a data transfer structure.
835 * a_opIdx : Index of the AFS operation we're printing number on.
836 * a_xferP : Ptr to the data transfer structure to print.
842 * Nothing interesting.
846 *------------------------------------------------------------------------*/
849 Print_cm_XferTiming(int a_opIdx
, char *a_opNames
[],
850 struct afs_stats_xferData
*a_xferP
)
851 { /*Print_cm_XferTiming */
854 "%s: %d xfers (%d OK), time sum=%ld.%06ld, min=%ld.%06ld, max=%ld.%06ld\n",
855 a_opNames
[a_opIdx
], a_xferP
->numXfers
, a_xferP
->numSuccesses
,
856 (long)a_xferP
->sumTime
.tv_sec
, (long)a_xferP
->sumTime
.tv_usec
,
857 (long)a_xferP
->minTime
.tv_sec
, (long)a_xferP
->minTime
.tv_usec
,
858 (long)a_xferP
->maxTime
.tv_sec
, (long)a_xferP
->maxTime
.tv_usec
);
859 fprintf(cm_outFD
, "\t[bytes: sum=%d, min=%d, max=%d]\n",
860 a_xferP
->sumBytes
, a_xferP
->minBytes
, a_xferP
->maxBytes
);
862 "\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n",
863 a_xferP
->count
[0], a_xferP
->count
[1], a_xferP
->count
[2],
864 a_xferP
->count
[3], a_xferP
->count
[4], a_xferP
->count
[5],
865 a_xferP
->count
[6], a_xferP
->count
[7], a_xferP
->count
[8]);
867 } /*Print_cm_XferTiming */
870 /*------------------------------------------------------------------------
874 * Print out the contents of an FS RPC error info structure.
877 * a_opIdx : Index of the AFS operation we're printing.
878 * a_opNames : Ptr to table of operation names.
879 * a_opErrP : Ptr to the op timing structure to print.
885 * Nothing interesting.
889 *------------------------------------------------------------------------*/
892 Print_cm_ErrInfo(int a_opIdx
, char *a_opNames
[],
893 struct afs_stats_RPCErrors
*a_opErrP
)
894 { /*Print_cm_ErrInfo */
897 "%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n",
898 a_opNames
[a_opIdx
], a_opErrP
->err_Server
, a_opErrP
->err_Network
,
899 a_opErrP
->err_Protection
, a_opErrP
->err_Volume
,
900 a_opErrP
->err_VolumeBusies
, a_opErrP
->err_Other
);
902 } /*Print_cm_ErrInfo */
905 /*------------------------------------------------------------------------
906 * Print_cm_RPCPerfInfo
909 * Print out a set of RPC performance numbers.
912 * a_rpcP : Ptr to RPC perf numbers to print.
918 * Nothing interesting.
922 *------------------------------------------------------------------------*/
925 Print_cm_RPCPerfInfo(struct afs_stats_RPCOpInfo
*a_rpcP
)
926 { /*Print_cm_RPCPerfInfo */
928 int currIdx
; /*Loop variable */
931 * Print the contents of each of the opcode-related arrays.
933 fprintf(cm_outFD
, "FS Operation Timings:\n---------------------\n");
934 for (currIdx
= 0; currIdx
< AFS_STATS_NUM_FS_RPC_OPS
; currIdx
++)
935 Print_cm_OpTiming(currIdx
, fsOpNames
, &(a_rpcP
->fsRPCTimes
[currIdx
]));
937 fprintf(cm_outFD
, "\nError Info:\n-----------\n");
938 for (currIdx
= 0; currIdx
< AFS_STATS_NUM_FS_RPC_OPS
; currIdx
++)
939 Print_cm_ErrInfo(currIdx
, fsOpNames
, &(a_rpcP
->fsRPCErrors
[currIdx
]));
941 fprintf(cm_outFD
, "\nTransfer timings:\n-----------------\n");
942 for (currIdx
= 0; currIdx
< AFS_STATS_NUM_FS_XFER_OPS
; currIdx
++)
943 Print_cm_XferTiming(currIdx
, xferOpNames
,
944 &(a_rpcP
->fsXferTimes
[currIdx
]));
946 fprintf(cm_outFD
, "\nCM Operation Timings:\n---------------------\n");
947 for (currIdx
= 0; currIdx
< AFS_STATS_NUM_CM_RPC_OPS
; currIdx
++)
948 Print_cm_OpTiming(currIdx
, cmOpNames
, &(a_rpcP
->cmRPCTimes
[currIdx
]));
950 } /*Print_cm_RPCPerfInfo */
953 /*------------------------------------------------------------------------
954 * Print_cm_FullPerfInfo
957 * Print out a set of full performance numbers.
966 * Nothing interesting.
970 *------------------------------------------------------------------------*/
973 Print_cm_FullPerfInfo(void)
974 { /*Print_cm_FullPerfInfo */
976 struct afs_stats_AuthentInfo
*authentP
; /*Ptr to authentication stats */
977 struct afs_stats_AccessInfo
*accessinfP
; /*Ptr to access stats */
978 static afs_int32 fullPerfLongs
= (sizeof(struct afs_stats_CMFullPerf
) >> 2); /*Correct #longs */
979 afs_int32 numLongs
; /*# longs actually received */
980 struct afs_stats_CMFullPerf
*fullP
; /*Ptr to full perf info */
982 char *printableTime
; /*Ptr to printable time string */
984 numLongs
= xstat_cm_Results
.data
.AFSCB_CollData_len
;
985 if (numLongs
!= fullPerfLongs
) {
987 " ** Data size mismatch in performance collection!\n");
988 fprintf(cm_outFD
, " ** Expecting %d, got %d\n", fullPerfLongs
,
993 probeTime
= xstat_cm_Results
.probeTime
;
994 printableTime
= ctime(&probeTime
);
995 printableTime
[strlen(printableTime
) - 1] = '\0';
996 fullP
= (struct afs_stats_CMFullPerf
*)
997 (xstat_cm_Results
.data
.AFSCB_CollData_val
);
1000 "AFSCB_XSTATSCOLL_FULL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n",
1001 xstat_cm_Results
.collectionNumber
,
1002 xstat_cm_Results
.connP
->hostName
, xstat_cm_Results
.probeNum
,
1006 * Print the overall numbers first, followed by all of the RPC numbers,
1007 * then each of the other groupings.
1010 "Overall Performance Info:\n-------------------------\n");
1011 Print_cm_OverallPerfInfo(&(fullP
->perf
));
1012 fprintf(cm_outFD
, "\n");
1013 Print_cm_RPCPerfInfo(&(fullP
->rpc
));
1015 authentP
= &(fullP
->authent
);
1016 fprintf(cm_outFD
, "\nAuthentication info:\n--------------------\n");
1018 "\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n",
1019 authentP
->curr_PAGs
, authentP
->curr_Records
,
1020 authentP
->curr_AuthRecords
, authentP
->curr_UnauthRecords
,
1021 authentP
->curr_MaxRecordsInPAG
, authentP
->curr_LongestChain
);
1022 fprintf(cm_outFD
, "\t%d PAG creations, %d tkt updates\n",
1023 authentP
->PAGCreations
, authentP
->TicketUpdates
);
1025 "\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n",
1026 authentP
->HWM_PAGs
, authentP
->HWM_Records
,
1027 authentP
->HWM_MaxRecordsInPAG
, authentP
->HWM_LongestChain
);
1029 accessinfP
= &(fullP
->accessinf
);
1031 "\n[Un]replicated accesses:\n------------------------\n");
1033 "\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n",
1034 accessinfP
->unreplicatedRefs
, accessinfP
->replicatedRefs
,
1035 accessinfP
->numReplicasAccessed
, accessinfP
->maxReplicasPerRef
,
1036 accessinfP
->refFirstReplicaOK
);
1038 /* There really isn't any authorship info
1039 * authorP = &(fullP->author); */
1041 } /*Print_cm_FullPerfInfo */
1043 /*------------------------------------------------------------------------
1047 * Prints the contents of xstat_cm_Results to an output file. The
1048 * output is either in a compact (longs only) format or a detailed
1049 * format giving the names of each of the datums. Output is appended.
1052 * Name of output file.
1053 * Flag to indicate if detailed output is required.
1059 * All the info we need is nestled into xstat_cm_Results.
1063 *------------------------------------------------------------------------*/
1065 afsmon_cmOutput(char *a_outfile
, /* ptr to output file name */
1066 int a_detOutput
) /* detailed output ? */
1069 static char rn
[] = "afsmon_cmOutput"; /* routine name */
1070 char *printTime
; /* ptr to time string */
1071 char *hostname
; /* fileserner name */
1072 afs_int32 numLongs
; /* longwords in result */
1073 afs_int32
*currLong
; /* ptr to longwords in result */
1078 fprintf(debugFD
, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
1079 rn
, a_outfile
, a_detOutput
);
1083 /* need to lock this file before writing */
1084 cm_outFD
= fopen(a_outfile
, "a");
1085 if (cm_outFD
== (FILE *) 0) {
1086 sprintf(errMsg
, "[ %s ] failed to open output file %s", rn
,
1091 /* get the probe time and strip the \n at the end */
1092 probeTime
= xstat_cm_Results
.probeTime
;
1093 printTime
= ctime(&probeTime
);
1094 printTime
[strlen(printTime
) - 1] = '\0';
1095 hostname
= xstat_cm_Results
.connP
->hostName
;
1097 /* print "time hostname CM" prefix */
1098 fprintf(cm_outFD
, "\n%s %s CM ", printTime
, hostname
);
1100 /* if probe failed print -1 and vanish */
1101 if (xstat_cm_Results
.probeOK
) {
1102 fprintf(cm_outFD
, "-1\n");
1107 /* print out the probe information as long words */
1108 numLongs
= xstat_cm_Results
.data
.AFSCB_CollData_len
;
1109 currLong
= (afs_int32
*) (xstat_cm_Results
.data
.AFSCB_CollData_val
);
1111 for (i
= 0; i
< numLongs
; i
++) {
1112 fprintf(cm_outFD
, "%d ", *currLong
++);
1114 fprintf(cm_outFD
, "\n\n");
1116 /* print out detailed statistics */
1118 Print_cm_FullPerfInfo();
1122 if (fclose(cm_outFD
))
1124 fprintf(debugFD
, "[ %s ] failed to close %s\n", rn
, a_outfile
);