Willy Tarreau | 4151c75 | 2019-08-08 18:21:26 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Runtime tracing API |
| 3 | * |
| 4 | * Copyright (C) 2000-2019 Willy Tarreau - w@1wt.eu |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation, version 2.1 |
| 9 | * exclusively. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
Willy Tarreau | eb6f701 | 2020-05-27 16:21:26 +0200 | [diff] [blame] | 21 | #include <import/ist.h> |
Willy Tarreau | 2741c8c | 2020-06-02 11:28:02 +0200 | [diff] [blame] | 22 | #include <haproxy/api.h> |
| 23 | #include <haproxy/buf.h> |
Willy Tarreau | 83487a8 | 2020-06-04 20:19:54 +0200 | [diff] [blame] | 24 | #include <haproxy/cli.h> |
Willy Tarreau | 36979d9 | 2020-06-05 17:27:29 +0200 | [diff] [blame] | 25 | #include <haproxy/errors.h> |
Willy Tarreau | 2741c8c | 2020-06-02 11:28:02 +0200 | [diff] [blame] | 26 | #include <haproxy/istbuf.h> |
Willy Tarreau | 853b297 | 2020-05-27 18:01:47 +0200 | [diff] [blame] | 27 | #include <haproxy/list.h> |
Willy Tarreau | aeed4a8 | 2020-06-04 22:01:04 +0200 | [diff] [blame] | 28 | #include <haproxy/log.h> |
Willy Tarreau | ba2f73d | 2020-06-03 20:02:28 +0200 | [diff] [blame] | 29 | #include <haproxy/sink.h> |
Willy Tarreau | c6d61d7 | 2020-06-04 19:02:42 +0200 | [diff] [blame] | 30 | #include <haproxy/trace.h> |
Willy Tarreau | 4151c75 | 2019-08-08 18:21:26 +0200 | [diff] [blame] | 31 | |
| 32 | struct list trace_sources = LIST_HEAD_INIT(trace_sources); |
Willy Tarreau | 88ebd40 | 2019-08-19 15:55:34 +0200 | [diff] [blame] | 33 | THREAD_LOCAL struct buffer trace_buf = { }; |
| 34 | |
| 35 | /* allocates the trace buffers. Returns 0 in case of failure. It is safe to |
| 36 | * call to call this function multiple times if the size changes. |
| 37 | */ |
| 38 | static int alloc_trace_buffers_per_thread() |
| 39 | { |
| 40 | chunk_init(&trace_buf, my_realloc2(trace_buf.area, global.tune.bufsize), global.tune.bufsize); |
Willy Tarreau | 2e7fdfc | 2019-11-25 19:43:31 +0100 | [diff] [blame] | 41 | return !!trace_buf.area; |
Willy Tarreau | 88ebd40 | 2019-08-19 15:55:34 +0200 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | static void free_trace_buffers_per_thread() |
| 45 | { |
| 46 | chunk_destroy(&trace_buf); |
| 47 | } |
Willy Tarreau | 4151c75 | 2019-08-08 18:21:26 +0200 | [diff] [blame] | 48 | |
Willy Tarreau | 88ebd40 | 2019-08-19 15:55:34 +0200 | [diff] [blame] | 49 | REGISTER_PER_THREAD_ALLOC(alloc_trace_buffers_per_thread); |
| 50 | REGISTER_PER_THREAD_FREE(free_trace_buffers_per_thread); |
Willy Tarreau | 864e880 | 2019-08-08 18:48:12 +0200 | [diff] [blame] | 51 | |
Willy Tarreau | d8b99ed | 2019-08-21 17:05:46 +0200 | [diff] [blame] | 52 | /* pick the lowest non-null argument with a non-null arg_def mask */ |
| 53 | static inline const void *trace_pick_arg(uint32_t arg_def, const void *a1, const void *a2, const void *a3, const void *a4) |
| 54 | { |
| 55 | if (arg_def & 0x0000FFFF) { |
| 56 | if ((arg_def & 0x000000FF) && a1) |
| 57 | return a1; |
| 58 | if ((arg_def & 0x0000FF00) && a2) |
| 59 | return a2; |
| 60 | } |
| 61 | |
| 62 | if (arg_def & 0xFFFF0000) { |
| 63 | if ((arg_def & 0x00FF0000) && a3) |
| 64 | return a3; |
| 65 | if ((arg_def & 0xFF000000) && a4) |
| 66 | return a4; |
| 67 | } |
| 68 | |
| 69 | return NULL; |
| 70 | } |
| 71 | |
Willy Tarreau | 4c2ae48 | 2019-08-12 15:51:58 +0200 | [diff] [blame] | 72 | /* write a message for the given trace source */ |
Willy Tarreau | 09fb0df | 2019-08-29 08:40:59 +0200 | [diff] [blame] | 73 | void __trace(enum trace_level level, uint64_t mask, struct trace_source *src, |
| 74 | const struct ist where, const char *func, |
Willy Tarreau | bfd14fc | 2019-08-19 16:28:07 +0200 | [diff] [blame] | 75 | const void *a1, const void *a2, const void *a3, const void *a4, |
Willy Tarreau | 09fb0df | 2019-08-29 08:40:59 +0200 | [diff] [blame] | 76 | void (*cb)(enum trace_level level, uint64_t mask, const struct trace_source *src, |
| 77 | const struct ist where, const struct ist func, |
Willy Tarreau | bfd14fc | 2019-08-19 16:28:07 +0200 | [diff] [blame] | 78 | const void *a1, const void *a2, const void *a3, const void *a4), |
| 79 | const struct ist msg) |
Willy Tarreau | 4c2ae48 | 2019-08-12 15:51:58 +0200 | [diff] [blame] | 80 | { |
Willy Tarreau | d8b99ed | 2019-08-21 17:05:46 +0200 | [diff] [blame] | 81 | const struct listener *li = NULL; |
| 82 | const struct proxy *fe = NULL; |
| 83 | const struct proxy *be = NULL; |
| 84 | const struct server *srv = NULL; |
| 85 | const struct session *sess = NULL; |
| 86 | const struct stream *strm = NULL; |
| 87 | const struct connection *conn = NULL; |
Christopher Faulet | 6d80b63 | 2021-04-12 11:53:16 +0200 | [diff] [blame] | 88 | const struct check *check = NULL; |
Willy Tarreau | d8b99ed | 2019-08-21 17:05:46 +0200 | [diff] [blame] | 89 | const void *lockon_ptr = NULL; |
Willy Tarreau | 09fb0df | 2019-08-29 08:40:59 +0200 | [diff] [blame] | 90 | struct ist ist_func = ist(func); |
Willy Tarreau | a9f5b96 | 2019-08-28 10:08:58 +0200 | [diff] [blame] | 91 | char tnum[4]; |
Willy Tarreau | 052ad36 | 2019-08-29 09:08:36 +0200 | [diff] [blame] | 92 | struct ist line[12]; |
Willy Tarreau | 09fb0df | 2019-08-29 08:40:59 +0200 | [diff] [blame] | 93 | int words = 0; |
Willy Tarreau | 419bd49 | 2019-08-12 17:27:09 +0200 | [diff] [blame] | 94 | |
Willy Tarreau | 4c2ae48 | 2019-08-12 15:51:58 +0200 | [diff] [blame] | 95 | if (likely(src->state == TRACE_STATE_STOPPED)) |
| 96 | return; |
| 97 | |
| 98 | /* check that at least one action is interested by this event */ |
| 99 | if (((src->report_events | src->start_events | src->pause_events | src->stop_events) & mask) == 0) |
| 100 | return; |
| 101 | |
Willy Tarreau | d8b99ed | 2019-08-21 17:05:46 +0200 | [diff] [blame] | 102 | /* retrieve available information from the caller's arguments */ |
| 103 | if (src->arg_def & TRC_ARGS_CONN) |
| 104 | conn = trace_pick_arg(src->arg_def & TRC_ARGS_CONN, a1, a2, a3, a4); |
| 105 | |
| 106 | if (src->arg_def & TRC_ARGS_SESS) |
| 107 | sess = trace_pick_arg(src->arg_def & TRC_ARGS_SESS, a1, a2, a3, a4); |
| 108 | |
| 109 | if (src->arg_def & TRC_ARGS_STRM) |
| 110 | strm = trace_pick_arg(src->arg_def & TRC_ARGS_STRM, a1, a2, a3, a4); |
| 111 | |
Christopher Faulet | 6d80b63 | 2021-04-12 11:53:16 +0200 | [diff] [blame] | 112 | if (src->arg_def & TRC_ARGS_CHK) |
| 113 | check = trace_pick_arg(src->arg_def & TRC_ARGS_CHK, a1, a2, a3, a4); |
| 114 | |
Willy Tarreau | d8b99ed | 2019-08-21 17:05:46 +0200 | [diff] [blame] | 115 | if (!sess && strm) |
| 116 | sess = strm->sess; |
Willy Tarreau | a547018 | 2022-03-18 17:37:20 +0100 | [diff] [blame] | 117 | else if (!sess && conn && LIST_INLIST(&conn->session_list)) |
Willy Tarreau | d8b99ed | 2019-08-21 17:05:46 +0200 | [diff] [blame] | 118 | sess = conn->owner; |
Christopher Faulet | 6d80b63 | 2021-04-12 11:53:16 +0200 | [diff] [blame] | 119 | else if (!sess && check) |
| 120 | sess = check->sess; |
Willy Tarreau | d8b99ed | 2019-08-21 17:05:46 +0200 | [diff] [blame] | 121 | |
| 122 | if (sess) { |
| 123 | fe = sess->fe; |
| 124 | li = sess->listener; |
| 125 | } |
| 126 | |
| 127 | if (!li && conn) |
| 128 | li = objt_listener(conn->target); |
| 129 | |
| 130 | if (li && !fe) |
| 131 | fe = li->bind_conf->frontend; |
| 132 | |
| 133 | if (strm) { |
| 134 | be = strm->be; |
| 135 | srv = strm->srv_conn; |
| 136 | } |
Christopher Faulet | 6d80b63 | 2021-04-12 11:53:16 +0200 | [diff] [blame] | 137 | if (check) { |
| 138 | srv = check->server; |
Christopher Faulet | add68c8 | 2022-06-08 09:06:15 +0200 | [diff] [blame] | 139 | be = (srv ? srv->proxy : NULL); |
Christopher Faulet | 6d80b63 | 2021-04-12 11:53:16 +0200 | [diff] [blame] | 140 | } |
Willy Tarreau | d8b99ed | 2019-08-21 17:05:46 +0200 | [diff] [blame] | 141 | |
| 142 | if (!srv && conn) |
| 143 | srv = objt_server(conn->target); |
| 144 | |
| 145 | if (srv && !be) |
| 146 | be = srv->proxy; |
| 147 | |
| 148 | if (!be && conn) |
| 149 | be = objt_proxy(conn->target); |
| 150 | |
Willy Tarreau | 4c2ae48 | 2019-08-12 15:51:58 +0200 | [diff] [blame] | 151 | /* TODO: add handling of filters here, return if no match (not even update states) */ |
| 152 | |
| 153 | /* check if we need to start the trace now */ |
| 154 | if (src->state == TRACE_STATE_WAITING) { |
| 155 | if ((src->start_events & mask) == 0) |
| 156 | return; |
| 157 | |
| 158 | /* TODO: add update of lockon+lockon_ptr here */ |
| 159 | HA_ATOMIC_STORE(&src->state, TRACE_STATE_RUNNING); |
| 160 | } |
| 161 | |
Willy Tarreau | d8b99ed | 2019-08-21 17:05:46 +0200 | [diff] [blame] | 162 | /* we may want to lock on a particular object */ |
| 163 | if (src->lockon != TRACE_LOCKON_NOTHING) { |
| 164 | switch (src->lockon) { |
| 165 | case TRACE_LOCKON_BACKEND: lockon_ptr = be; break; |
| 166 | case TRACE_LOCKON_CONNECTION: lockon_ptr = conn; break; |
| 167 | case TRACE_LOCKON_FRONTEND: lockon_ptr = fe; break; |
| 168 | case TRACE_LOCKON_LISTENER: lockon_ptr = li; break; |
| 169 | case TRACE_LOCKON_SERVER: lockon_ptr = srv; break; |
| 170 | case TRACE_LOCKON_SESSION: lockon_ptr = sess; break; |
| 171 | case TRACE_LOCKON_STREAM: lockon_ptr = strm; break; |
Christopher Faulet | 6d80b63 | 2021-04-12 11:53:16 +0200 | [diff] [blame] | 172 | case TRACE_LOCKON_CHECK: lockon_ptr = check; break; |
Willy Tarreau | d8b99ed | 2019-08-21 17:05:46 +0200 | [diff] [blame] | 173 | case TRACE_LOCKON_THREAD: lockon_ptr = ti; break; |
| 174 | case TRACE_LOCKON_ARG1: lockon_ptr = a1; break; |
| 175 | case TRACE_LOCKON_ARG2: lockon_ptr = a2; break; |
| 176 | case TRACE_LOCKON_ARG3: lockon_ptr = a3; break; |
| 177 | case TRACE_LOCKON_ARG4: lockon_ptr = a4; break; |
| 178 | default: break; // silence stupid gcc -Wswitch |
| 179 | } |
| 180 | |
| 181 | if (src->lockon_ptr && src->lockon_ptr != lockon_ptr) |
| 182 | return; |
| 183 | |
| 184 | if (!src->lockon_ptr && lockon_ptr && src->state == TRACE_STATE_RUNNING) |
| 185 | HA_ATOMIC_STORE(&src->lockon_ptr, lockon_ptr); |
| 186 | } |
| 187 | |
Willy Tarreau | 4c2ae48 | 2019-08-12 15:51:58 +0200 | [diff] [blame] | 188 | /* here the trace is running and is tracking a desired item */ |
| 189 | |
Willy Tarreau | 5da4088 | 2019-08-12 17:57:57 +0200 | [diff] [blame] | 190 | if ((src->report_events & mask) == 0 || level > src->level) |
Willy Tarreau | 4c2ae48 | 2019-08-12 15:51:58 +0200 | [diff] [blame] | 191 | goto end; |
| 192 | |
Willy Tarreau | 419bd49 | 2019-08-12 17:27:09 +0200 | [diff] [blame] | 193 | /* log the logging location truncated to 10 chars from the right so that |
| 194 | * the line number and the end of the file name are there. |
| 195 | */ |
Willy Tarreau | 09fb0df | 2019-08-29 08:40:59 +0200 | [diff] [blame] | 196 | line[words++] = ist("["); |
Willy Tarreau | a9f5b96 | 2019-08-28 10:08:58 +0200 | [diff] [blame] | 197 | tnum[0] = '0' + tid / 10; |
| 198 | tnum[1] = '0' + tid % 10; |
| 199 | tnum[2] = '|'; |
| 200 | tnum[3] = 0; |
Willy Tarreau | 09fb0df | 2019-08-29 08:40:59 +0200 | [diff] [blame] | 201 | line[words++] = ist(tnum); |
| 202 | line[words++] = src->name; |
| 203 | line[words++] = ist("|"); |
Frédéric Lécaille | fd18314 | 2020-12-02 16:51:00 +0100 | [diff] [blame] | 204 | line[words++] = ist2("012345" + level, 1); // "0" to "5" |
Willy Tarreau | 052ad36 | 2019-08-29 09:08:36 +0200 | [diff] [blame] | 205 | line[words++] = ist("|"); |
Willy Tarreau | 09fb0df | 2019-08-29 08:40:59 +0200 | [diff] [blame] | 206 | line[words] = where; |
| 207 | if (line[words].len > 13) { |
| 208 | line[words].ptr += (line[words].len - 13); |
| 209 | line[words].len = 13; |
Willy Tarreau | 419bd49 | 2019-08-12 17:27:09 +0200 | [diff] [blame] | 210 | } |
Willy Tarreau | 09fb0df | 2019-08-29 08:40:59 +0200 | [diff] [blame] | 211 | words++; |
| 212 | line[words++] = ist("] "); |
| 213 | |
Tim Duesterhus | 7b5777d | 2021-03-02 18:57:28 +0100 | [diff] [blame] | 214 | if (isttest(ist_func)) { |
Willy Tarreau | 09fb0df | 2019-08-29 08:40:59 +0200 | [diff] [blame] | 215 | line[words++] = ist_func; |
| 216 | line[words++] = ist("(): "); |
| 217 | } |
Willy Tarreau | bfd14fc | 2019-08-19 16:28:07 +0200 | [diff] [blame] | 218 | |
Willy Tarreau | 3da0026 | 2019-08-28 07:03:58 +0200 | [diff] [blame] | 219 | if (!cb) |
| 220 | cb = src->default_cb; |
| 221 | |
Willy Tarreau | 370a694 | 2019-08-29 08:24:16 +0200 | [diff] [blame] | 222 | if (cb && src->verbosity) { |
Willy Tarreau | bfd14fc | 2019-08-19 16:28:07 +0200 | [diff] [blame] | 223 | /* decode function passed, we want to pre-fill the |
| 224 | * buffer with the message and let the decode function |
| 225 | * do its job, possibly even overwriting it. |
| 226 | */ |
| 227 | b_reset(&trace_buf); |
| 228 | b_istput(&trace_buf, msg); |
Willy Tarreau | 09fb0df | 2019-08-29 08:40:59 +0200 | [diff] [blame] | 229 | cb(level, mask, src, where, ist_func, a1, a2, a3, a4); |
Tim Duesterhus | 92c696e | 2021-02-28 16:11:36 +0100 | [diff] [blame] | 230 | line[words] = ist2(trace_buf.area, trace_buf.data); |
Willy Tarreau | 09fb0df | 2019-08-29 08:40:59 +0200 | [diff] [blame] | 231 | words++; |
Willy Tarreau | bfd14fc | 2019-08-19 16:28:07 +0200 | [diff] [blame] | 232 | } |
Willy Tarreau | 370a694 | 2019-08-29 08:24:16 +0200 | [diff] [blame] | 233 | else { |
| 234 | /* Note that here we could decide to print some args whose type |
| 235 | * is known, when verbosity is above the quiet level, and even |
| 236 | * to print the name and values of those which are declared for |
| 237 | * lock-on. |
| 238 | */ |
Willy Tarreau | 09fb0df | 2019-08-29 08:40:59 +0200 | [diff] [blame] | 239 | line[words++] = msg; |
Willy Tarreau | 370a694 | 2019-08-29 08:24:16 +0200 | [diff] [blame] | 240 | } |
Willy Tarreau | 419bd49 | 2019-08-12 17:27:09 +0200 | [diff] [blame] | 241 | |
Willy Tarreau | 4c2ae48 | 2019-08-12 15:51:58 +0200 | [diff] [blame] | 242 | if (src->sink) |
Aurelien DARRAGON | c242313 | 2023-06-26 16:44:41 +0200 | [diff] [blame] | 243 | sink_write(src->sink, 0, line, words, 0, 0, NULL); |
Willy Tarreau | 4c2ae48 | 2019-08-12 15:51:58 +0200 | [diff] [blame] | 244 | |
| 245 | end: |
| 246 | /* check if we need to stop the trace now */ |
| 247 | if ((src->stop_events & mask) != 0) { |
Willy Tarreau | beadb5c | 2019-08-20 18:57:48 +0200 | [diff] [blame] | 248 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
Willy Tarreau | 4c2ae48 | 2019-08-12 15:51:58 +0200 | [diff] [blame] | 249 | HA_ATOMIC_STORE(&src->state, TRACE_STATE_STOPPED); |
| 250 | } |
| 251 | else if ((src->pause_events & mask) != 0) { |
Willy Tarreau | beadb5c | 2019-08-20 18:57:48 +0200 | [diff] [blame] | 252 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
Willy Tarreau | 4c2ae48 | 2019-08-12 15:51:58 +0200 | [diff] [blame] | 253 | HA_ATOMIC_STORE(&src->state, TRACE_STATE_WAITING); |
| 254 | } |
| 255 | } |
| 256 | |
Willy Tarreau | 864e880 | 2019-08-08 18:48:12 +0200 | [diff] [blame] | 257 | struct trace_source *trace_find_source(const char *name) |
| 258 | { |
| 259 | struct trace_source *src; |
| 260 | const struct ist iname = ist(name); |
| 261 | |
| 262 | list_for_each_entry(src, &trace_sources, source_link) |
| 263 | if (isteq(src->name, iname)) |
| 264 | return src; |
| 265 | return NULL; |
| 266 | } |
| 267 | |
| 268 | const struct trace_event *trace_find_event(const struct trace_event *ev, const char *name) |
| 269 | { |
| 270 | for (; ev && ev->mask; ev++) |
| 271 | if (strcmp(ev->name, name) == 0) |
| 272 | return ev; |
| 273 | return NULL; |
| 274 | } |
| 275 | |
| 276 | /* parse the command, returns 1 if a message is returned, otherwise zero */ |
| 277 | static int cli_parse_trace(char **args, char *payload, struct appctx *appctx, void *private) |
| 278 | { |
| 279 | struct trace_source *src; |
| 280 | uint64_t *ev_ptr = NULL; |
| 281 | |
| 282 | if (!cli_has_level(appctx, ACCESS_LVL_OPER)) |
| 283 | return 1; |
| 284 | |
| 285 | if (!*args[1]) { |
| 286 | /* no arg => report the list of supported sources as a warning */ |
| 287 | chunk_printf(&trash, |
| 288 | "Supported trace sources and states (.=stopped, w=waiting, R=running) :\n" |
| 289 | " [.] 0 : not a source, will immediately stop all traces\n" |
| 290 | ); |
| 291 | |
| 292 | list_for_each_entry(src, &trace_sources, source_link) |
| 293 | chunk_appendf(&trash, " [%c] %-10s : %s\n", trace_state_char(src->state), src->name.ptr, src->desc); |
| 294 | |
| 295 | trash.area[trash.data] = 0; |
| 296 | return cli_msg(appctx, LOG_WARNING, trash.area); |
| 297 | } |
| 298 | |
| 299 | if (strcmp(args[1], "0") == 0) { |
| 300 | /* emergency stop of all traces */ |
| 301 | list_for_each_entry(src, &trace_sources, source_link) |
| 302 | HA_ATOMIC_STORE(&src->state, TRACE_STATE_STOPPED); |
| 303 | return cli_msg(appctx, LOG_NOTICE, "All traces now stopped"); |
| 304 | } |
| 305 | |
| 306 | src = trace_find_source(args[1]); |
| 307 | if (!src) |
| 308 | return cli_err(appctx, "No such trace source"); |
| 309 | |
| 310 | if (!*args[2]) { |
| 311 | return cli_msg(appctx, LOG_WARNING, |
| 312 | "Supported commands:\n" |
Willy Tarreau | 370a694 | 2019-08-29 08:24:16 +0200 | [diff] [blame] | 313 | " event : list/enable/disable source-specific event reporting\n" |
| 314 | //" filter : list/enable/disable generic filters\n" |
| 315 | " level : list/set trace reporting level\n" |
| 316 | " lock : automatic lock on thread/connection/stream/...\n" |
| 317 | " pause : pause and automatically restart after a specific event\n" |
| 318 | " sink : list/set event sinks\n" |
| 319 | " start : start immediately or after a specific event\n" |
| 320 | " stop : stop immediately or after a specific event\n" |
| 321 | " verbosity : list/set trace output verbosity\n" |
Willy Tarreau | 864e880 | 2019-08-08 18:48:12 +0200 | [diff] [blame] | 322 | ); |
| 323 | } |
| 324 | else if ((strcmp(args[2], "event") == 0 && (ev_ptr = &src->report_events)) || |
| 325 | (strcmp(args[2], "pause") == 0 && (ev_ptr = &src->pause_events)) || |
| 326 | (strcmp(args[2], "start") == 0 && (ev_ptr = &src->start_events)) || |
| 327 | (strcmp(args[2], "stop") == 0 && (ev_ptr = &src->stop_events))) { |
| 328 | const struct trace_event *ev; |
| 329 | const char *name = args[3]; |
| 330 | int neg = 0; |
| 331 | int i; |
| 332 | |
| 333 | /* skip prefix '!', '-', '+' and remind negation */ |
| 334 | while (*name) { |
| 335 | if (*name == '!' || *name == '-') |
| 336 | neg = 1; |
| 337 | else if (*name == '+') |
| 338 | neg = 0; |
| 339 | else |
| 340 | break; |
| 341 | name++; |
| 342 | } |
| 343 | |
| 344 | if (!*name) { |
| 345 | chunk_printf(&trash, "Supported events for source %s (+=enabled, -=disabled):\n", src->name.ptr); |
| 346 | if (ev_ptr != &src->report_events) |
Willy Tarreau | 99282dd | 2019-08-30 07:37:32 +0200 | [diff] [blame] | 347 | chunk_appendf(&trash, " - now : don't wait for events, immediately change the state\n"); |
| 348 | chunk_appendf(&trash, " - none : disable all event types\n"); |
| 349 | chunk_appendf(&trash, " - any : enable all event types\n"); |
Willy Tarreau | 864e880 | 2019-08-08 18:48:12 +0200 | [diff] [blame] | 350 | for (i = 0; src->known_events && src->known_events[i].mask; i++) { |
Willy Tarreau | 99282dd | 2019-08-30 07:37:32 +0200 | [diff] [blame] | 351 | chunk_appendf(&trash, " %c %-12s : %s\n", |
Willy Tarreau | 864e880 | 2019-08-08 18:48:12 +0200 | [diff] [blame] | 352 | trace_event_char(*ev_ptr, src->known_events[i].mask), |
| 353 | src->known_events[i].name, src->known_events[i].desc); |
| 354 | } |
| 355 | trash.area[trash.data] = 0; |
| 356 | return cli_msg(appctx, LOG_WARNING, trash.area); |
| 357 | } |
| 358 | |
| 359 | if (strcmp(name, "now") == 0 && ev_ptr != &src->report_events) { |
| 360 | HA_ATOMIC_STORE(ev_ptr, 0); |
Willy Tarreau | beadb5c | 2019-08-20 18:57:48 +0200 | [diff] [blame] | 361 | if (ev_ptr == &src->pause_events) { |
| 362 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
Willy Tarreau | 864e880 | 2019-08-08 18:48:12 +0200 | [diff] [blame] | 363 | HA_ATOMIC_STORE(&src->state, TRACE_STATE_WAITING); |
Willy Tarreau | beadb5c | 2019-08-20 18:57:48 +0200 | [diff] [blame] | 364 | } |
| 365 | else if (ev_ptr == &src->start_events) { |
Willy Tarreau | 864e880 | 2019-08-08 18:48:12 +0200 | [diff] [blame] | 366 | HA_ATOMIC_STORE(&src->state, TRACE_STATE_RUNNING); |
Willy Tarreau | beadb5c | 2019-08-20 18:57:48 +0200 | [diff] [blame] | 367 | } |
| 368 | else if (ev_ptr == &src->stop_events) { |
| 369 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
Willy Tarreau | 864e880 | 2019-08-08 18:48:12 +0200 | [diff] [blame] | 370 | HA_ATOMIC_STORE(&src->state, TRACE_STATE_STOPPED); |
Willy Tarreau | beadb5c | 2019-08-20 18:57:48 +0200 | [diff] [blame] | 371 | } |
Willy Tarreau | 864e880 | 2019-08-08 18:48:12 +0200 | [diff] [blame] | 372 | return 0; |
| 373 | } |
| 374 | |
| 375 | if (strcmp(name, "none") == 0) |
| 376 | HA_ATOMIC_STORE(ev_ptr, 0); |
| 377 | else if (strcmp(name, "any") == 0) |
| 378 | HA_ATOMIC_STORE(ev_ptr, ~0); |
| 379 | else { |
| 380 | ev = trace_find_event(src->known_events, name); |
| 381 | if (!ev) |
| 382 | return cli_err(appctx, "No such trace event"); |
| 383 | |
| 384 | if (!neg) |
| 385 | HA_ATOMIC_OR(ev_ptr, ev->mask); |
| 386 | else |
| 387 | HA_ATOMIC_AND(ev_ptr, ~ev->mask); |
| 388 | } |
| 389 | } |
| 390 | else if (strcmp(args[2], "sink") == 0) { |
| 391 | const char *name = args[3]; |
| 392 | struct sink *sink; |
| 393 | |
| 394 | if (!*name) { |
| 395 | chunk_printf(&trash, "Supported sinks for source %s (*=current):\n", src->name.ptr); |
| 396 | chunk_appendf(&trash, " %c none : no sink\n", src->sink ? ' ' : '*'); |
| 397 | list_for_each_entry(sink, &sink_list, sink_list) { |
| 398 | chunk_appendf(&trash, " %c %-10s : %s\n", |
| 399 | src->sink == sink ? '*' : ' ', |
| 400 | sink->name, sink->desc); |
| 401 | } |
| 402 | trash.area[trash.data] = 0; |
| 403 | return cli_msg(appctx, LOG_WARNING, trash.area); |
| 404 | } |
| 405 | |
| 406 | if (strcmp(name, "none") == 0) |
| 407 | sink = NULL; |
| 408 | else { |
| 409 | sink = sink_find(name); |
| 410 | if (!sink) |
| 411 | return cli_err(appctx, "No such sink"); |
| 412 | } |
| 413 | |
| 414 | HA_ATOMIC_STORE(&src->sink, sink); |
| 415 | } |
Willy Tarreau | aaaf411 | 2019-08-12 17:57:57 +0200 | [diff] [blame] | 416 | else if (strcmp(args[2], "level") == 0) { |
| 417 | const char *name = args[3]; |
| 418 | |
| 419 | if (!*name) { |
Willy Tarreau | 2ea549b | 2019-08-29 08:01:48 +0200 | [diff] [blame] | 420 | chunk_printf(&trash, "Supported trace levels for source %s:\n", src->name.ptr); |
Willy Tarreau | a1f1274 | 2020-12-01 09:46:46 +0100 | [diff] [blame] | 421 | chunk_appendf(&trash, " %c error : report errors\n", |
| 422 | src->level == TRACE_LEVEL_ERROR ? '*' : ' '); |
| 423 | chunk_appendf(&trash, " %c user : also information useful to the end user\n", |
Willy Tarreau | aaaf411 | 2019-08-12 17:57:57 +0200 | [diff] [blame] | 424 | src->level == TRACE_LEVEL_USER ? '*' : ' '); |
Willy Tarreau | 2ea549b | 2019-08-29 08:01:48 +0200 | [diff] [blame] | 425 | chunk_appendf(&trash, " %c proto : also protocol-level updates\n", |
Willy Tarreau | aaaf411 | 2019-08-12 17:57:57 +0200 | [diff] [blame] | 426 | src->level == TRACE_LEVEL_PROTO ? '*' : ' '); |
Willy Tarreau | 2ea549b | 2019-08-29 08:01:48 +0200 | [diff] [blame] | 427 | chunk_appendf(&trash, " %c state : also report internal state changes\n", |
Willy Tarreau | aaaf411 | 2019-08-12 17:57:57 +0200 | [diff] [blame] | 428 | src->level == TRACE_LEVEL_STATE ? '*' : ' '); |
Willy Tarreau | 2ea549b | 2019-08-29 08:01:48 +0200 | [diff] [blame] | 429 | chunk_appendf(&trash, " %c data : also report data transfers\n", |
| 430 | src->level == TRACE_LEVEL_DATA ? '*' : ' '); |
| 431 | chunk_appendf(&trash, " %c developer : also report information useful only to the developer\n", |
Willy Tarreau | aaaf411 | 2019-08-12 17:57:57 +0200 | [diff] [blame] | 432 | src->level == TRACE_LEVEL_DEVELOPER ? '*' : ' '); |
| 433 | trash.area[trash.data] = 0; |
| 434 | return cli_msg(appctx, LOG_WARNING, trash.area); |
| 435 | } |
| 436 | |
Willy Tarreau | a1f1274 | 2020-12-01 09:46:46 +0100 | [diff] [blame] | 437 | if (strcmp(name, "error") == 0) |
| 438 | HA_ATOMIC_STORE(&src->level, TRACE_LEVEL_ERROR); |
| 439 | else if (strcmp(name, "user") == 0) |
Willy Tarreau | aaaf411 | 2019-08-12 17:57:57 +0200 | [diff] [blame] | 440 | HA_ATOMIC_STORE(&src->level, TRACE_LEVEL_USER); |
Willy Tarreau | aaaf411 | 2019-08-12 17:57:57 +0200 | [diff] [blame] | 441 | else if (strcmp(name, "proto") == 0) |
| 442 | HA_ATOMIC_STORE(&src->level, TRACE_LEVEL_PROTO); |
| 443 | else if (strcmp(name, "state") == 0) |
| 444 | HA_ATOMIC_STORE(&src->level, TRACE_LEVEL_STATE); |
Willy Tarreau | 2ea549b | 2019-08-29 08:01:48 +0200 | [diff] [blame] | 445 | else if (strcmp(name, "data") == 0) |
| 446 | HA_ATOMIC_STORE(&src->level, TRACE_LEVEL_DATA); |
Willy Tarreau | aaaf411 | 2019-08-12 17:57:57 +0200 | [diff] [blame] | 447 | else if (strcmp(name, "developer") == 0) |
| 448 | HA_ATOMIC_STORE(&src->level, TRACE_LEVEL_DEVELOPER); |
| 449 | else |
| 450 | return cli_err(appctx, "No such trace level"); |
| 451 | } |
Willy Tarreau | 60e4c9f | 2019-08-20 19:24:10 +0200 | [diff] [blame] | 452 | else if (strcmp(args[2], "lock") == 0) { |
| 453 | const char *name = args[3]; |
| 454 | |
| 455 | if (!*name) { |
| 456 | chunk_printf(&trash, "Supported lock-on criteria for source %s:\n", src->name.ptr); |
| 457 | if (src->arg_def & (TRC_ARGS_CONN|TRC_ARGS_STRM)) |
| 458 | chunk_appendf(&trash, " %c backend : lock on the backend that started the trace\n", |
| 459 | src->lockon == TRACE_LOCKON_BACKEND ? '*' : ' '); |
| 460 | |
Christopher Faulet | 6d80b63 | 2021-04-12 11:53:16 +0200 | [diff] [blame] | 461 | if (src->arg_def & TRC_ARGS_CHK) |
| 462 | chunk_appendf(&trash, " %c check : lock on the check that started the trace\n", |
| 463 | src->lockon == TRACE_LOCKON_CHECK ? '*' : ' '); |
| 464 | |
Willy Tarreau | 60e4c9f | 2019-08-20 19:24:10 +0200 | [diff] [blame] | 465 | if (src->arg_def & TRC_ARGS_CONN) |
| 466 | chunk_appendf(&trash, " %c connection : lock on the connection that started the trace\n", |
| 467 | src->lockon == TRACE_LOCKON_CONNECTION ? '*' : ' '); |
| 468 | |
| 469 | if (src->arg_def & (TRC_ARGS_CONN|TRC_ARGS_SESS|TRC_ARGS_STRM)) |
| 470 | chunk_appendf(&trash, " %c frontend : lock on the frontend that started the trace\n", |
| 471 | src->lockon == TRACE_LOCKON_FRONTEND ? '*' : ' '); |
| 472 | |
| 473 | if (src->arg_def & (TRC_ARGS_CONN|TRC_ARGS_SESS|TRC_ARGS_STRM)) |
| 474 | chunk_appendf(&trash, " %c listener : lock on the listener that started the trace\n", |
| 475 | src->lockon == TRACE_LOCKON_LISTENER ? '*' : ' '); |
| 476 | |
| 477 | chunk_appendf(&trash, " %c nothing : do not lock on anything\n", |
| 478 | src->lockon == TRACE_LOCKON_NOTHING ? '*' : ' '); |
| 479 | |
| 480 | if (src->arg_def & (TRC_ARGS_CONN|TRC_ARGS_STRM)) |
| 481 | chunk_appendf(&trash, " %c server : lock on the server that started the trace\n", |
| 482 | src->lockon == TRACE_LOCKON_SERVER ? '*' : ' '); |
| 483 | |
| 484 | if (src->arg_def & (TRC_ARGS_CONN|TRC_ARGS_SESS|TRC_ARGS_STRM)) |
| 485 | chunk_appendf(&trash, " %c session : lock on the session that started the trace\n", |
| 486 | src->lockon == TRACE_LOCKON_SESSION ? '*' : ' '); |
| 487 | |
| 488 | if (src->arg_def & TRC_ARGS_STRM) |
| 489 | chunk_appendf(&trash, " %c stream : lock on the stream that started the trace\n", |
| 490 | src->lockon == TRACE_LOCKON_STREAM ? '*' : ' '); |
| 491 | |
| 492 | chunk_appendf(&trash, " %c thread : lock on the thread that started the trace\n", |
| 493 | src->lockon == TRACE_LOCKON_THREAD ? '*' : ' '); |
| 494 | |
| 495 | if (src->lockon_args && src->lockon_args[0].name) |
| 496 | chunk_appendf(&trash, " %c %-10s : %s\n", |
| 497 | src->lockon == TRACE_LOCKON_ARG1 ? '*' : ' ', |
| 498 | src->lockon_args[0].name, src->lockon_args[0].desc); |
| 499 | |
| 500 | if (src->lockon_args && src->lockon_args[1].name) |
| 501 | chunk_appendf(&trash, " %c %-10s : %s\n", |
| 502 | src->lockon == TRACE_LOCKON_ARG2 ? '*' : ' ', |
| 503 | src->lockon_args[1].name, src->lockon_args[1].desc); |
| 504 | |
| 505 | if (src->lockon_args && src->lockon_args[2].name) |
| 506 | chunk_appendf(&trash, " %c %-10s : %s\n", |
| 507 | src->lockon == TRACE_LOCKON_ARG3 ? '*' : ' ', |
| 508 | src->lockon_args[2].name, src->lockon_args[2].desc); |
| 509 | |
| 510 | if (src->lockon_args && src->lockon_args[3].name) |
| 511 | chunk_appendf(&trash, " %c %-10s : %s\n", |
| 512 | src->lockon == TRACE_LOCKON_ARG4 ? '*' : ' ', |
| 513 | src->lockon_args[3].name, src->lockon_args[3].desc); |
| 514 | |
| 515 | trash.area[trash.data] = 0; |
| 516 | return cli_msg(appctx, LOG_WARNING, trash.area); |
| 517 | } |
| 518 | else if ((src->arg_def & (TRC_ARGS_CONN|TRC_ARGS_STRM)) && strcmp(name, "backend") == 0) { |
| 519 | HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_BACKEND); |
| 520 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
| 521 | } |
Christopher Faulet | 6d80b63 | 2021-04-12 11:53:16 +0200 | [diff] [blame] | 522 | else if ((src->arg_def & TRC_ARGS_CHK) && strcmp(name, "check") == 0) { |
| 523 | HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_CHECK); |
| 524 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
| 525 | } |
Willy Tarreau | 60e4c9f | 2019-08-20 19:24:10 +0200 | [diff] [blame] | 526 | else if ((src->arg_def & TRC_ARGS_CONN) && strcmp(name, "connection") == 0) { |
| 527 | HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_CONNECTION); |
| 528 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
| 529 | } |
| 530 | else if ((src->arg_def & (TRC_ARGS_CONN|TRC_ARGS_SESS|TRC_ARGS_STRM)) && strcmp(name, "frontend") == 0) { |
| 531 | HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_FRONTEND); |
| 532 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
| 533 | } |
| 534 | else if ((src->arg_def & (TRC_ARGS_CONN|TRC_ARGS_SESS|TRC_ARGS_STRM)) && strcmp(name, "listener") == 0) { |
| 535 | HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_LISTENER); |
| 536 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
| 537 | } |
| 538 | else if (strcmp(name, "nothing") == 0) { |
| 539 | HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_NOTHING); |
| 540 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
| 541 | } |
| 542 | else if ((src->arg_def & (TRC_ARGS_CONN|TRC_ARGS_STRM)) && strcmp(name, "server") == 0) { |
| 543 | HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_SERVER); |
| 544 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
| 545 | } |
| 546 | else if ((src->arg_def & (TRC_ARGS_CONN|TRC_ARGS_SESS|TRC_ARGS_STRM)) && strcmp(name, "session") == 0) { |
| 547 | HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_SESSION); |
| 548 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
| 549 | } |
| 550 | else if ((src->arg_def & TRC_ARGS_STRM) && strcmp(name, "stream") == 0) { |
| 551 | HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_STREAM); |
| 552 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
| 553 | } |
| 554 | else if (strcmp(name, "thread") == 0) { |
| 555 | HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_THREAD); |
| 556 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
| 557 | } |
| 558 | else if (src->lockon_args && src->lockon_args[0].name && strcmp(name, src->lockon_args[0].name) == 0) { |
| 559 | HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_ARG1); |
| 560 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
| 561 | } |
| 562 | else if (src->lockon_args && src->lockon_args[1].name && strcmp(name, src->lockon_args[1].name) == 0) { |
| 563 | HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_ARG2); |
| 564 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
| 565 | } |
| 566 | else if (src->lockon_args && src->lockon_args[2].name && strcmp(name, src->lockon_args[2].name) == 0) { |
| 567 | HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_ARG3); |
| 568 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
| 569 | } |
| 570 | else if (src->lockon_args && src->lockon_args[3].name && strcmp(name, src->lockon_args[3].name) == 0) { |
| 571 | HA_ATOMIC_STORE(&src->lockon, TRACE_LOCKON_ARG4); |
| 572 | HA_ATOMIC_STORE(&src->lockon_ptr, NULL); |
| 573 | } |
| 574 | else |
| 575 | return cli_err(appctx, "Unsupported lock-on criterion"); |
| 576 | } |
Willy Tarreau | 370a694 | 2019-08-29 08:24:16 +0200 | [diff] [blame] | 577 | else if (strcmp(args[2], "verbosity") == 0) { |
| 578 | const char *name = args[3]; |
| 579 | const struct name_desc *nd; |
| 580 | |
| 581 | if (!*name) { |
| 582 | chunk_printf(&trash, "Supported trace verbosities for source %s:\n", src->name.ptr); |
| 583 | chunk_appendf(&trash, " %c quiet : only report basic information with no decoding\n", |
| 584 | src->verbosity == 0 ? '*' : ' '); |
| 585 | if (!src->decoding || !src->decoding[0].name) { |
| 586 | chunk_appendf(&trash, " %c default : report extra information when available\n", |
| 587 | src->verbosity > 0 ? '*' : ' '); |
| 588 | } else { |
| 589 | for (nd = src->decoding; nd->name && nd->desc; nd++) |
| 590 | chunk_appendf(&trash, " %c %-10s : %s\n", |
| 591 | nd == (src->decoding + src->verbosity - 1) ? '*' : ' ', |
| 592 | nd->name, nd->desc); |
| 593 | } |
| 594 | trash.area[trash.data] = 0; |
| 595 | return cli_msg(appctx, LOG_WARNING, trash.area); |
| 596 | } |
| 597 | |
| 598 | if (strcmp(name, "quiet") == 0) |
| 599 | HA_ATOMIC_STORE(&src->verbosity, 0); |
| 600 | else if (!src->decoding || !src->decoding[0].name) { |
| 601 | if (strcmp(name, "default") == 0) |
| 602 | HA_ATOMIC_STORE(&src->verbosity, 1); |
| 603 | else |
| 604 | return cli_err(appctx, "No such verbosity level"); |
| 605 | } else { |
| 606 | for (nd = src->decoding; nd->name && nd->desc; nd++) |
| 607 | if (strcmp(name, nd->name) == 0) |
| 608 | break; |
| 609 | |
| 610 | if (!nd->name || !nd->desc) |
| 611 | return cli_err(appctx, "No such verbosity level"); |
| 612 | |
| 613 | HA_ATOMIC_STORE(&src->verbosity, (nd - src->decoding) + 1); |
| 614 | } |
| 615 | } |
Willy Tarreau | 864e880 | 2019-08-08 18:48:12 +0200 | [diff] [blame] | 616 | else |
| 617 | return cli_err(appctx, "Unknown trace keyword"); |
| 618 | |
| 619 | return 0; |
| 620 | } |
| 621 | |
Willy Tarreau | 85b1575 | 2019-08-12 16:44:33 +0200 | [diff] [blame] | 622 | /* parse the command, returns 1 if a message is returned, otherwise zero */ |
| 623 | static int cli_parse_show_trace(char **args, char *payload, struct appctx *appctx, void *private) |
| 624 | { |
| 625 | struct trace_source *src; |
| 626 | const struct sink *sink; |
| 627 | int i; |
| 628 | |
| 629 | args++; // make args[1] the 1st arg |
| 630 | |
| 631 | if (!*args[1]) { |
| 632 | /* no arg => report the list of supported sources */ |
| 633 | chunk_printf(&trash, |
| 634 | "Supported trace sources and states (.=stopped, w=waiting, R=running) :\n" |
| 635 | ); |
| 636 | |
| 637 | list_for_each_entry(src, &trace_sources, source_link) { |
| 638 | sink = src->sink; |
| 639 | chunk_appendf(&trash, " [%c] %-10s -> %s [drp %u] [%s]\n", |
| 640 | trace_state_char(src->state), src->name.ptr, |
| 641 | sink ? sink->name : "none", |
| 642 | sink ? sink->ctx.dropped : 0, |
| 643 | src->desc); |
| 644 | } |
| 645 | |
| 646 | trash.area[trash.data] = 0; |
| 647 | return cli_msg(appctx, LOG_INFO, trash.area); |
| 648 | } |
| 649 | |
| 650 | if (!cli_has_level(appctx, ACCESS_LVL_OPER)) |
| 651 | return 1; |
| 652 | |
| 653 | src = trace_find_source(args[1]); |
| 654 | if (!src) |
| 655 | return cli_err(appctx, "No such trace source"); |
| 656 | |
| 657 | sink = src->sink; |
| 658 | chunk_printf(&trash, "Trace status for %s:\n", src->name.ptr); |
| 659 | chunk_appendf(&trash, " - sink: %s [%u dropped]\n", |
| 660 | sink ? sink->name : "none", sink ? sink->ctx.dropped : 0); |
| 661 | |
Willy Tarreau | 99282dd | 2019-08-30 07:37:32 +0200 | [diff] [blame] | 662 | chunk_appendf(&trash, " - event name : report start stop pause\n"); |
Willy Tarreau | 85b1575 | 2019-08-12 16:44:33 +0200 | [diff] [blame] | 663 | for (i = 0; src->known_events && src->known_events[i].mask; i++) { |
Willy Tarreau | 99282dd | 2019-08-30 07:37:32 +0200 | [diff] [blame] | 664 | chunk_appendf(&trash, " %-12s : %c %c %c %c\n", |
Willy Tarreau | 85b1575 | 2019-08-12 16:44:33 +0200 | [diff] [blame] | 665 | src->known_events[i].name, |
| 666 | trace_event_char(src->report_events, src->known_events[i].mask), |
| 667 | trace_event_char(src->start_events, src->known_events[i].mask), |
| 668 | trace_event_char(src->stop_events, src->known_events[i].mask), |
| 669 | trace_event_char(src->pause_events, src->known_events[i].mask)); |
| 670 | } |
| 671 | |
| 672 | trash.area[trash.data] = 0; |
| 673 | return cli_msg(appctx, LOG_WARNING, trash.area); |
| 674 | } |
| 675 | |
Willy Tarreau | 864e880 | 2019-08-08 18:48:12 +0200 | [diff] [blame] | 676 | static struct cli_kw_list cli_kws = {{ },{ |
Willy Tarreau | b205bfd | 2021-05-07 11:38:37 +0200 | [diff] [blame] | 677 | { { "trace", NULL }, "trace [<module>|0] [cmd [args...]] : manage live tracing (empty to list, 0 to stop all)", cli_parse_trace, NULL, NULL }, |
| 678 | { { "show", "trace", NULL }, "show trace [<module>] : show live tracing state", cli_parse_show_trace, NULL, NULL }, |
Willy Tarreau | 864e880 | 2019-08-08 18:48:12 +0200 | [diff] [blame] | 679 | {{},} |
| 680 | }}; |
| 681 | |
| 682 | INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); |
| 683 | |
Willy Tarreau | 4151c75 | 2019-08-08 18:21:26 +0200 | [diff] [blame] | 684 | /* |
| 685 | * Local variables: |
| 686 | * c-indent-level: 8 |
| 687 | * c-basic-offset: 8 |
| 688 | * End: |
| 689 | */ |