• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  */
24 
25 /*
26  * Stats are all uint64_t numbers that start at 0.
27  * Index names here have the convention
28  *
29  *  _C_ counter
30  *  _B_ byte count
31  *  _MS_ millisecond count
32  */
33 
34 enum {
35 	LWSSTATS_C_CONNECTIONS, /**< count incoming connections */
36 	LWSSTATS_C_API_CLOSE, /**< count calls to close api */
37 	LWSSTATS_C_API_READ, /**< count calls to read from socket api */
38 	LWSSTATS_C_API_LWS_WRITE, /**< count calls to lws_write API */
39 	LWSSTATS_C_API_WRITE, /**< count calls to write API */
40 	LWSSTATS_C_WRITE_PARTIALS, /**< count of partial writes */
41 	LWSSTATS_C_WRITEABLE_CB_REQ, /**< count of writable callback requests */
42 	LWSSTATS_C_WRITEABLE_CB_EFF_REQ, /**< count of effective writable callback requests */
43 	LWSSTATS_C_WRITEABLE_CB, /**< count of writable callbacks */
44 	LWSSTATS_C_SSL_CONNECTIONS_FAILED, /**< count of failed SSL connections */
45 	LWSSTATS_C_SSL_CONNECTIONS_ACCEPTED, /**< count of accepted SSL connections */
46 	LWSSTATS_C_SSL_ACCEPT_SPIN, /**< count of SSL_accept() attempts */
47 	LWSSTATS_C_SSL_CONNS_HAD_RX, /**< count of accepted SSL conns that have had some RX */
48 	LWSSTATS_C_TIMEOUTS, /**< count of timed-out connections */
49 	LWSSTATS_C_SERVICE_ENTRY, /**< count of entries to lws service loop */
50 	LWSSTATS_B_READ, /**< aggregate bytes read */
51 	LWSSTATS_B_WRITE, /**< aggregate bytes written */
52 	LWSSTATS_B_PARTIALS_ACCEPTED_PARTS, /**< aggreate of size of accepted write data from new partials */
53 	LWSSTATS_US_SSL_ACCEPT_LATENCY_AVG, /**< aggregate delay in accepting connection */
54 	LWSSTATS_US_WRITABLE_DELAY_AVG, /**< aggregate delay between asking for writable and getting cb */
55 	LWSSTATS_US_WORST_WRITABLE_DELAY, /**< single worst delay between asking for writable and getting cb */
56 	LWSSTATS_US_SSL_RX_DELAY_AVG, /**< aggregate delay between ssl accept complete and first RX */
57 	LWSSTATS_C_PEER_LIMIT_AH_DENIED, /**< number of times we would have given an ah but for the peer limit */
58 	LWSSTATS_C_PEER_LIMIT_WSI_DENIED, /**< number of times we would have given a wsi but for the peer limit */
59 	LWSSTATS_C_CONNS_CLIENT, /**< attempted client conns */
60 	LWSSTATS_C_CONNS_CLIENT_FAILED, /**< failed client conns */
61 
62 	/* Add new things just above here ---^
63 	 * This is part of the ABI, don't needlessly break compatibility
64 	 *
65 	 * UPDATE stat_names in stats.c in sync with this!
66 	 */
67 	LWSSTATS_SIZE
68 };
69 
70 #if defined(LWS_WITH_STATS)
71 
72 LWS_VISIBLE LWS_EXTERN uint64_t
73 lws_stats_get(struct lws_context *context, int index);
74 LWS_VISIBLE LWS_EXTERN void
75 lws_stats_log_dump(struct lws_context *context);
76 #else
77 static LWS_INLINE uint64_t
lws_stats_get(struct lws_context * context,int index)78 lws_stats_get(struct lws_context *context, int index) { (void)context; (void)index;  return 0; }
79 static LWS_INLINE void
lws_stats_log_dump(struct lws_context * context)80 lws_stats_log_dump(struct lws_context *context) { (void)context; }
81 #endif
82