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 #define __fs_stats_h 1
13 /*------------------------------------------------------------------------
16 * Definitions supporting call and performance information gathering for
17 * the FileServer xstat (extended statistics) interface.
19 *------------------------------------------------------------------------*/
22 #include <afs/param.h> /*System configuration info */
25 * Decide if we're keeping detailed File Server stats.
27 #define FS_STATS_DETAILED 1
30 * Performance numbers.
32 struct afs_PerfStats {
33 afs_int32 numPerfCalls; /*# of performance calls rcvd */
36 * Vnode cache section.
38 afs_int32 vcache_L_Entries; /*Num entries in LARGE vnode cache */
39 afs_int32 vcache_L_Allocs; /*# allocs, large */
40 afs_int32 vcache_L_Gets; /*# gets, large */
41 afs_int32 vcache_L_Reads; /*# reads, large */
42 afs_int32 vcache_L_Writes; /*# writes, large */
44 afs_int32 vcache_S_Entries; /*Num entries in SMALL vnode cache */
45 afs_int32 vcache_S_Allocs; /*# allocs, small */
46 afs_int32 vcache_S_Gets; /*# gets, small */
47 afs_int32 vcache_S_Reads; /*# reads, small */
48 afs_int32 vcache_S_Writes; /*# writes, small */
50 afs_int32 vcache_H_Entries; /*Num entries in HEADER vnode cache */
51 afs_int32 vcache_H_Gets; /*# gets */
52 afs_int32 vcache_H_Replacements; /*# replacements */
55 * Directory package section.
57 afs_int32 dir_Buffers; /*Num buffers in use */
58 afs_int32 dir_Calls; /*Num read calls made */
59 afs_int32 dir_IOs; /*I/O ops performed */
62 * Rx section. These numbers represent the contents of the
63 * rx_stats structure maintained by Rx. All other Rx info,
64 * including struct rx_debug and connection stuff is available
65 * via the rxdebug interface.
67 afs_int32 rx_packetRequests; /*Packet alloc requests */
68 afs_int32 rx_noPackets_RcvClass; /*Failed pkt requests, receives */
69 afs_int32 rx_noPackets_SendClass; /*Ditto, sends */
70 afs_int32 rx_noPackets_SpecialClass; /*Ditto, specials */
71 afs_int32 rx_socketGreedy; /*Did SO_GREEDY succeed? */
72 afs_int32 rx_bogusPacketOnRead; /*Short pkts rcvd */
73 afs_int32 rx_bogusHost; /*Host addr from bogus pkts */
74 afs_int32 rx_noPacketOnRead; /*Read pkts w/no packet there */
75 afs_int32 rx_noPacketBuffersOnRead; /*Pkts dropped from buff shortage */
76 afs_int32 rx_selects; /*Selects waiting on pkt or timeout */
77 afs_int32 rx_sendSelects; /*Selects forced upon sends */
78 afs_int32 rx_packetsRead_RcvClass; /*Packets read, rcv class */
79 afs_int32 rx_packetsRead_SendClass; /*Packets read, send class */
80 afs_int32 rx_packetsRead_SpecialClass; /*Packets read, special class */
81 afs_int32 rx_dataPacketsRead; /*Uniq data packets read off wire */
82 afs_int32 rx_ackPacketsRead; /*Ack packets read */
83 afs_int32 rx_dupPacketsRead; /*Duplicate data packets read */
84 afs_int32 rx_spuriousPacketsRead; /*Inappropriate packets read */
85 afs_int32 rx_packetsSent_RcvClass; /*Packets sent, rcv class */
86 afs_int32 rx_packetsSent_SendClass; /*Packets sent, send class */
87 afs_int32 rx_packetsSent_SpecialClass; /*Packets sent, special class */
88 afs_int32 rx_ackPacketsSent; /*Ack packets sent */
89 afs_int32 rx_pingPacketsSent; /*Ping packets sent */
90 afs_int32 rx_abortPacketsSent; /*Abort packets sent */
91 afs_int32 rx_busyPacketsSent; /*Busy packets sent */
92 afs_int32 rx_dataPacketsSent; /*Unique data packets sent */
93 afs_int32 rx_dataPacketsReSent; /*Retransmissions sent */
94 afs_int32 rx_dataPacketsPushed; /*Retransmissions pushed by NACK */
95 afs_int32 rx_ignoreAckedPacket; /*Packets w/acked flag on rxi_Start */
96 afs_int32 rx_totalRtt_Sec; /*Ttl round trip time, secs */
97 afs_int32 rx_totalRtt_Usec; /*Ttl round trip time, usecs */
98 afs_int32 rx_minRtt_Sec; /*Min round trip time, secs */
99 afs_int32 rx_minRtt_Usec; /*Min round trip time, usecs */
100 afs_int32 rx_maxRtt_Sec; /*Max round trip time, secs */
101 afs_int32 rx_maxRtt_Usec; /*Max round trip time, usecs */
102 afs_int32 rx_nRttSamples; /*Round trip samples */
103 afs_int32 rx_nServerConns; /*Ttl server connections */
104 afs_int32 rx_nClientConns; /*Ttl client connections */
105 afs_int32 rx_nPeerStructs; /*Ttl peer structures */
106 afs_int32 rx_nCallStructs; /*Ttl call structures */
107 afs_int32 rx_nFreeCallStructs; /*Ttl free call structures */
110 * Host module fields.
112 afs_int32 host_NumHostEntries; /*Number of host entries */
113 afs_int32 host_HostBlocks; /*Blocks in use for hosts */
114 afs_int32 host_NonDeletedHosts; /*Non-deleted hosts */
115 afs_int32 host_HostsInSameNetOrSubnet; /*" in same [sub]net as server */
116 afs_int32 host_HostsInDiffSubnet; /*" in different subnet as server */
117 afs_int32 host_HostsInDiffNetwork; /*" in different network as server */
118 afs_int32 host_NumClients; /*Number of client entries */
119 afs_int32 host_ClientBlocks; /*Blocks in use for clients */
124 afs_int32 sysname_ID; /*Unique hardware/OS identifier */
126 afs_int32 rx_nBusies; /*Ttl VBUSYs sent to shed load */
127 afs_int32 fs_nBusies; /*Ttl VBUSYs sent during restart/vol clone */
130 * Can't count this as an RPC because it breaks the data structure
132 afs_int32 fs_nGetCaps; /* Number of GetCapabilities calls */
139 #if FS_STATS_DETAILED
141 * Assign each of the File Server's RPC interface routines an index.
143 #define FS_STATS_RPCIDX_FETCHDATA 0
144 #define FS_STATS_RPCIDX_FETCHACL 1
145 #define FS_STATS_RPCIDX_FETCHSTATUS 2
146 #define FS_STATS_RPCIDX_STOREDATA 3
147 #define FS_STATS_RPCIDX_STOREACL 4
148 #define FS_STATS_RPCIDX_STORESTATUS 5
149 #define FS_STATS_RPCIDX_REMOVEFILE 6
150 #define FS_STATS_RPCIDX_CREATEFILE 7
151 #define FS_STATS_RPCIDX_RENAME 8
152 #define FS_STATS_RPCIDX_SYMLINK 9
153 #define FS_STATS_RPCIDX_LINK 10
154 #define FS_STATS_RPCIDX_MAKEDIR 11
155 #define FS_STATS_RPCIDX_REMOVEDIR 12
156 #define FS_STATS_RPCIDX_SETLOCK 13
157 #define FS_STATS_RPCIDX_EXTENDLOCK 14
158 #define FS_STATS_RPCIDX_RELEASELOCK 15
159 #define FS_STATS_RPCIDX_GETSTATISTICS 16
160 #define FS_STATS_RPCIDX_GIVEUPCALLBACKS 17
161 #define FS_STATS_RPCIDX_GETVOLUMEINFO 18
162 #define FS_STATS_RPCIDX_GETVOLUMESTATUS 19
163 #define FS_STATS_RPCIDX_SETVOLUMESTATUS 20
164 #define FS_STATS_RPCIDX_GETROOTVOLUME 21
165 #define FS_STATS_RPCIDX_CHECKTOKEN 22
166 #define FS_STATS_RPCIDX_GETTIME 23
167 #define FS_STATS_RPCIDX_NGETVOLUMEINFO 24
168 #define FS_STATS_RPCIDX_BULKSTATUS 25
169 #define FS_STATS_RPCIDX_XSTATSVERSION 26
170 #define FS_STATS_RPCIDX_GETXSTATS 27
172 #define FS_STATS_NUM_RPC_OPS 28
175 * Assign an index to each of the File Server's RPC interface routines
176 * that transfer any data to speak of.
178 #define FS_STATS_XFERIDX_FETCHDATA 0
179 #define FS_STATS_XFERIDX_STOREDATA 1
181 #define FS_STATS_NUM_XFER_OPS 2
184 * Record to track timing numbers for each File Server RPC operation.
186 struct fs_stats_opTimingData {
187 afs_int32 numOps; /*Number of operations executed */
188 afs_int32 numSuccesses; /*Number of successful ops */
189 struct timeval sumTime; /*Sum of sample timings */
190 struct timeval sqrTime; /*Sum of squares of sample timings */
191 struct timeval minTime; /*Minimum timing value observed */
192 struct timeval maxTime; /*Minimum timing value observed */
196 * We discriminate byte size transfers into this many buckets.
198 #define FS_STATS_NUM_XFER_BUCKETS 9
200 #define FS_STATS_MAXBYTES_BUCKET0 128
201 #define FS_STATS_MAXBYTES_BUCKET1 1024
202 #define FS_STATS_MAXBYTES_BUCKET2 8192
203 #define FS_STATS_MAXBYTES_BUCKET3 16384
204 #define FS_STATS_MAXBYTES_BUCKET4 32768
205 #define FS_STATS_MAXBYTES_BUCKET5 131072
206 #define FS_STATS_MAXBYTES_BUCKET6 524288
207 #define FS_STATS_MAXBYTES_BUCKET7 1048576
211 * Record to track timings and byte sizes for data transfers.
213 struct fs_stats_xferData {
214 afs_int32 numXfers; /*Number of xfers */
215 afs_int32 numSuccesses; /*Number of successful xfers */
216 struct timeval sumTime; /*Sum of timing values */
217 struct timeval sqrTime; /*Sum of squares of timing values */
218 struct timeval minTime; /*Minimum xfer time recorded */
219 struct timeval maxTime; /*Maximum xfer time recorded */
220 afs_int32 sumBytes; /*Sum of bytes transferred */
221 afs_int32 minBytes; /*Minimum value observed */
222 afs_int32 maxBytes; /*Maximum value observed */
223 afs_int32 count[FS_STATS_NUM_XFER_BUCKETS]; /*Tally for each range of bytes */
227 * Macros to operate on time values.
229 * fs_stats_TimeLessThan(t1, t2) Non-zero if t1 is less than t2
230 * fs_stats_TimeGreaterThan(t1, t2) Non-zero if t1 is greater than t2
231 * fs_stats_GetDiff(t3, t1, t2) Set t3 to the difference between
232 * t1 and t2 (t1 is less than or
234 * fs_stats_AddTo(t1, t2) Add t2 to t1
235 * fs_stats_TimeAssign(t1, t2) Assign time t2 to t1
236 * afs_stats_SquareAddTo(t1,t2) Add square of t2 to t1
238 #define fs_stats_TimeLessThan(t1, t2) \
239 ((t1.tv_sec < t2.tv_sec) ? 1 : \
240 (t1.tv_sec > t2.tv_sec) ? 0 : \
241 (t1.tv_usec < t2.tv_usec) ? 1 : \
244 #define fs_stats_TimeGreaterThan(t1, t2) \
245 ((t1.tv_sec > t2.tv_sec) ? 1 : \
246 (t1.tv_sec < t2.tv_sec) ? 0 : \
247 (t1.tv_usec > t2.tv_usec) ? 1 : \
250 #define fs_stats_GetDiff(t3, t1, t2) \
253 * If the microseconds of the later time are smaller than \
254 * the earlier time, set up for proper subtraction (doing \
257 if (t2.tv_usec < t1.tv_usec) { \
258 t2.tv_usec += 1000000; \
261 t3.tv_sec = t2.tv_sec - t1.tv_sec; \
262 t3.tv_usec = t2.tv_usec - t1.tv_usec; \
265 #define fs_stats_AddTo(t1, t2) \
267 t1.tv_sec += t2.tv_sec; \
268 t1.tv_usec += t2.tv_usec; \
269 if (t1.tv_usec > 1000000) { \
270 t1.tv_usec -= 1000000; \
275 #define fs_stats_TimeAssign(t1, t2) \
277 t1.tv_sec = t2.tv_sec; \
278 t1.tv_usec = t2.tv_usec; \
281 #define fs_stats_SquareAddTo(t1, t2) \
285 t1.tv_sec += (int) (t2.tv_sec * t2.tv_sec \
286 + (0.000002 * t2.tv_sec) * t2.tv_usec) ; \
287 t1.tv_usec += (int) ((2 * t2.tv_sec * t2.tv_usec) % 1000000 \
288 + (0.000001 * t2.tv_usec) * t2.tv_usec); \
292 t1.tv_usec += (int) ((0.000001 * t2.tv_usec) * t2.tv_usec); \
294 if (t1.tv_usec > 1000000) { \
295 t1.tv_usec -= 1000000; \
301 * This is the detailed performance data collection for the File Server.
303 struct fs_stats_DetailedStats {
304 struct timeval epoch; /*Time when data collection began */
305 struct fs_stats_opTimingData
306 rpcOpTimes[FS_STATS_NUM_RPC_OPS]; /*Individual RPC operation timings */
307 struct fs_stats_xferData
308 xferOpTimes[FS_STATS_NUM_XFER_OPS]; /*Byte info for certain ops */
312 * This is all of the performance data, both overall and detailed.
314 struct fs_stats_FullPerfStats {
315 struct afs_PerfStats overall;
316 struct fs_stats_DetailedStats det;
320 * This is the structure accessible by specifying the
321 * AFS_XSTATSCOLL_FULL_PERF_INFO collection to the xstat package.
323 extern struct fs_stats_FullPerfStats afs_FullPerfStats;
324 #endif /* FS_STATS_DETAILED */
328 * This is the structure accessible by specifying the
329 * AFS_XSTATSCOLL_PERF_INFO collection to the xstat package.
331 extern struct afs_PerfStats afs_perfstats;
334 * FileServer's name and IP address, both network byte order and
337 extern char FS_HostName[];
338 extern afs_uint32 FS_HostAddr_NBO;
339 extern afs_uint32 FS_HostAddr_HBO;
341 #endif /* __fs_stats_h */