/src/haproxy/include/haproxy/stats.h
Line | Count | Source |
1 | | /* |
2 | | * include/haproxy/stats.h |
3 | | * This file contains definitions of some primitives to dedicated to |
4 | | * statistics output. |
5 | | * |
6 | | * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu |
7 | | * |
8 | | * This library is free software; you can redistribute it and/or |
9 | | * modify it under the terms of the GNU Lesser General Public |
10 | | * License as published by the Free Software Foundation, version 2.1 |
11 | | * exclusively. |
12 | | * |
13 | | * This library is distributed in the hope that it will be useful, |
14 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | | * Lesser General Public License for more details. |
17 | | * |
18 | | * You should have received a copy of the GNU Lesser General Public |
19 | | * License along with this library; if not, write to the Free Software |
20 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 | | */ |
22 | | |
23 | | #ifndef _HAPROXY_STATS_H |
24 | | #define _HAPROXY_STATS_H |
25 | | |
26 | | #include <haproxy/api.h> |
27 | | #include <haproxy/counters.h> |
28 | | #include <haproxy/listener-t.h> |
29 | | #include <haproxy/stats-t.h> |
30 | | #include <haproxy/tools-t.h> |
31 | | |
32 | | struct channel; |
33 | | struct buffer; |
34 | | struct proxy; |
35 | | struct appctx; |
36 | | struct htx; |
37 | | struct stconn; |
38 | | |
39 | | /* These two structs contains all column names and descriptions according to |
40 | | * the the number of entries in "enum stat_idx_px" and "enum stat_idx_info" |
41 | | */ |
42 | | extern const struct stat_col stat_cols_px[]; |
43 | | extern const struct stat_col stat_cols_info[]; |
44 | | extern const char *stat_status_codes[]; |
45 | | extern struct applet http_stats_applet; |
46 | | extern struct list stats_module_list[]; |
47 | | extern THREAD_LOCAL struct field stat_line_info[]; |
48 | | extern THREAD_LOCAL struct field *stat_lines[]; |
49 | | extern struct name_desc *stat_cols[STATS_DOMAIN_COUNT]; |
50 | | extern size_t stat_cols_len[STATS_DOMAIN_COUNT]; |
51 | | |
52 | | int generate_stat_tree(struct eb_root *st_tree, const struct stat_col cols[]); |
53 | | |
54 | | struct htx; |
55 | | int stats_putchk(struct appctx *appctx, struct buffer *buf, struct htx *htx); |
56 | | int stats_is_full(struct appctx *appctx, struct buffer *buf, struct htx *htx); |
57 | | |
58 | | const char *stats_scope_ptr(struct appctx *appctx); |
59 | | |
60 | | int stats_dump_one_line(const struct field *line, size_t stats_count, struct appctx *appctx); |
61 | | |
62 | | int stats_fill_info(struct field *info, int len, uint flags); |
63 | | int stats_fill_fe_line(struct proxy *px, int flags, struct field *line, int len, |
64 | | enum stat_idx_px *index); |
65 | | int stats_fill_li_line(struct proxy *px, struct listener *l, int flags, |
66 | | struct field *line, int len, enum stat_idx_px *index); |
67 | | int stats_fill_sv_line(struct proxy *px, struct server *sv, int flags, |
68 | | struct field *line, int len, enum stat_idx_px *index); |
69 | | int stats_fill_be_line(struct proxy *px, int flags, struct field *line, int len, |
70 | | enum stat_idx_px *index); |
71 | | |
72 | | int stats_dump_stat_to_buffer(struct stconn *sc, struct buffer *buf, struct htx *htx); |
73 | | |
74 | | int stats_emit_raw_data_field(struct buffer *out, const struct field *f); |
75 | | int stats_emit_typed_data_field(struct buffer *out, const struct field *f); |
76 | | int stats_emit_field_tags(struct buffer *out, const struct field *f, |
77 | | int persistent, char delim); |
78 | | |
79 | | |
80 | | /* Returns true if <col> is fully defined, false if only used as name-desc. */ |
81 | | static inline int stcol_is_generic(const struct stat_col *col) |
82 | 0 | { |
83 | 0 | return col->flags & STAT_COL_FL_GENERIC; |
84 | 0 | } Unexecuted instantiation: http_ana.c:stcol_is_generic Unexecuted instantiation: proxy.c:stcol_is_generic Unexecuted instantiation: resolvers.c:stcol_is_generic Unexecuted instantiation: server.c:stcol_is_generic Unexecuted instantiation: stats-html.c:stcol_is_generic Unexecuted instantiation: stats.c:stcol_is_generic Unexecuted instantiation: stats-file.c:stcol_is_generic Unexecuted instantiation: stats-json.c:stcol_is_generic Unexecuted instantiation: stats-proxy.c:stcol_is_generic |
85 | | |
86 | | static inline enum field_format stcol_format(const struct stat_col *col) |
87 | 0 | { |
88 | 0 | return col->type & FF_MASK; |
89 | 0 | } Unexecuted instantiation: http_ana.c:stcol_format Unexecuted instantiation: proxy.c:stcol_format Unexecuted instantiation: resolvers.c:stcol_format Unexecuted instantiation: server.c:stcol_format Unexecuted instantiation: stats-html.c:stcol_format Unexecuted instantiation: stats.c:stcol_format Unexecuted instantiation: stats-file.c:stcol_format Unexecuted instantiation: stats-json.c:stcol_format Unexecuted instantiation: stats-proxy.c:stcol_format |
90 | | |
91 | | static inline enum field_nature stcol_nature(const struct stat_col *col) |
92 | 0 | { |
93 | 0 | return col->type & FN_MASK; |
94 | 0 | } Unexecuted instantiation: http_ana.c:stcol_nature Unexecuted instantiation: proxy.c:stcol_nature Unexecuted instantiation: resolvers.c:stcol_nature Unexecuted instantiation: server.c:stcol_nature Unexecuted instantiation: stats-html.c:stcol_nature Unexecuted instantiation: stats.c:stcol_nature Unexecuted instantiation: stats-file.c:stcol_nature Unexecuted instantiation: stats-json.c:stcol_nature Unexecuted instantiation: stats-proxy.c:stcol_nature |
95 | | |
96 | | static inline enum field_format field_format(const struct field *f, int e) |
97 | 0 | { |
98 | 0 | return f[e].type & FF_MASK; |
99 | 0 | } Unexecuted instantiation: http_ana.c:field_format Unexecuted instantiation: proxy.c:field_format Unexecuted instantiation: resolvers.c:field_format Unexecuted instantiation: server.c:field_format Unexecuted instantiation: stats-html.c:field_format Unexecuted instantiation: stats.c:field_format Unexecuted instantiation: stats-file.c:field_format Unexecuted instantiation: stats-json.c:field_format Unexecuted instantiation: stats-proxy.c:field_format |
100 | | |
101 | | static inline enum field_origin field_origin(const struct field *f, int e) |
102 | 0 | { |
103 | 0 | return f[e].type & FO_MASK; |
104 | 0 | } Unexecuted instantiation: http_ana.c:field_origin Unexecuted instantiation: proxy.c:field_origin Unexecuted instantiation: resolvers.c:field_origin Unexecuted instantiation: server.c:field_origin Unexecuted instantiation: stats-html.c:field_origin Unexecuted instantiation: stats.c:field_origin Unexecuted instantiation: stats-file.c:field_origin Unexecuted instantiation: stats-json.c:field_origin Unexecuted instantiation: stats-proxy.c:field_origin |
105 | | |
106 | | static inline enum field_scope field_scope(const struct field *f, int e) |
107 | 0 | { |
108 | 0 | return f[e].type & FS_MASK; |
109 | 0 | } Unexecuted instantiation: http_ana.c:field_scope Unexecuted instantiation: proxy.c:field_scope Unexecuted instantiation: resolvers.c:field_scope Unexecuted instantiation: server.c:field_scope Unexecuted instantiation: stats-html.c:field_scope Unexecuted instantiation: stats.c:field_scope Unexecuted instantiation: stats-file.c:field_scope Unexecuted instantiation: stats-json.c:field_scope Unexecuted instantiation: stats-proxy.c:field_scope |
110 | | |
111 | | static inline enum field_nature field_nature(const struct field *f, int e) |
112 | 0 | { |
113 | 0 | return f[e].type & FN_MASK; |
114 | 0 | } Unexecuted instantiation: http_ana.c:field_nature Unexecuted instantiation: proxy.c:field_nature Unexecuted instantiation: resolvers.c:field_nature Unexecuted instantiation: server.c:field_nature Unexecuted instantiation: stats-html.c:field_nature Unexecuted instantiation: stats.c:field_nature Unexecuted instantiation: stats-file.c:field_nature Unexecuted instantiation: stats-json.c:field_nature Unexecuted instantiation: stats-proxy.c:field_nature |
115 | | |
116 | | static inline const char *field_str(const struct field *f, int e) |
117 | 0 | { |
118 | 0 | return (field_format(f, e) == FF_STR && f[e].u.str) ? f[e].u.str : ""; |
119 | 0 | } Unexecuted instantiation: http_ana.c:field_str Unexecuted instantiation: proxy.c:field_str Unexecuted instantiation: resolvers.c:field_str Unexecuted instantiation: server.c:field_str Unexecuted instantiation: stats-html.c:field_str Unexecuted instantiation: stats.c:field_str Unexecuted instantiation: stats-file.c:field_str Unexecuted instantiation: stats-json.c:field_str Unexecuted instantiation: stats-proxy.c:field_str |
120 | | |
121 | | static inline struct field mkf_s32(uint32_t type, int32_t value) |
122 | 0 | { |
123 | 0 | struct field f = { .type = FF_S32 | type, .u.s32 = value }; |
124 | 0 | return f; |
125 | 0 | } Unexecuted instantiation: http_ana.c:mkf_s32 Unexecuted instantiation: proxy.c:mkf_s32 Unexecuted instantiation: resolvers.c:mkf_s32 Unexecuted instantiation: server.c:mkf_s32 Unexecuted instantiation: stats-html.c:mkf_s32 Unexecuted instantiation: stats.c:mkf_s32 Unexecuted instantiation: stats-file.c:mkf_s32 Unexecuted instantiation: stats-json.c:mkf_s32 Unexecuted instantiation: stats-proxy.c:mkf_s32 |
126 | | |
127 | | static inline struct field mkf_u32(uint32_t type, uint32_t value) |
128 | 0 | { |
129 | 0 | struct field f = { .type = FF_U32 | type, .u.u32 = value }; |
130 | 0 | return f; |
131 | 0 | } Unexecuted instantiation: http_ana.c:mkf_u32 Unexecuted instantiation: proxy.c:mkf_u32 Unexecuted instantiation: resolvers.c:mkf_u32 Unexecuted instantiation: server.c:mkf_u32 Unexecuted instantiation: stats-html.c:mkf_u32 Unexecuted instantiation: stats.c:mkf_u32 Unexecuted instantiation: stats-file.c:mkf_u32 Unexecuted instantiation: stats-json.c:mkf_u32 Unexecuted instantiation: stats-proxy.c:mkf_u32 |
132 | | |
133 | | static inline struct field mkf_s64(uint32_t type, int64_t value) |
134 | 0 | { |
135 | 0 | struct field f = { .type = FF_S64 | type, .u.s64 = value }; |
136 | 0 | return f; |
137 | 0 | } Unexecuted instantiation: http_ana.c:mkf_s64 Unexecuted instantiation: proxy.c:mkf_s64 Unexecuted instantiation: resolvers.c:mkf_s64 Unexecuted instantiation: server.c:mkf_s64 Unexecuted instantiation: stats-html.c:mkf_s64 Unexecuted instantiation: stats.c:mkf_s64 Unexecuted instantiation: stats-file.c:mkf_s64 Unexecuted instantiation: stats-json.c:mkf_s64 Unexecuted instantiation: stats-proxy.c:mkf_s64 |
138 | | |
139 | | static inline struct field mkf_u64(uint32_t type, uint64_t value) |
140 | 0 | { |
141 | 0 | struct field f = { .type = FF_U64 | type, .u.u64 = value }; |
142 | 0 | return f; |
143 | 0 | } Unexecuted instantiation: http_ana.c:mkf_u64 Unexecuted instantiation: proxy.c:mkf_u64 Unexecuted instantiation: resolvers.c:mkf_u64 Unexecuted instantiation: server.c:mkf_u64 Unexecuted instantiation: stats-html.c:mkf_u64 Unexecuted instantiation: stats.c:mkf_u64 Unexecuted instantiation: stats-file.c:mkf_u64 Unexecuted instantiation: stats-json.c:mkf_u64 Unexecuted instantiation: stats-proxy.c:mkf_u64 |
144 | | |
145 | | static inline struct field mkf_str(uint32_t type, const char *value) |
146 | 0 | { |
147 | 0 | struct field f = { .type = FF_STR | type, .u.str = value }; |
148 | 0 | return f; |
149 | 0 | } Unexecuted instantiation: http_ana.c:mkf_str Unexecuted instantiation: proxy.c:mkf_str Unexecuted instantiation: resolvers.c:mkf_str Unexecuted instantiation: server.c:mkf_str Unexecuted instantiation: stats-html.c:mkf_str Unexecuted instantiation: stats.c:mkf_str Unexecuted instantiation: stats-file.c:mkf_str Unexecuted instantiation: stats-json.c:mkf_str Unexecuted instantiation: stats-proxy.c:mkf_str |
150 | | |
151 | | static inline struct field mkf_flt(uint32_t type, double value) |
152 | 0 | { |
153 | 0 | struct field f = { .type = FF_FLT | type, .u.flt = value }; |
154 | 0 | return f; |
155 | 0 | } Unexecuted instantiation: http_ana.c:mkf_flt Unexecuted instantiation: proxy.c:mkf_flt Unexecuted instantiation: resolvers.c:mkf_flt Unexecuted instantiation: server.c:mkf_flt Unexecuted instantiation: stats-html.c:mkf_flt Unexecuted instantiation: stats.c:mkf_flt Unexecuted instantiation: stats-file.c:mkf_flt Unexecuted instantiation: stats-json.c:mkf_flt Unexecuted instantiation: stats-proxy.c:mkf_flt |
156 | | |
157 | | #define MK_STATS_PROXY_DOMAIN(px_cap) \ |
158 | | ((px_cap) << STATS_PX_CAP | STATS_DOMAIN_PROXY) |
159 | | |
160 | | static inline uint8_t stats_get_domain(uint32_t domain) |
161 | 0 | { |
162 | 0 | return domain >> STATS_DOMAIN & STATS_DOMAIN_MASK; |
163 | 0 | } Unexecuted instantiation: http_ana.c:stats_get_domain Unexecuted instantiation: proxy.c:stats_get_domain Unexecuted instantiation: resolvers.c:stats_get_domain Unexecuted instantiation: server.c:stats_get_domain Unexecuted instantiation: stats-html.c:stats_get_domain Unexecuted instantiation: stats.c:stats_get_domain Unexecuted instantiation: stats-file.c:stats_get_domain Unexecuted instantiation: stats-json.c:stats_get_domain Unexecuted instantiation: stats-proxy.c:stats_get_domain |
164 | | |
165 | | static inline enum stats_domain_px_cap stats_px_get_cap(uint32_t domain) |
166 | 0 | { |
167 | 0 | return domain >> STATS_PX_CAP & STATS_PX_CAP_MASK; |
168 | 0 | } Unexecuted instantiation: http_ana.c:stats_px_get_cap Unexecuted instantiation: proxy.c:stats_px_get_cap Unexecuted instantiation: resolvers.c:stats_px_get_cap Unexecuted instantiation: server.c:stats_px_get_cap Unexecuted instantiation: stats-html.c:stats_px_get_cap Unexecuted instantiation: stats.c:stats_px_get_cap Unexecuted instantiation: stats-file.c:stats_px_get_cap Unexecuted instantiation: stats-json.c:stats_px_get_cap Unexecuted instantiation: stats-proxy.c:stats_px_get_cap |
169 | | |
170 | | int stats_allocate_proxy_counters_internal(struct extra_counters **counters, |
171 | | int type, int px_cap, |
172 | | char **storage, size_t step); |
173 | | int stats_allocate_proxy_counters(struct proxy *px); |
174 | | |
175 | | void stats_register_module(struct stats_module *m); |
176 | | |
177 | | #endif /* _HAPROXY_STATS_H */ |
178 | | |
179 | | /* |
180 | | * Local variables: |
181 | | * c-indent-level: 8 |
182 | | * c-basic-offset: 8 |
183 | | * End: |
184 | | */ |