convert-from-bsd-to-posix-string-and-memory-functions-20010807
[openafs.git] / src / afs / afs_stat.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 /* statistics-gathering package */
11
12 #include <afsconfig.h>
13 #include "../afs/param.h"
14
15 RCSID("$Header$");
16
17 #include "../afs/sysincludes.h" /*Standard vendor system headers*/
18 #include "../afs/afsincludes.h" /*AFS-based standard headers*/
19 #include "afs_stats.h"
20
21 struct afs_CMStats afs_cmstats;
22 struct afs_stats_CMPerf afs_stats_cmperf;
23 struct afs_stats_CMFullPerf afs_stats_cmfullperf;
24 afs_int32 afs_stats_XferSumBytes[AFS_STATS_NUM_FS_XFER_OPS];
25
26
27
28 /*
29  * afs_InitStats
30  *
31  * Description:
32  *      Initialize all of the CM statistics structures.
33  *
34  * Parameters:
35  *      None.
36  *
37  * Environment:
38  *      This routine should only be called once, at initialization time.
39  */
40 void afs_InitStats()
41
42 { /*afs_InitStats*/
43
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*/
47
48     /*
49      * First step is to zero everything out.
50      */
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, sizeof(struct afs_stats_CMFullPerf));
54
55     /*
56      * Some fields really should be non-zero at the start, so set 'em up.
57      */
58     afs_stats_cmperf.srvNumBuckets = NSERVERS;
59
60     opTimeP = &(afs_stats_cmfullperf.rpc.fsRPCTimes[0]);
61     for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++, opTimeP++)
62         opTimeP->minTime.tv_sec = 999999;
63
64     opTimeP = &(afs_stats_cmfullperf.rpc.cmRPCTimes[0]);
65     for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++, opTimeP++)
66         opTimeP->minTime.tv_sec = 999999;
67
68     xferP = &(afs_stats_cmfullperf.rpc.fsXferTimes[0]);
69     for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++, xferP++) {
70         xferP->minTime.tv_sec = 999999;
71         xferP->minBytes = 999999999;
72     }
73     
74 } /*afs_InitStats*/
75
76
77
78 afs_GetCMStat(ptr, size)
79      char **ptr; /* memory area */
80      unsigned *size; /* # of bytes */
81   {
82 #ifndef AFS_NOSTATS
83       AFS_STATCNT(afs_GetCMStat);
84       *ptr = (char *)&afs_cmstats;
85       *size = sizeof(afs_cmstats);
86 #endif /* AFS_NOSTATS */
87   }
88
89 afs_AddToMean(oldMean, newValue)
90      struct afs_MeanStats *oldMean;
91      afs_int32 newValue;
92   {
93       AFS_STATCNT(afs_AddToMean);
94   }