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