Willy Tarreau | 9186126 | 2007-10-17 17:06:05 +0200 | [diff] [blame] | 1 | /* |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 2 | * include/types/stats.h |
| 3 | * This file provides structures and types for stats. |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation, version 2.1 |
| 8 | * exclusively. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public |
| 16 | * License along with this library; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
Willy Tarreau | 9186126 | 2007-10-17 17:06:05 +0200 | [diff] [blame] | 19 | |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 20 | #ifndef _TYPES_STATS_H |
| 21 | #define _TYPES_STATS_H |
Willy Tarreau | 9186126 | 2007-10-17 17:06:05 +0200 | [diff] [blame] | 22 | |
Willy Tarreau | 295a837 | 2011-03-10 11:25:07 +0100 | [diff] [blame] | 23 | /* Flags for applet.ctx.stats.flags */ |
Willy Tarreau | 354898b | 2012-12-23 18:15:23 +0100 | [diff] [blame] | 24 | #define STAT_FMT_HTML 0x00000001 /* dump the stats in HTML format */ |
Willy Tarreau | cb80912 | 2016-01-11 20:08:42 +0100 | [diff] [blame] | 25 | #define STAT_FMT_TYPED 0x00000002 /* use the typed output format */ |
Willy Tarreau | 39f7e6d | 2008-03-17 21:38:24 +0100 | [diff] [blame] | 26 | #define STAT_HIDE_DOWN 0x00000008 /* hide 'down' servers in the stats page */ |
| 27 | #define STAT_NO_REFRESH 0x00000010 /* do not automatically refresh the stats page */ |
Cyril Bonté | 474be41 | 2010-10-12 00:14:36 +0200 | [diff] [blame] | 28 | #define STAT_ADMIN 0x00000020 /* indicate a stats admin level */ |
Willy Tarreau | af3cf70 | 2014-04-22 22:19:53 +0200 | [diff] [blame] | 29 | #define STAT_CHUNKED 0x00000040 /* use chunked encoding (HTTP/1.1) */ |
Willy Tarreau | 39f7e6d | 2008-03-17 21:38:24 +0100 | [diff] [blame] | 30 | #define STAT_BOUND 0x00800000 /* bound statistics to selected proxies/types/services */ |
Willy Tarreau | 55bb845 | 2007-10-17 18:44:57 +0200 | [diff] [blame] | 31 | |
Krzysztof Piotr Oledzki | 2c6962c | 2008-03-02 02:42:14 +0100 | [diff] [blame] | 32 | #define STATS_TYPE_FE 0 |
| 33 | #define STATS_TYPE_BE 1 |
| 34 | #define STATS_TYPE_SV 2 |
Krzysztof Piotr Oledzki | aeebf9b | 2009-10-04 15:43:17 +0200 | [diff] [blame] | 35 | #define STATS_TYPE_SO 3 |
Krzysztof Piotr Oledzki | 2c6962c | 2008-03-02 02:42:14 +0100 | [diff] [blame] | 36 | |
Willy Tarreau | 96d4491 | 2013-11-22 12:25:24 +0100 | [diff] [blame] | 37 | /* HTTP stats : applet.st0 */ |
| 38 | enum { |
| 39 | STAT_HTTP_DONE = 0, /* finished */ |
Willy Tarreau | 347a35d | 2013-11-22 17:51:09 +0100 | [diff] [blame] | 40 | STAT_HTTP_HEAD, /* send headers before dump */ |
Willy Tarreau | 96d4491 | 2013-11-22 12:25:24 +0100 | [diff] [blame] | 41 | STAT_HTTP_DUMP, /* dumping stats */ |
Willy Tarreau | 347a35d | 2013-11-22 17:51:09 +0100 | [diff] [blame] | 42 | STAT_HTTP_POST, /* waiting post data */ |
| 43 | STAT_HTTP_LAST, /* sending last chunk of response */ |
Willy Tarreau | 96d4491 | 2013-11-22 12:25:24 +0100 | [diff] [blame] | 44 | }; |
| 45 | |
de Lafond Guillaume | 88c278f | 2013-04-15 19:27:10 +0200 | [diff] [blame] | 46 | /* HTML form to limit output scope */ |
| 47 | #define STAT_SCOPE_TXT_MAXLEN 20 /* max len for scope substring */ |
| 48 | #define STAT_SCOPE_INPUT_NAME "scope" /* pattern form scope name <input> in html form */ |
| 49 | #define STAT_SCOPE_PATTERN "?" STAT_SCOPE_INPUT_NAME "=" |
| 50 | |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 51 | /* Actions available for the stats admin forms */ |
| 52 | enum { |
| 53 | ST_ADM_ACTION_NONE = 0, |
Thierry Fournier | 31e64ca | 2016-03-23 16:25:49 +0100 | [diff] [blame] | 54 | |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 55 | /* enable/disable health checks */ |
| 56 | ST_ADM_ACTION_DHLTH, |
| 57 | ST_ADM_ACTION_EHLTH, |
| 58 | |
| 59 | /* force health check status */ |
| 60 | ST_ADM_ACTION_HRUNN, |
| 61 | ST_ADM_ACTION_HNOLB, |
| 62 | ST_ADM_ACTION_HDOWN, |
| 63 | |
| 64 | /* enable/disable agent checks */ |
| 65 | ST_ADM_ACTION_DAGENT, |
| 66 | ST_ADM_ACTION_EAGENT, |
| 67 | |
| 68 | /* force agent check status */ |
| 69 | ST_ADM_ACTION_ARUNN, |
| 70 | ST_ADM_ACTION_ADOWN, |
| 71 | |
| 72 | /* set admin state */ |
| 73 | ST_ADM_ACTION_READY, |
| 74 | ST_ADM_ACTION_DRAIN, |
| 75 | ST_ADM_ACTION_MAINT, |
| 76 | ST_ADM_ACTION_SHUTDOWN, |
| 77 | /* these are the ancient actions, still available for compatibility */ |
| 78 | ST_ADM_ACTION_DISABLE, |
| 79 | ST_ADM_ACTION_ENABLE, |
| 80 | ST_ADM_ACTION_STOP, |
| 81 | ST_ADM_ACTION_START, |
Thierry Fournier | 31e64ca | 2016-03-23 16:25:49 +0100 | [diff] [blame] | 82 | }; |
| 83 | |
Thierry Fournier | 31e64ca | 2016-03-23 16:25:49 +0100 | [diff] [blame] | 84 | |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 85 | /* data transmission states for the stats responses */ |
| 86 | enum { |
| 87 | STAT_ST_INIT = 0, |
| 88 | STAT_ST_HEAD, |
| 89 | STAT_ST_INFO, |
| 90 | STAT_ST_LIST, |
| 91 | STAT_ST_END, |
| 92 | STAT_ST_FIN, |
Thierry Fournier | 31e64ca | 2016-03-23 16:25:49 +0100 | [diff] [blame] | 93 | }; |
| 94 | |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 95 | /* data transmission states for the stats responses inside a proxy */ |
| 96 | enum { |
| 97 | STAT_PX_ST_INIT = 0, |
| 98 | STAT_PX_ST_TH, |
| 99 | STAT_PX_ST_FE, |
| 100 | STAT_PX_ST_LI, |
| 101 | STAT_PX_ST_SV, |
| 102 | STAT_PX_ST_BE, |
| 103 | STAT_PX_ST_END, |
| 104 | STAT_PX_ST_FIN, |
| 105 | }; |
| 106 | |
Willy Tarreau | 8e62c05 | 2016-01-04 17:23:25 +0100 | [diff] [blame] | 107 | /* This level of detail is needed to let the stats consumer know how to |
| 108 | * aggregate them (eg: between processes or cluster nodes). Only a few |
| 109 | * combinations are actually in use, though the mechanism tends to make |
| 110 | * this easy to extend to future uses. |
| 111 | * |
| 112 | * Each reported stats element is typed based on 4 dimensions : |
| 113 | * - the field format : it indicates the validity range of the reported value, |
| 114 | * its limits and how to parse it. 6 types are currently supported : |
| 115 | * empty, signed 32-bit integer, unsigned 32-bit integer, signed 64-bit |
| 116 | * integer, unsigned 64-bit integer, string |
| 117 | * |
| 118 | * - the field origin : how was the value retrieved and what it depends on. |
| 119 | * 5 origins are currently defined : product (eg: haproxy version or |
| 120 | * release date), configuration (eg: a configured limit), key (identifier |
| 121 | * used to group values at a certain level), metric (a measure of something), |
| 122 | * status (something discrete which by definition cannot be averaged nor |
| 123 | * aggregated, such as "listening" versus "full"). |
| 124 | * |
| 125 | * - the field nature : what does the data represent, implying how to aggregate |
| 126 | * it. At least 9 different natures are expected : counter (an increasing |
| 127 | * positive counter that may wrap when its type is overflown such as a byte |
| 128 | * counter), gauge (a measure at any instant that may vary, such as a |
| 129 | * concurrent connection count), a limit (eg: maximum acceptable concurrent |
| 130 | * connections), a minimum (eg: minimum free memory over a period), a |
| 131 | * maximum (eg: highest queue length over a period), an event rate (eg: |
| 132 | * incoming connections per second), a duration that is often aggregated by |
| 133 | * taking the max (eg: service uptime), an age that generally reports the |
| 134 | * last time an event appeared and which generally is aggregated by taking |
| 135 | * the most recent event hence the smallest one, the time which reports a |
| 136 | * discrete instant and cannot obviously be averaged either, a name which |
| 137 | * will generally be the name of an entity (such as a server name or cookie |
| 138 | * name), an output which is mostly used for various unsafe strings that are |
| 139 | * retrieved (eg: last check output, product name, description, etc), and an |
| 140 | * average which indicates that the value is relative and meant to be averaged |
| 141 | * between all nodes (eg: response time, throttling, etc). |
| 142 | * |
| 143 | * - the field scope : if the value is shared with other elements, which ones |
| 144 | * are expected to report the same value. The first scope with the least |
| 145 | * share is the process (most common one) where all data are only relevant |
| 146 | * to the process being consulted. The next one is the service, which is |
| 147 | * valid for all processes launched together (eg: shared SSL cache usage |
| 148 | * among processes). The next one is the system (such as the OS version) |
| 149 | * and which will report the same information for all instances running on |
| 150 | * the same node. The next one is the cluster, which indicates that the |
| 151 | * information are shared with other nodes being part of a same cluster. |
| 152 | * Stick-tables may carry such cluster-wide information. Larger scopes may |
| 153 | * be added in the future such as datacenter, country, continent, planet, |
| 154 | * galaxy, universe, etc. |
| 155 | * |
| 156 | * All these information will be encoded in the field as a bit field so that |
| 157 | * it is easy to pass composite values by simply ORing elements above, and |
| 158 | * to ease the definition of a few field types for the most common field |
| 159 | * combinations. |
| 160 | * |
| 161 | * The enums try to be arranged so that most likely characteristics are |
| 162 | * assigned the value zero, making it easier to add new fields. |
| 163 | * |
| 164 | * Field format has precedence over the other parts of the type. Please avoid |
| 165 | * declaring extra formats unless absolutely needed. The first one, FF_EMPTY, |
| 166 | * must absolutely have value zero so that it is what is returned after a |
| 167 | * memset(0). Furthermore, the producer is responsible for ensuring that when |
| 168 | * this format is set, all other bits of the type as well as the values in the |
| 169 | * union only contain zeroes. This makes it easier for the consumer to use the |
| 170 | * values as the expected type. |
| 171 | */ |
| 172 | |
| 173 | enum field_format { |
| 174 | FF_EMPTY = 0x00000000, |
| 175 | FF_S32 = 0x00000001, |
| 176 | FF_U32 = 0x00000002, |
| 177 | FF_S64 = 0x00000003, |
| 178 | FF_U64 = 0x00000004, |
| 179 | FF_STR = 0x00000005, |
| 180 | FF_MASK = 0x000000FF, |
| 181 | }; |
| 182 | |
| 183 | enum field_origin { |
| 184 | FO_METRIC = 0x00000000, |
| 185 | FO_STATUS = 0x00000100, |
| 186 | FO_KEY = 0x00000200, |
| 187 | FO_CONFIG = 0x00000300, |
| 188 | FO_PRODUCT = 0x00000400, |
| 189 | FO_MASK = 0x0000FF00, |
| 190 | }; |
| 191 | |
| 192 | enum field_nature { |
| 193 | FN_GAUGE = 0x00000000, |
| 194 | FN_LIMIT = 0x00010000, |
| 195 | FN_MIN = 0x00020000, |
| 196 | FN_MAX = 0x00030000, |
| 197 | FN_RATE = 0x00040000, |
| 198 | FN_COUNTER = 0x00050000, |
| 199 | FN_DURATION = 0x00060000, |
| 200 | FN_AGE = 0x00070000, |
| 201 | FN_TIME = 0x00080000, |
| 202 | FN_NAME = 0x00090000, |
| 203 | FN_OUTPUT = 0x000A0000, |
| 204 | FN_AVG = 0x000B0000, |
| 205 | FN_MASK = 0x00FF0000, |
| 206 | }; |
| 207 | |
| 208 | enum field_scope { |
| 209 | FS_PROCESS = 0x00000000, |
| 210 | FS_SERVICE = 0x01000000, |
| 211 | FS_SYSTEM = 0x02000000, |
| 212 | FS_CLUSTER = 0x03000000, |
| 213 | FS_MASK = 0xFF000000, |
| 214 | }; |
| 215 | |
| 216 | struct field { |
| 217 | uint32_t type; |
| 218 | union { |
| 219 | int32_t s32; /* FF_S32 */ |
| 220 | uint32_t u32; /* FF_U32 */ |
| 221 | int64_t s64; /* FF_S64 */ |
| 222 | uint64_t u64; /* FF_U64 */ |
| 223 | const char *str; /* FF_STR */ |
| 224 | } u; |
| 225 | }; |
| 226 | |
Willy Tarreau | 0baac8c | 2016-11-22 16:36:53 +0100 | [diff] [blame] | 227 | /* Show Info fields for CLI output. For any field added here, please add the text |
| 228 | * representation in the info_field_names array below. Please only append at the end, |
| 229 | * before the INF_TOTAL_FIELDS entry, and never insert anything in the middle |
| 230 | * nor at the beginning. |
| 231 | */ |
| 232 | enum info_field { |
| 233 | INF_NAME, |
| 234 | INF_VERSION, |
| 235 | INF_RELEASE_DATE, |
| 236 | INF_NBPROC, |
| 237 | INF_PROCESS_NUM, |
| 238 | INF_PID, |
| 239 | INF_UPTIME, |
| 240 | INF_UPTIME_SEC, |
| 241 | INF_MEMMAX_MB, |
| 242 | INF_POOL_ALLOC_MB, |
| 243 | INF_POOL_USED_MB, |
| 244 | INF_POOL_FAILED, |
| 245 | INF_ULIMIT_N, |
| 246 | INF_MAXSOCK, |
| 247 | INF_MAXCONN, |
| 248 | INF_HARD_MAXCONN, |
| 249 | INF_CURR_CONN, |
| 250 | INF_CUM_CONN, |
| 251 | INF_CUM_REQ, |
| 252 | INF_MAX_SSL_CONNS, |
| 253 | INF_CURR_SSL_CONNS, |
| 254 | INF_CUM_SSL_CONNS, |
| 255 | INF_MAXPIPES, |
| 256 | INF_PIPES_USED, |
| 257 | INF_PIPES_FREE, |
| 258 | INF_CONN_RATE, |
| 259 | INF_CONN_RATE_LIMIT, |
| 260 | INF_MAX_CONN_RATE, |
| 261 | INF_SESS_RATE, |
| 262 | INF_SESS_RATE_LIMIT, |
| 263 | INF_MAX_SESS_RATE, |
| 264 | INF_SSL_RATE, |
| 265 | INF_SSL_RATE_LIMIT, |
| 266 | INF_MAX_SSL_RATE, |
| 267 | INF_SSL_FRONTEND_KEY_RATE, |
| 268 | INF_SSL_FRONTEND_MAX_KEY_RATE, |
| 269 | INF_SSL_FRONTEND_SESSION_REUSE_PCT, |
| 270 | INF_SSL_BACKEND_KEY_RATE, |
| 271 | INF_SSL_BACKEND_MAX_KEY_RATE, |
| 272 | INF_SSL_CACHE_LOOKUPS, |
| 273 | INF_SSL_CACHE_MISSES, |
| 274 | INF_COMPRESS_BPS_IN, |
| 275 | INF_COMPRESS_BPS_OUT, |
| 276 | INF_COMPRESS_BPS_RATE_LIM, |
| 277 | INF_ZLIB_MEM_USAGE, |
| 278 | INF_MAX_ZLIB_MEM_USAGE, |
| 279 | INF_TASKS, |
| 280 | INF_RUN_QUEUE, |
| 281 | INF_IDLE_PCT, |
| 282 | INF_NODE, |
| 283 | INF_DESCRIPTION, |
| 284 | |
| 285 | /* must always be the last one */ |
| 286 | INF_TOTAL_FIELDS |
| 287 | }; |
| 288 | |
| 289 | |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 290 | /* Stats fields for CSV output. For any field added here, please add the text |
| 291 | * representation in the stat_field_names array below. Please only append at the end, |
| 292 | * before the ST_F_TOTAL_FIELDS entry, and never insert anything in the middle |
| 293 | * nor at the beginning. |
Thierry Fournier | 31e64ca | 2016-03-23 16:25:49 +0100 | [diff] [blame] | 294 | */ |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 295 | enum stat_field { |
| 296 | ST_F_PXNAME, |
| 297 | ST_F_SVNAME, |
| 298 | ST_F_QCUR, |
| 299 | ST_F_QMAX, |
| 300 | ST_F_SCUR, |
| 301 | ST_F_SMAX, |
| 302 | ST_F_SLIM, |
| 303 | ST_F_STOT, |
| 304 | ST_F_BIN , |
| 305 | ST_F_BOUT, |
| 306 | ST_F_DREQ, |
| 307 | ST_F_DRESP, |
| 308 | ST_F_EREQ, |
| 309 | ST_F_ECON, |
| 310 | ST_F_ERESP, |
| 311 | ST_F_WRETR, |
| 312 | ST_F_WREDIS, |
| 313 | ST_F_STATUS, |
| 314 | ST_F_WEIGHT, |
| 315 | ST_F_ACT, |
| 316 | ST_F_BCK, |
| 317 | ST_F_CHKFAIL, |
| 318 | ST_F_CHKDOWN, |
| 319 | ST_F_LASTCHG, |
| 320 | ST_F_DOWNTIME, |
| 321 | ST_F_QLIMIT, |
| 322 | ST_F_PID, |
| 323 | ST_F_IID, |
| 324 | ST_F_SID, |
| 325 | ST_F_THROTTLE, |
| 326 | ST_F_LBTOT, |
| 327 | ST_F_TRACKED, |
| 328 | ST_F_TYPE, |
| 329 | ST_F_RATE, |
| 330 | ST_F_RATE_LIM, |
| 331 | ST_F_RATE_MAX, |
| 332 | ST_F_CHECK_STATUS, |
| 333 | ST_F_CHECK_CODE, |
| 334 | ST_F_CHECK_DURATION, |
| 335 | ST_F_HRSP_1XX, |
| 336 | ST_F_HRSP_2XX, |
| 337 | ST_F_HRSP_3XX, |
| 338 | ST_F_HRSP_4XX, |
| 339 | ST_F_HRSP_5XX, |
| 340 | ST_F_HRSP_OTHER, |
| 341 | ST_F_HANAFAIL, |
| 342 | ST_F_REQ_RATE, |
| 343 | ST_F_REQ_RATE_MAX, |
| 344 | ST_F_REQ_TOT, |
| 345 | ST_F_CLI_ABRT, |
| 346 | ST_F_SRV_ABRT, |
| 347 | ST_F_COMP_IN, |
| 348 | ST_F_COMP_OUT, |
| 349 | ST_F_COMP_BYP, |
| 350 | ST_F_COMP_RSP, |
| 351 | ST_F_LASTSESS, |
| 352 | ST_F_LAST_CHK, |
| 353 | ST_F_LAST_AGT, |
| 354 | ST_F_QTIME, |
| 355 | ST_F_CTIME, |
| 356 | ST_F_RTIME, |
| 357 | ST_F_TTIME, |
| 358 | ST_F_AGENT_STATUS, |
| 359 | ST_F_AGENT_CODE, |
| 360 | ST_F_AGENT_DURATION, |
| 361 | ST_F_CHECK_DESC, |
| 362 | ST_F_AGENT_DESC, |
| 363 | ST_F_CHECK_RISE, |
| 364 | ST_F_CHECK_FALL, |
| 365 | ST_F_CHECK_HEALTH, |
| 366 | ST_F_AGENT_RISE, |
| 367 | ST_F_AGENT_FALL, |
| 368 | ST_F_AGENT_HEALTH, |
| 369 | ST_F_ADDR, |
| 370 | ST_F_COOKIE, |
| 371 | ST_F_MODE, |
| 372 | ST_F_ALGO, |
| 373 | ST_F_CONN_RATE, |
| 374 | ST_F_CONN_RATE_MAX, |
| 375 | ST_F_CONN_TOT, |
| 376 | ST_F_INTERCEPTED, |
| 377 | ST_F_DCON, |
| 378 | ST_F_DSES, |
William Lallemand | 1e08cd8 | 2016-10-13 17:57:55 +0200 | [diff] [blame] | 379 | |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 380 | /* must always be the last one */ |
| 381 | ST_F_TOTAL_FIELDS |
William Lallemand | 1e08cd8 | 2016-10-13 17:57:55 +0200 | [diff] [blame] | 382 | }; |
| 383 | |
William Lallemand | 74c24fb | 2016-11-21 17:18:36 +0100 | [diff] [blame] | 384 | |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 385 | #endif /* _TYPES_STATS_H */ |