afsmonitor: Add missing items to fsOpNames array
[openafs.git] / src / afsmonitor / afsmon-output.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
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
8  */
9
10 /*
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
14  *              xstat_cm_test.c
15  *
16  *-------------------------------------------------------------------------*/
17
18 #include <afsconfig.h>
19 #include <afs/param.h>
20
21 #include <stdio.h>
22 #include <time.h>
23 #include <string.h>
24
25
26 #include <afs/xstat_fs.h>
27 #include <afs/xstat_cm.h>
28
29 #include "afsmonitor.h"
30
31
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 */
36
37 static FILE *fs_outFD;          /* fs output file descriptor */
38 static FILE *cm_outFD;          /* cm output file descriptor */
39
40 /* structures used by FS & CM stats print routines */
41
42 static char *fsOpNames[] = {
43     "FetchData",
44     "FetchACL",
45     "FetchStatus",
46     "StoreData",
47     "StoreACL",
48     "StoreStatus",
49     "RemoveFile",
50     "CreateFile",
51     "Rename",
52     "Symlink",
53     "Link",
54     "MakeDir",
55     "RemoveDir",
56     "SetLock",
57     "ExtendLock",
58     "ReleaseLock",
59     "GetStatistics",
60     "GiveUpCallbacks",
61     "GetVolumeInfo",
62     "GetVolumeStatus",
63     "SetVolumeStatus",
64     "GetRootVolume",
65     "CheckToken",
66     "GetTime",
67     "NGetVolumeInfo",
68     "BulkStatus",
69     "XStatsVersion",
70     "GetXStats",
71     "Lookup",
72     "Residency"
73 };
74
75 static char *cmOpNames[] = {
76     "CallBack",
77     "InitCallBackState",
78     "Probe",
79     "GetLock",
80     "GetCE",
81     "XStatsVersion",
82     "GetXStats"
83 };
84
85 static char *xferOpNames[] = {
86     "FetchData",
87     "StoreData"
88 };
89
90 static char *CbCounterStrings[] = {
91     "DeleteFiles",
92     "DeleteCallBacks",
93     "BreakCallBacks",
94     "AddCallBack",
95     "GotSomeSpaces",
96     "DeleteAllCallBacks",
97     "nFEs",
98     "nCBs",
99     "nblks",
100     "CBsTimedOut",
101     "nbreakers",
102     "GSS1",
103     "GSS2",
104     "GSS3",
105     "GSS4",
106     "GSS5"
107 };
108
109 /*________________________________________________________________________
110                                 FS STATS ROUTINES
111  *_______________________________________________________________________*/
112
113 /*------------------------------------------------------------------------
114  * Print_fs_OverallPerfInfo
115  *
116  * Description:
117  *      Print out overall performance numbers.
118  *
119  * Arguments:
120  *      a_ovP : Ptr to the overall performance numbers.
121  *
122  * Returns:
123  *      Nothing.
124  *
125  * Environment:
126  *      Nothing interesting.
127  *
128  * Side Effects:
129  *      As advertised.
130  *------------------------------------------------------------------------*/
131
132 void
133 Print_fs_OverallPerfInfo(struct afs_PerfStats *a_ovP)
134 {                               /*Print_fs_OverallPerfInfo */
135
136     fprintf(fs_outFD, "\t%10d numPerfCalls\n\n", a_ovP->numPerfCalls);
137
138
139     /*
140      * Vnode cache section.
141      */
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);
147
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);
153
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);
158
159     /*
160      * Directory package section.
161      */
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);
165
166     /*
167      * Rx section.
168      */
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);
232
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);
235
236     /*
237      * Host module fields.
238      */
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);
253
254     fprintf(fs_outFD, "\t%10d sysname_ID\n", a_ovP->sysname_ID);
255 }                               /*Print_fs_OverallPerfInfo */
256
257
258 /*------------------------------------------------------------------------
259  * Print_fs_OpTiming
260  *
261  * Description:
262  *      Print out the contents of an RPC op timing structure.
263  *
264  * Arguments:
265  *      a_opIdx   : Index of the AFS operation we're printing number on.
266  *      a_opTimeP : Ptr to the op timing structure to print.
267  *
268  * Returns:
269  *      Nothing.
270  *
271  * Environment:
272  *      Nothing interesting.
273  *
274  * Side Effects:
275  *      As advertised.
276  *------------------------------------------------------------------------*/
277
278 void
279 Print_fs_OpTiming(int a_opIdx, struct fs_stats_opTimingData *a_opTimeP)
280 {                               /*Print_fs_OpTiming */
281
282     fprintf(fs_outFD,
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);
288
289 }                               /*Print_fs_OpTiming */
290
291
292 /*------------------------------------------------------------------------
293  * Print_fs_XferTiming
294  *
295  * Description:
296  *      Print out the contents of a data transfer structure.
297  *
298  * Arguments:
299  *      a_opIdx : Index of the AFS operation we're printing number on.
300  *      a_xferP : Ptr to the data transfer structure to print.
301  *
302  * Returns:
303  *      Nothing.
304  *
305  * Environment:
306  *      Nothing interesting.
307  *
308  * Side Effects:
309  *      As advertised.
310  *------------------------------------------------------------------------*/
311
312 void
313 Print_fs_XferTiming(int a_opIdx, struct fs_stats_xferData *a_xferP)
314 {                               /*Print_fs_XferTiming */
315
316     fprintf(fs_outFD,
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);
324     fprintf(fs_outFD,
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]);
329
330 }                               /*Print_fs_XferTiming */
331
332
333 /*------------------------------------------------------------------------
334  * Print_fs_DetailedPerfInfo
335  *
336  * Description:
337  *      Print out a set of detailed performance numbers.
338  *
339  * Arguments:
340  *      a_detP : Ptr to detailed perf numbers to print.
341  *
342  * Returns:
343  *      Nothing.
344  *
345  * Environment:
346  *      Nothing interesting.
347  *
348  * Side Effects:
349  *      As advertised.
350  *------------------------------------------------------------------------*/
351
352 void
353 Print_fs_DetailedPerfInfo(struct fs_stats_DetailedStats *a_detP)
354 {                               /*Print_fs_DetailedPerfInfo */
355
356     int currIdx;                /*Loop variable */
357
358     fprintf(fs_outFD, "\t%10ld epoch\n", (long)a_detP->epoch.tv_sec);
359
360     for (currIdx = 0; currIdx < FS_STATS_NUM_RPC_OPS; currIdx++)
361         Print_fs_OpTiming(currIdx, &(a_detP->rpcOpTimes[currIdx]));
362
363     for (currIdx = 0; currIdx < FS_STATS_NUM_XFER_OPS; currIdx++)
364         Print_fs_XferTiming(currIdx, &(a_detP->xferOpTimes[currIdx]));
365
366 }                               /*Print_fs_DetailedPerfInfo */
367
368
369 /*------------------------------------------------------------------------
370  * Print_fs_FullPerfInfo
371  *
372  * Description:
373  *      Print out the AFS_XSTATSCOLL_FULL_PERF_INFO collection we just
374  *      received.
375  *
376  * Arguments:
377  *      None.
378  *
379  * Returns:
380  *      Nothing.
381  *
382  * Environment:
383  *      All the info we need is nestled into xstat_fs_Results.
384  *
385  * Side Effects:
386  *      As advertised.
387  *------------------------------------------------------------------------*/
388
389 void
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 */
397     time_t probeTime;
398     int code;
399
400
401     probeTime = a_fs_Results->probeTime;
402     printableTime = ctime(&probeTime);
403     printableTime[strlen(printableTime) - 1] = '\0';
404
405     fprintf(fs_outFD,
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);
409
410     code = xstat_fs_DecodeFullPerfStats(&fullPerfP,
411                                         a_fs_Results->data.AFS_CollData_val,
412                                         a_fs_Results->data.AFS_CollData_len,
413                                         &buffer);
414     if (code) {
415         numLongs = a_fs_Results->data.AFS_CollData_len;
416         fprintf(fs_outFD,
417                 " ** Data size mismatch in full performance collection!\n");
418         fprintf(fs_outFD, " ** Expecting %d, got %d\n", fullPerfLongs,
419                 numLongs);
420
421     } else {
422         Print_fs_OverallPerfInfo(&(fullPerfP->overall));
423         Print_fs_DetailedPerfInfo(&(fullPerfP->det));
424     }
425
426 }                               /*Print_fs_FullPerfInfo */
427
428 /*------------------------------------------------------------------------
429  * Print_fs_CallbackStats
430  *
431  * Description:
432  *      Print out the AFS_XSTATSCOLL_CBSTATS collection we just
433  *      received.
434  *
435  * Arguments:
436  *      None.
437  *
438  * Returns:
439  *      Nothing.
440  *
441  * Environment:
442  *      All the info we need is nestled into xstat_fs_Results.
443  *
444  * Side Effects:
445  *      As advertised.
446  *------------------------------------------------------------------------*/
447 void
448 Print_fs_CallBackStats(struct xstat_fs_ProbeResults *a_fs_Results)
449 {
450     char *printableTime;
451     time_t probeTime;
452     int numInt32s = xstat_fs_Results.data.AFS_CollData_len;
453     afs_int32 *val = xstat_fs_Results.data.AFS_CollData_val;
454     int i;
455
456     probeTime = a_fs_Results->probeTime;
457     printableTime = ctime(&probeTime);
458     printableTime[strlen(printableTime) - 1] = '\0';
459     fprintf(fs_outFD,
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);
463
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]);
467     }
468 }                               /*Print_fs_CallbackStats */
469
470 /*------------------------------------------------------------------------
471  * afsmon_fsOutput()
472  *
473  * Description:
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.
477  *
478  * Arguments:
479  *      Name of output file.
480  *      Flag to indicate if detailed output is required.
481  *
482  * Returns:
483  *      Nothing.
484  *
485  * Environment:
486  *      All the info we need is nestled into xstat_fs_Results.
487  *
488  * Side Effects:
489  *      As advertised.
490  *------------------------------------------------------------------------*/
491 int
492 afsmon_fsOutput(char *a_outfile,        /* ptr to output file name */
493                 int a_detOutput)        /* detailed output ? */
494 {
495
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 */
501     int i;
502     time_t probeTime;
503
504     if (afsmon_debug) {
505         fprintf(debugFD, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
506                 rn, a_outfile, a_detOutput);
507         fflush(debugFD);
508     }
509
510     fs_outFD = fopen(a_outfile, "a");
511     if (fs_outFD == (FILE *) 0) {
512         sprintf(errMsg, "[ %s ] failed to open output file %s", rn,
513                 a_outfile);
514         afsmon_Exit(1);
515     }
516
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;
522
523     /* print "time hostname FS" */
524     fprintf(fs_outFD, "\n%s %s FS ", printTime, hostname);
525
526     /* if probe failed print -1 and return */
527     if (xstat_fs_Results.probeOK) {
528         fprintf(fs_outFD, "-1\n");
529         fclose(fs_outFD);
530         return (0);
531     }
532
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);
536
537     for (i = 0; i < numLongs; i++) {
538         fprintf(fs_outFD, "%d ", *currLong++);
539     }
540     fprintf(fs_outFD, "\n\n");
541
542     /* print detailed information */
543     if (a_detOutput) {
544         if (xstat_fs_Results.collectionNumber ==
545             AFS_XSTATSCOLL_FULL_PERF_INFO) {
546             Print_fs_FullPerfInfo(&xstat_fs_Results);
547             fflush(fs_outFD);
548         } else if (xstat_fs_Results.collectionNumber ==
549                    AFS_XSTATSCOLL_CBSTATS) {
550             Print_fs_CallBackStats(&xstat_fs_Results);
551             fflush(fs_outFD);
552         }
553     }
554
555     if (fclose(fs_outFD))
556         if (afsmon_debug) {
557             fprintf(debugFD, "[ %s ] failed to close %s\n", rn, a_outfile);
558             fflush(debugFD);
559         }
560
561     return (0);
562 }
563
564 /*___________________________________________________________________________
565                         CM STATS
566  *__________________________________________________________________________*/
567
568
569
570 /*------------------------------------------------------------------------
571  * Print_cm_UpDownStats
572  *
573  * Description:
574  *      Print the up/downtime stats for the given class of server records
575  *      provided.
576  *
577  * Arguments:
578  *      a_upDownP : Ptr to the server up/down info.
579  *
580  * Returns:
581  *      Nothing.
582  *
583  * Environment:
584  *      Nothing interesting.
585  *
586  * Side Effects:
587  *      As advertised.
588  *------------------------------------------------------------------------*/
589
590 void
591 Print_cm_UpDownStats(struct afs_stats_SrvUpDownInfo *a_upDownP) /*Ptr to server up/down info */
592 {                               /*Print_cm_UpDownStats */
593
594     /*
595      * First, print the simple values.
596      */
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);
617
618     /*
619      * Now, print the array values.
620      */
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]);
635
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]);
646
647 }                               /*Print_cm_UpDownStats */
648
649
650 /*------------------------------------------------------------------------
651  * Print_cm_OverallPerfInfo
652  *
653  * Description:
654  *      Print out overall performance numbers.
655  *
656  * Arguments:
657  *      a_ovP : Ptr to the overall performance numbers.
658  *
659  * Returns:
660  *      Nothing.
661  *
662  * Environment:
663  *      All the info we need is nestled into xstat_cm_Results.
664  *
665  * Side Effects:
666  *      As advertised.
667  *------------------------------------------------------------------------*/
668
669 void
670 Print_cm_OverallPerfInfo(struct afs_stats_CMPerf *a_ovP)
671 {                               /*Print_cm_OverallPerfInfo */
672
673     fprintf(cm_outFD, "\t%10d numPerfCalls\n", a_ovP->numPerfCalls);
674
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);
696
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);
701
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);
713
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);
720
721     fprintf(cm_outFD, "\t%10d sysName_ID\n", a_ovP->sysName_ID);
722
723     fprintf(cm_outFD, "\tFile Server up/downtimes, same cell:\n");
724     Print_cm_UpDownStats(&(a_ovP->fs_UpDown[0]));
725
726     fprintf(cm_outFD, "\tFile Server up/downtimes, diff cell:\n");
727     Print_cm_UpDownStats(&(a_ovP->fs_UpDown[1]));
728
729     fprintf(cm_outFD, "\tVL Server up/downtimes, same cell:\n");
730     Print_cm_UpDownStats(&(a_ovP->vl_UpDown[0]));
731
732     fprintf(cm_outFD, "\tVL Server up/downtimes, diff cell:\n");
733     Print_cm_UpDownStats(&(a_ovP->vl_UpDown[1]));
734
735 }                               /*Print_cm_OverallPerfInfo */
736
737
738 /*------------------------------------------------------------------------
739  * Print_cm_PerfInfo
740  *
741  * Description:
742  *      Print out the AFSCB_XSTATSCOLL_PERF_INFO collection we just
743  *      received.
744  *
745  * Arguments:
746  *      None.
747  *
748  * Returns:
749  *      Nothing.
750  *
751  * Environment:
752  *      All the info we need is nestled into xstat_cm_Results.
753  *
754  * Side Effects:
755  *      As advertised.
756  *------------------------------------------------------------------------*/
757
758 void
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 */
765     time_t probeTime;
766
767     numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
768     if (numLongs != perfLongs) {
769         fprintf(cm_outFD,
770                 " ** Data size mismatch in performance collection!\n");
771         fprintf(cm_outFD, "** Expecting %d, got %d\n", perfLongs, numLongs);
772         return;
773     }
774
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);
780
781     fprintf(cm_outFD,
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,
785             printableTime);
786
787     Print_cm_OverallPerfInfo(perfP);
788
789 }                               /*Print_cm_PerfInfo */
790
791
792 /*------------------------------------------------------------------------
793  * Print_cm_OpTiming
794  *
795  * Description:
796  *      Print out the contents of an FS RPC op timing structure.
797  *
798  * Arguments:
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.
802  *
803  * Returns:
804  *      Nothing.
805  *
806  * Environment:
807  *      Nothing interesting.
808  *
809  * Side Effects:
810  *      As advertised.
811  *------------------------------------------------------------------------*/
812
813 void
814 Print_cm_OpTiming(int a_opIdx, char *a_opNames[],
815                   struct afs_stats_opTimingData *a_opTimeP)
816 {                               /*Print_cm_OpTiming */
817
818     fprintf(cm_outFD,
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);
824
825 }                               /*Print_cm_OpTiming */
826
827
828 /*------------------------------------------------------------------------
829  * Print_cm_XferTiming
830  *
831  * Description:
832  *      Print out the contents of a data transfer structure.
833  *
834  * Arguments:
835  *      a_opIdx : Index of the AFS operation we're printing number on.
836  *      a_xferP : Ptr to the data transfer structure to print.
837  *
838  * Returns:
839  *      Nothing.
840  *
841  * Environment:
842  *      Nothing interesting.
843  *
844  * Side Effects:
845  *      As advertised.
846  *------------------------------------------------------------------------*/
847
848 void
849 Print_cm_XferTiming(int a_opIdx, char *a_opNames[],
850                     struct afs_stats_xferData *a_xferP)
851 {                               /*Print_cm_XferTiming */
852
853     fprintf(cm_outFD,
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);
861     fprintf(cm_outFD,
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]);
866
867 }                               /*Print_cm_XferTiming */
868
869
870 /*------------------------------------------------------------------------
871  * Print_cm_ErrInfo
872  *
873  * Description:
874  *      Print out the contents of an FS RPC error info structure.
875  *
876  * Arguments:
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.
880  *
881  * Returns:
882  *      Nothing.
883  *
884  * Environment:
885  *      Nothing interesting.
886  *
887  * Side Effects:
888  *      As advertised.
889  *------------------------------------------------------------------------*/
890
891 void
892 Print_cm_ErrInfo(int a_opIdx, char *a_opNames[],
893                  struct afs_stats_RPCErrors *a_opErrP)
894 {                               /*Print_cm_ErrInfo */
895
896     fprintf(cm_outFD,
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);
901
902 }                               /*Print_cm_ErrInfo */
903
904
905 /*------------------------------------------------------------------------
906  * Print_cm_RPCPerfInfo
907  *
908  * Description:
909  *      Print out a set of RPC performance numbers.
910  *
911  * Arguments:
912  *      a_rpcP : Ptr to RPC perf numbers to print.
913  *
914  * Returns:
915  *      Nothing.
916  *
917  * Environment:
918  *      Nothing interesting.
919  *
920  * Side Effects:
921  *      As advertised.
922  *------------------------------------------------------------------------*/
923
924 void
925 Print_cm_RPCPerfInfo(struct afs_stats_RPCOpInfo *a_rpcP)
926 {                               /*Print_cm_RPCPerfInfo */
927
928     int currIdx;                /*Loop variable */
929
930     /*
931      * Print the contents of each of the opcode-related arrays.
932      */
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]));
936
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]));
940
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]));
945
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]));
949
950 }                               /*Print_cm_RPCPerfInfo */
951
952
953 /*------------------------------------------------------------------------
954  * Print_cm_FullPerfInfo
955  *
956  * Description:
957  *      Print out a set of full performance numbers.
958  *
959  * Arguments:
960  *      None.
961  *
962  * Returns:
963  *      Nothing.
964  *
965  * Environment:
966  *      Nothing interesting.
967  *
968  * Side Effects:
969  *      As advertised.
970  *------------------------------------------------------------------------*/
971
972 void
973 Print_cm_FullPerfInfo(void)
974 {                               /*Print_cm_FullPerfInfo */
975
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 */
981     time_t probeTime;
982     char *printableTime;        /*Ptr to printable time string */
983
984     numLongs = xstat_cm_Results.data.AFSCB_CollData_len;
985     if (numLongs != fullPerfLongs) {
986         fprintf(cm_outFD,
987                 " ** Data size mismatch in performance collection!\n");
988         fprintf(cm_outFD, " ** Expecting %d, got %d\n", fullPerfLongs,
989                 numLongs);
990         return;
991     }
992
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);
998
999     fprintf(cm_outFD,
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,
1003             printableTime);
1004
1005     /*
1006      * Print the overall numbers first, followed by all of the RPC numbers,
1007      * then each of the other groupings.
1008      */
1009     fprintf(cm_outFD,
1010             "Overall Performance Info:\n-------------------------\n");
1011     Print_cm_OverallPerfInfo(&(fullP->perf));
1012     fprintf(cm_outFD, "\n");
1013     Print_cm_RPCPerfInfo(&(fullP->rpc));
1014
1015     authentP = &(fullP->authent);
1016     fprintf(cm_outFD, "\nAuthentication info:\n--------------------\n");
1017     fprintf(cm_outFD,
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);
1024     fprintf(cm_outFD,
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);
1028
1029     accessinfP = &(fullP->accessinf);
1030     fprintf(cm_outFD,
1031             "\n[Un]replicated accesses:\n------------------------\n");
1032     fprintf(cm_outFD,
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);
1037
1038     /* There really isn't any authorship info
1039      * authorP = &(fullP->author); */
1040
1041 }                               /*Print_cm_FullPerfInfo */
1042
1043 /*------------------------------------------------------------------------
1044  * afsmon_cmOutput()
1045  *
1046  * Description:
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.
1050  *
1051  * Arguments:
1052  *      Name of output file.
1053  *      Flag to indicate if detailed output is required.
1054  *
1055  * Returns:
1056  *      Nothing.
1057  *
1058  * Environment:
1059  *      All the info we need is nestled into xstat_cm_Results.
1060  *
1061  * Side Effects:
1062  *      As advertised.
1063  *------------------------------------------------------------------------*/
1064 int
1065 afsmon_cmOutput(char *a_outfile,                /* ptr to output file name */
1066                 int a_detOutput)                /* detailed output ? */
1067 {
1068
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 */
1074     int i;
1075     time_t probeTime;
1076
1077     if (afsmon_debug) {
1078         fprintf(debugFD, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n",
1079                 rn, a_outfile, a_detOutput);
1080         fflush(debugFD);
1081     }
1082
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,
1087                 a_outfile);
1088         afsmon_Exit(1);
1089     }
1090
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;
1096
1097     /* print "time hostname CM" prefix  */
1098     fprintf(cm_outFD, "\n%s %s CM ", printTime, hostname);
1099
1100     /* if probe failed print -1 and vanish */
1101     if (xstat_cm_Results.probeOK) {
1102         fprintf(cm_outFD, "-1\n");
1103         fclose(cm_outFD);
1104         return (0);
1105     }
1106
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);
1110
1111     for (i = 0; i < numLongs; i++) {
1112         fprintf(cm_outFD, "%d ", *currLong++);
1113     }
1114     fprintf(cm_outFD, "\n\n");
1115
1116     /* print out detailed statistics */
1117     if (a_detOutput) {
1118         Print_cm_FullPerfInfo();
1119         fflush(cm_outFD);
1120     }
1121
1122     if (fclose(cm_outFD))
1123         if (afsmon_debug) {
1124             fprintf(debugFD, "[ %s ] failed to close %s\n", rn, a_outfile);
1125             fflush(debugFD);
1126         }
1127
1128     return (0);
1129 }