William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 1 | /* |
| 2 | * include/proto/stats.h |
| 3 | * This file contains definitions of some primitives to dedicated to |
| 4 | * statistics output. |
| 5 | * |
| 6 | * Copyright (C) 2000-2011 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 _PROTO_STATS_H |
| 24 | #define _PROTO_STATS_H |
| 25 | |
| 26 | #include <common/config.h> |
| 27 | #include <types/applet.h> |
| 28 | #include <types/stream_interface.h> |
| 29 | |
| 30 | |
| 31 | static inline enum field_format field_format(const struct field *f, int e) |
| 32 | { |
| 33 | return f[e].type & FF_MASK; |
| 34 | } |
| 35 | |
| 36 | static inline enum field_origin field_origin(const struct field *f, int e) |
| 37 | { |
| 38 | return f[e].type & FO_MASK; |
| 39 | } |
| 40 | |
| 41 | static inline enum field_scope field_scope(const struct field *f, int e) |
| 42 | { |
| 43 | return f[e].type & FS_MASK; |
| 44 | } |
| 45 | |
| 46 | static inline enum field_nature field_nature(const struct field *f, int e) |
| 47 | { |
| 48 | return f[e].type & FN_MASK; |
| 49 | } |
| 50 | |
| 51 | static inline const char *field_str(const struct field *f, int e) |
| 52 | { |
| 53 | return (field_format(f, e) == FF_STR) ? f[e].u.str : ""; |
| 54 | } |
| 55 | |
| 56 | static inline struct field mkf_s32(uint32_t type, int32_t value) |
| 57 | { |
| 58 | struct field f = { .type = FF_S32 | type, .u.s32 = value }; |
| 59 | return f; |
| 60 | } |
| 61 | |
| 62 | static inline struct field mkf_u32(uint32_t type, uint32_t value) |
| 63 | { |
| 64 | struct field f = { .type = FF_U32 | type, .u.u32 = value }; |
| 65 | return f; |
| 66 | } |
| 67 | |
| 68 | static inline struct field mkf_s64(uint32_t type, int64_t value) |
| 69 | { |
| 70 | struct field f = { .type = FF_S64 | type, .u.s64 = value }; |
| 71 | return f; |
| 72 | } |
| 73 | |
| 74 | static inline struct field mkf_u64(uint32_t type, uint64_t value) |
| 75 | { |
| 76 | struct field f = { .type = FF_U64 | type, .u.u64 = value }; |
| 77 | return f; |
| 78 | } |
| 79 | |
| 80 | static inline struct field mkf_str(uint32_t type, const char *value) |
| 81 | { |
| 82 | struct field f = { .type = FF_STR | type, .u.str = value }; |
| 83 | return f; |
| 84 | } |
| 85 | |
| 86 | /* These two structs contains all field names according with |
| 87 | * the the number of entries in "enum stat_field" and |
| 88 | * "enum info_field" |
| 89 | */ |
| 90 | extern const char *info_field_names[]; |
| 91 | extern const char *stat_field_names[]; |
| 92 | |
| 93 | int stats_fill_info(struct field *info, int len); |
| 94 | int stats_fill_fe_stats(struct proxy *px, struct field *stats, int len); |
| 95 | int stats_fill_li_stats(struct proxy *px, struct listener *l, int flags, |
| 96 | struct field *stats, int len); |
| 97 | int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags, |
| 98 | struct field *stats, int len); |
| 99 | int stats_fill_be_stats(struct proxy *px, int flags, struct field *stats, int len); |
| 100 | |
| 101 | extern struct applet http_stats_applet; |
| 102 | |
| 103 | void stats_io_handler(struct stream_interface *si); |
| 104 | int stats_emit_raw_data_field(struct chunk *out, const struct field *f); |
| 105 | int stats_emit_typed_data_field(struct chunk *out, const struct field *f); |
| 106 | int stats_emit_field_tags(struct chunk *out, const struct field *f, char delim); |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 107 | |
| 108 | #endif /* _PROTO_STATS_H */ |
| 109 | |
| 110 | /* |
| 111 | * Local variables: |
| 112 | * c-indent-level: 8 |
| 113 | * c-basic-offset: 8 |
| 114 | * End: |
| 115 | */ |