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
10 /* statistics-gathering package */
12 #include <afsconfig.h>
13 #include "afs/param.h"
18 #include "afs/sysincludes.h" /*Standard vendor system headers */
19 #include "afsincludes.h" /*AFS-based standard headers */
20 #include "afs_stats.h"
22 struct afs_CMStats afs_cmstats;
23 struct afs_stats_CMPerf afs_stats_cmperf;
24 struct afs_stats_CMFullPerf afs_stats_cmfullperf;
25 afs_int32 afs_stats_XferSumBytes[AFS_STATS_NUM_FS_XFER_OPS];
33 * Initialize all of the CM statistics structures.
39 * This routine should only be called once, at initialization time.
44 struct afs_stats_opTimingData *opTimeP; /*Ptr to curr timing struct */
45 struct afs_stats_xferData *xferP; /*Ptr to curr xfer struct */
46 int currIdx; /*Current index */
49 * First step is to zero everything out.
51 memset((char *)(&afs_cmstats), 0, sizeof(struct afs_CMStats));
52 memset((char *)(&afs_stats_cmperf), 0, sizeof(struct afs_stats_CMPerf));
53 memset((char *)(&afs_stats_cmfullperf), 0,
54 sizeof(struct afs_stats_CMFullPerf));
57 * Some fields really should be non-zero at the start, so set 'em up.
59 afs_stats_cmperf.srvNumBuckets = NSERVERS;
61 opTimeP = &(afs_stats_cmfullperf.rpc.fsRPCTimes[0]);
62 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS;
64 opTimeP->minTime.tv_sec = 999999;
66 opTimeP = &(afs_stats_cmfullperf.rpc.cmRPCTimes[0]);
67 for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS;
69 opTimeP->minTime.tv_sec = 999999;
71 xferP = &(afs_stats_cmfullperf.rpc.fsXferTimes[0]);
72 for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++, xferP++) {
73 xferP->minTime.tv_sec = 999999;
74 xferP->minBytes = 999999999;
79 afs_GetCMStat(char **ptr, unsigned *size)
82 AFS_STATCNT(afs_GetCMStat);
83 *ptr = (char *)&afs_cmstats;
84 *size = sizeof(afs_cmstats);
85 #endif /* AFS_NOSTATS */
89 afs_AddToMean(struct afs_MeanStats *oldMean, afs_int32 newValue)
91 AFS_STATCNT(afs_AddToMean);