mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 15:47:01 +02:00
MINOR: trace: Be able to chain commands for a source in one line
In the configuration file or on the CLI, configuring traces for a specific source is a bit painful because this must be done in several lines. Thanks to this patch, it is now possible to fully configure traces for a source in one line. For instance, the following on the CLI: trace h1 sink stderr; trace h1 level developer; trace h1 verbosity complete; trace h1 start now can now be replaced by: trace h1 sink stderr level developer verbosity complete start now The same is true for the 'trace' directives in the configuration file.
This commit is contained in:
parent
15a520d474
commit
c39c351a73
@ -4350,11 +4350,9 @@ traces
|
|||||||
used. All direcitives are evaluated in the declararion order, the last ones
|
used. All direcitives are evaluated in the declararion order, the last ones
|
||||||
overriding previous ones.
|
overriding previous ones.
|
||||||
|
|
||||||
trace <args...>
|
trace <source> <args...>
|
||||||
Configures on "trace" subsystem. Each of them can be found in the management
|
Configures on "trace" subsystem. Each of them can be found in the management
|
||||||
manual, and follow the exact same syntax. Only one statement per line is
|
manual, and follow the exact same syntax. Any output that the "trace"
|
||||||
permitted (i.e. if some long trace configurations using semi-colons are to be
|
|
||||||
imported, they must be placed one per line). Any output that the "trace"
|
|
||||||
command would produce will be emitted during the parsing step of the
|
command would produce will be emitted during the parsing step of the
|
||||||
section. Most of the time these will be errors and warnings, but certain
|
section. Most of the time these will be errors and warnings, but certain
|
||||||
incomplete commands might list permissible choices. This command is not meant
|
incomplete commands might list permissible choices. This command is not meant
|
||||||
@ -4377,15 +4375,8 @@ trace <args...>
|
|||||||
backing-file /tmp/h2.traces
|
backing-file /tmp/h2.traces
|
||||||
|
|
||||||
traces
|
traces
|
||||||
trace h1 sink buf1
|
trace h1 sink buf1 level developer verbosity complete start now
|
||||||
trace h1 level developer
|
trace h2 sink buf1 level developer verbosity complete start now
|
||||||
trace h1 verbosity complete
|
|
||||||
trace h1 start now
|
|
||||||
|
|
||||||
trace h2 sink buf1
|
|
||||||
trace h2 level developer
|
|
||||||
trace h2 verbosity complete
|
|
||||||
trace h2 start now
|
|
||||||
|
|
||||||
3.4. Userlists
|
3.4. Userlists
|
||||||
--------------
|
--------------
|
||||||
|
@ -3931,183 +3931,186 @@ trace 0
|
|||||||
to terminate a debugging session or as an emergency action to be used in case
|
to terminate a debugging session or as an emergency action to be used in case
|
||||||
complex traces were enabled on multiple sources and impact the service.
|
complex traces were enabled on multiple sources and impact the service.
|
||||||
|
|
||||||
trace <source> event [ [+|-|!]<name> ]
|
trace <source> [<args...>]
|
||||||
Without argument, this will list all the events supported by the designated
|
Configure traces for the source <source>. Without argument, this will list all
|
||||||
source. They are prefixed with a "-" if they are not enabled, or a "+" if
|
supported sub-commands to the given source. Multiple sub-commands can be
|
||||||
they are enabled. It is important to note that a single trace may be labelled
|
chained. Following sub-commands are supported:
|
||||||
with multiple events, and as long as any of the enabled events matches one of
|
|
||||||
the events labelled on the trace, the event will be passed to the trace
|
|
||||||
subsystem. For example, receiving an HTTP/2 frame of type HEADERS may trigger
|
|
||||||
a frame event and a stream event since the frame creates a new stream. If
|
|
||||||
either the frame event or the stream event are enabled for this source, the
|
|
||||||
frame will be passed to the trace framework.
|
|
||||||
|
|
||||||
With an argument, it is possible to toggle the state of each event and
|
event [ [+|-|!]<name> ]
|
||||||
individually enable or disable them. Two special keywords are supported,
|
Without argument, this will list all the events supported by the designated
|
||||||
"none", which matches no event, and is used to disable all events at once,
|
source. They are prefixed with a "-" if they are not enabled, or a "+" if
|
||||||
and "any" which matches all events, and is used to enable all events at
|
they are enabled. It is important to note that a single trace may be
|
||||||
once. Other events are specific to the event source. It is possible to
|
labelled with multiple events, and as long as any of the enabled events
|
||||||
enable one event by specifying its name, optionally prefixed with '+' for
|
matches one of the events labelled on the trace, the event will be passed to
|
||||||
better readability. It is possible to disable one event by specifying its
|
the trace subsystem. For example, receiving an HTTP/2 frame of type HEADERS
|
||||||
name prefixed by a '-' or a '!'.
|
may trigger a frame event and a stream event since the frame creates a new
|
||||||
|
stream. If either the frame event or the stream event are enabled for this
|
||||||
|
source, the frame will be passed to the trace framework.
|
||||||
|
|
||||||
One way to completely disable a trace source is to pass "event none", and
|
With an argument, it is possible to toggle the state of each event and
|
||||||
this source will instantly be totally ignored.
|
individually enable or disable them. Two special keywords are supported,
|
||||||
|
"none", which matches no event, and is used to disable all events at once,
|
||||||
|
and "any" which matches all events, and is used to enable all events at
|
||||||
|
once. Other events are specific to the event source. It is possible to
|
||||||
|
enable one event by specifying its name, optionally prefixed with '+' for
|
||||||
|
better readability. It is possible to disable one event by specifying its
|
||||||
|
name prefixed by a '-' or a '!'.
|
||||||
|
|
||||||
trace <source> follow <other_source>
|
One way to completely disable a trace source is to pass "event none", and
|
||||||
This permits the source <source> to also emit traces when the other source
|
this source will instantly be totally ignored.
|
||||||
<other_source> is locked on a criteria and the same criteria matches for the
|
|
||||||
current source as well. For example, if a source is locked on a session,
|
|
||||||
following that source from another one will make that other one emit traces
|
|
||||||
for all events related to this session. This may be used to some extents to
|
|
||||||
track backend requests along with the associated frontend connections. The
|
|
||||||
"session" source makes this easier by providing a "new" and an "end" events
|
|
||||||
that are usable for lock-on processing. Note that the source <source> does
|
|
||||||
not need to have its traces enabled in this case, and its tracing state will
|
|
||||||
not be affected either. It is, however, possible that some events may be
|
|
||||||
missing if they do not contain information that allow to correlate them with
|
|
||||||
the tracked element. The meta-source "all" may also be used with this
|
|
||||||
command: in this case, all sources will follow <other_source>.
|
|
||||||
|
|
||||||
Example:
|
follow <other_source>
|
||||||
trace session lock session
|
This permits the source <source> to also emit traces when the other source
|
||||||
trace session start sess_new
|
<other_source> is locked on a criteria and the same criteria matches for the
|
||||||
trace session pause sess_end
|
current source as well. For example, if a source is locked on a session,
|
||||||
trace h1 follow session
|
following that source from another one will make that other one emit traces
|
||||||
|
for all events related to this session. This may be used to some extents to
|
||||||
|
track backend requests along with the associated frontend connections. The
|
||||||
|
"session" source makes this easier by providing a "new" and an "end" events
|
||||||
|
that are usable for lock-on processing. Note that the source <source> does
|
||||||
|
not need to have its traces enabled in this case, and its tracing state will
|
||||||
|
not be affected either. It is, however, possible that some events may be
|
||||||
|
missing if they do not contain information that allow to correlate them with
|
||||||
|
the tracked element. The meta-source "all" may also be used with this
|
||||||
|
command: in this case, all sources will follow <other_source>.
|
||||||
|
|
||||||
trace <source> level [<level>]
|
Example:
|
||||||
Without argument, this will list all trace levels for this source, and the
|
trace h1 lock session start sess_new pause sess_end follow session
|
||||||
current one will be indicated by a star ('*') prepended in front of it. With
|
|
||||||
an argument, this will change the trace level to the specified level. Detail
|
|
||||||
levels are a form of filters that are applied before reporting the events.
|
|
||||||
These filters are used to selectively include or exclude events depending on
|
|
||||||
their level of importance. For example a developer might need to know
|
|
||||||
precisely where in the code an HTTP header was considered invalid while the
|
|
||||||
end user may not even care about this header's validity at all. There are
|
|
||||||
currently 5 distinct levels for a trace :
|
|
||||||
|
|
||||||
user this will report information that are suitable for use by a
|
level [<level>]
|
||||||
|
Without argument, this will list all trace levels for this source, and the
|
||||||
|
current one will be indicated by a star ('*') prepended in front of it. With
|
||||||
|
an argument, this will change the trace level to the specified level. Detail
|
||||||
|
levels are a form of filters that are applied before reporting the events.
|
||||||
|
These filters are used to selectively include or exclude events depending on
|
||||||
|
their level of importance. For example a developer might need to know
|
||||||
|
precisely where in the code an HTTP header was considered invalid while the
|
||||||
|
end user may not even care about this header's validity at all. There are
|
||||||
|
currently 5 distinct levels for a trace :
|
||||||
|
|
||||||
|
user this will report information that are suitable for use by a
|
||||||
regular haproxy user who wants to observe his traffic.
|
regular haproxy user who wants to observe his traffic.
|
||||||
Typically some HTTP requests and responses will be reported
|
Typically some HTTP requests and responses will be reported
|
||||||
without much detail. Most sources will set this as the
|
without much detail. Most sources will set this as the
|
||||||
default level to ease operations.
|
default level to ease operations.
|
||||||
|
|
||||||
proto in addition to what is reported at the "user" level, it also
|
proto in addition to what is reported at the "user" level, it also
|
||||||
displays protocol-level updates. This can for example be the
|
displays protocol-level updates. This can for example be the
|
||||||
frame types or HTTP headers after decoding.
|
frame types or HTTP headers after decoding.
|
||||||
|
|
||||||
state in addition to what is reported at the "proto" level, it
|
state in addition to what is reported at the "proto" level, it
|
||||||
will also display state transitions (or failed transitions)
|
will also display state transitions (or failed transitions)
|
||||||
which happen in parsers, so this will show attempts to
|
which happen in parsers, so this will show attempts to
|
||||||
perform an operation while the "proto" level only shows
|
perform an operation while the "proto" level only shows
|
||||||
the final operation.
|
the final operation.
|
||||||
|
|
||||||
data in addition to what is reported at the "state" level, it
|
data in addition to what is reported at the "state" level, it
|
||||||
will also include data transfers between the various layers.
|
will also include data transfers between the various layers.
|
||||||
|
|
||||||
developer it reports everything available, which can include advanced
|
developer it reports everything available, which can include advanced
|
||||||
information such as "breaking out of this loop" that are
|
information such as "breaking out of this loop" that are
|
||||||
only relevant to a developer trying to understand a bug that
|
only relevant to a developer trying to understand a bug that
|
||||||
only happens once in a while in field. Function names are
|
only happens once in a while in field. Function names are
|
||||||
only reported at this level.
|
only reported at this level.
|
||||||
|
|
||||||
It is highly recommended to always use the "user" level only and switch to
|
It is highly recommended to always use the "user" level only and switch to
|
||||||
other levels only if instructed to do so by a developer. Also it is a good
|
other levels only if instructed to do so by a developer. Also it is a good
|
||||||
idea to first configure the events before switching to higher levels, as it
|
idea to first configure the events before switching to higher levels, as it
|
||||||
may save from dumping many lines if no filter is applied. The meta-source
|
may save from dumping many lines if no filter is applied. The meta-source
|
||||||
"all" may also be used with this command: in this case, the level will be
|
"all" may also be used with this command: in this case, the level will be
|
||||||
applied to all existing sources at once.
|
applied to all existing sources at once.
|
||||||
|
|
||||||
trace <source> lock [criterion]
|
lock [criterion]
|
||||||
Without argument, this will list all the criteria supported by this source
|
Without argument, this will list all the criteria supported by this source
|
||||||
for lock-on processing, and display the current choice by a star ('*') in
|
for lock-on processing, and display the current choice by a star ('*') in
|
||||||
front of it. Lock-on means that the source will focus on the first matching
|
front of it. Lock-on means that the source will focus on the first matching
|
||||||
event and only stick to the criterion which triggered this event, and ignore
|
event and only stick to the criterion which triggered this event, and ignore
|
||||||
all other ones until the trace stops. This allows for example to take a trace
|
all other ones until the trace stops. This allows for example to take a
|
||||||
on a single connection or on a single stream. The following criteria are
|
trace on a single connection or on a single stream. The following criteria
|
||||||
supported by some traces, though not necessarily all, since some of them
|
are supported by some traces, though not necessarily all, since some of them
|
||||||
might not be available to the source :
|
might not be available to the source :
|
||||||
|
|
||||||
backend lock on the backend that started the trace
|
backend lock on the backend that started the trace
|
||||||
connection lock on the connection that started the trace
|
connection lock on the connection that started the trace
|
||||||
frontend lock on the frontend that started the trace
|
frontend lock on the frontend that started the trace
|
||||||
listener lock on the listener that started the trace
|
listener lock on the listener that started the trace
|
||||||
nothing do not lock on anything
|
nothing do not lock on anything
|
||||||
server lock on the server that started the trace
|
server lock on the server that started the trace
|
||||||
session lock on the session that started the trace
|
session lock on the session that started the trace
|
||||||
thread lock on the thread that started the trace
|
thread lock on the thread that started the trace
|
||||||
|
|
||||||
In addition to this, each source may provide up to 4 specific criteria such
|
In addition to this, each source may provide up to 4 specific criteria such
|
||||||
as internal states or connection IDs. For example in HTTP/2 it is possible
|
as internal states or connection IDs. For example in HTTP/2 it is possible
|
||||||
to lock on the H2 stream and ignore other streams once a strace starts.
|
to lock on the H2 stream and ignore other streams once a strace starts.
|
||||||
|
|
||||||
When a criterion is passed in argument, this one is used instead of the
|
When a criterion is passed in argument, this one is used instead of the
|
||||||
other ones and any existing tracking is immediately terminated so that it can
|
other ones and any existing tracking is immediately terminated so that it
|
||||||
restart with the new criterion. The special keyword "nothing" is supported by
|
can restart with the new criterion. The special keyword "nothing" is
|
||||||
all sources to permanently disable tracking.
|
supported by all sources to permanently disable tracking.
|
||||||
|
|
||||||
trace <source> { pause | start | stop } [ [+|-|!]event]
|
{ pause | start | stop } [ [+|-|!]event]
|
||||||
Without argument, this will list the events enabled to automatically pause,
|
Without argument, this will list the events enabled to automatically pause,
|
||||||
start, or stop a trace for this source. These events are specific to each
|
start, or stop a trace for this source. These events are specific to each
|
||||||
trace source. With an argument, this will either enable the event for the
|
trace source. With an argument, this will either enable the event for the
|
||||||
specified action (if optionally prefixed by a '+') or disable it (if
|
specified action (if optionally prefixed by a '+') or disable it (if
|
||||||
prefixed by a '-' or '!'). The special keyword "now" is not an event and
|
prefixed by a '-' or '!'). The special keyword "now" is not an event and
|
||||||
requests to take the action immediately. The keywords "none" and "any" are
|
requests to take the action immediately. The keywords "none" and "any" are
|
||||||
supported just like in "trace event".
|
supported just like in "trace event".
|
||||||
|
|
||||||
The 3 supported actions are respectively "pause", "start" and "stop". The
|
The 3 supported actions are respectively "pause", "start" and "stop". The
|
||||||
"pause" action enumerates events which will cause a running trace to stop and
|
"pause" action enumerates events which will cause a running trace to stop
|
||||||
wait for a new start event to restart it. The "start" action enumerates the
|
and wait for a new start event to restart it. The "start" action enumerates
|
||||||
events which switch the trace into the waiting mode until one of the start
|
the events which switch the trace into the waiting mode until one of the
|
||||||
events appears. And the "stop" action enumerates the events which definitely
|
start events appears. And the "stop" action enumerates the events which
|
||||||
stop the trace until it is manually enabled again. In practice it makes sense
|
definitely stop the trace until it is manually enabled again. In practice it
|
||||||
to manually start a trace using "start now" without caring about events, and
|
makes sense to manually start a trace using "start now" without caring about
|
||||||
to stop it using "stop now". In order to capture more subtle event sequences,
|
events, and to stop it using "stop now". In order to capture more subtle
|
||||||
setting "start" to a normal event (like receiving an HTTP request) and "stop"
|
event sequences, setting "start" to a normal event (like receiving an HTTP
|
||||||
to a very rare event like emitting a certain error, will ensure that the last
|
request) and "stop" to a very rare event like emitting a certain error, will
|
||||||
captured events will match the desired criteria. And the pause event is
|
ensure that the last captured events will match the desired criteria. And
|
||||||
useful to detect the end of a sequence, disable the lock-on and wait for
|
the pause event is useful to detect the end of a sequence, disable the
|
||||||
another opportunity to take a capture. In this case it can make sense to
|
lock-on and wait for another opportunity to take a capture. In this case it
|
||||||
enable lock-on to spot only one specific criterion (e.g. a stream), and have
|
can make sense to enable lock-on to spot only one specific criterion (e.g. a
|
||||||
"start" set to anything that starts this criterion (e.g. all events which
|
stream), and have "start" set to anything that starts this criterion
|
||||||
create a stream), "stop" set to the expected anomaly, and "pause" to anything
|
(e.g. all events which create a stream), "stop" set to the expected anomaly,
|
||||||
that ends that criterion (e.g. any end of stream event). In this case the
|
and "pause" to anything that ends that criterion (e.g. any end of stream
|
||||||
trace log will contain complete sequences of perfectly clean series affecting
|
event). In this case the trace log will contain complete sequences of
|
||||||
a single object, until the last sequence containing everything from the
|
perfectly clean series affecting a single object, until the last sequence
|
||||||
beginning to the anomaly.
|
containing everything from the beginning to the anomaly.
|
||||||
|
|
||||||
trace <source> sink [<sink>]
|
sink [<sink>]
|
||||||
Without argument, this will list all event sinks available for this source,
|
Without argument, this will list all event sinks available for this source,
|
||||||
and the currently configured one will have a star ('*') prepended in front
|
and the currently configured one will have a star ('*') prepended in front
|
||||||
of it. Sink "none" is always available and means that all events are simply
|
of it. Sink "none" is always available and means that all events are simply
|
||||||
dropped, though their processing is not ignored (e.g. lock-on does occur).
|
dropped, though their processing is not ignored (e.g. lock-on does occur).
|
||||||
Other sinks are available depending on configuration and build options, but
|
Other sinks are available depending on configuration and build options, but
|
||||||
typically "stdout" and "stderr" will be usable in debug mode, and in-memory
|
typically "stdout" and "stderr" will be usable in debug mode, and in-memory
|
||||||
ring buffers should be available as well. When a name is specified, the sink
|
ring buffers should be available as well. When a name is specified, the
|
||||||
instantly changes for the specified source. Events are not changed during a
|
sink instantly changes for the specified source. Events are not changed
|
||||||
sink change. In the worst case some may be lost if an invalid sink is used
|
during a sink change. In the worst case some may be lost if an invalid sink
|
||||||
(or "none"), but operations do continue to a different destination. The
|
is used (or "none"), but operations do continue to a different
|
||||||
meta-source "all" may also be used with this command: in this case, the
|
destination. The meta-source "all" may also be used with this command: in
|
||||||
sink will be applied to all existing sources at once.
|
this case, the sink will be applied to all existing sources at once.
|
||||||
|
|
||||||
trace <source> verbosity [<level>]
|
verbosity [<level>]
|
||||||
Without argument, this will list all verbosity levels for this source, and the
|
Without argument, this will list all verbosity levels for this source, and
|
||||||
current one will be indicated by a star ('*') prepended in front of it. With
|
the current one will be indicated by a star ('*') prepended in front of
|
||||||
an argument, this will change the verbosity level to the specified one.
|
it. With an argument, this will change the verbosity level to the specified
|
||||||
|
one.
|
||||||
|
|
||||||
Verbosity levels indicate how far the trace decoder should go to provide
|
Verbosity levels indicate how far the trace decoder should go to provide
|
||||||
detailed information. It depends on the trace source, since some sources will
|
detailed information. It depends on the trace source, since some sources
|
||||||
not even provide a specific decoder. Level "quiet" is always available and
|
will not even provide a specific decoder. Level "quiet" is always available
|
||||||
disables any decoding. It can be useful when trying to figure what's
|
and disables any decoding. It can be useful when trying to figure what's
|
||||||
happening before trying to understand the details, since it will have a very
|
happening before trying to understand the details, since it will have a very
|
||||||
low impact on performance and trace size. When no verbosity levels are
|
low impact on performance and trace size. When no verbosity levels are
|
||||||
declared by a source, level "default" is available and will cause a decoder
|
declared by a source, level "default" is available and will cause a decoder
|
||||||
to be called when specified in the traces. It is an opportunistic decoding.
|
to be called when specified in the traces. It is an opportunistic decoding.
|
||||||
When the source declares some verbosity levels, these ones are listed with
|
When the source declares some verbosity levels, these ones are listed with a
|
||||||
a description of what they correspond to. In this case the trace decoder
|
description of what they correspond to. In this case the trace decoder
|
||||||
provided by the source will be as accurate as possible based on the
|
provided by the source will be as accurate as possible based on the
|
||||||
information available at the trace point. The first level above "quiet" is
|
information available at the trace point. The first level above "quiet" is
|
||||||
set by default.
|
set by default.
|
||||||
|
|
||||||
update ssl ocsp-response <certfile>
|
update ssl ocsp-response <certfile>
|
||||||
Create an OCSP request for the specified <certfile> and send it to the OCSP
|
Create an OCSP request for the specified <certfile> and send it to the OCSP
|
||||||
|
94
src/trace.c
94
src/trace.c
@ -449,8 +449,9 @@ static int trace_source_parse_verbosity(struct trace_source *src,
|
|||||||
*/
|
*/
|
||||||
static int trace_parse_statement(char **args, char **msg)
|
static int trace_parse_statement(char **args, char **msg)
|
||||||
{
|
{
|
||||||
struct trace_source *src;
|
struct trace_source *orig_src, *src;
|
||||||
uint64_t *ev_ptr = NULL;
|
uint64_t *ev_ptr = NULL;
|
||||||
|
int cur_arg;
|
||||||
|
|
||||||
/* no error by default */
|
/* no error by default */
|
||||||
*msg = NULL;
|
*msg = NULL;
|
||||||
@ -480,24 +481,18 @@ static int trace_parse_statement(char **args, char **msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(args[1], "all") == 0) {
|
if (strcmp(args[1], "all") == 0) {
|
||||||
if (*args[2] &&
|
orig_src = NULL;
|
||||||
strcmp(args[2], "follow") != 0 &&
|
|
||||||
strcmp(args[2], "sink") != 0 &&
|
|
||||||
strcmp(args[2], "level") != 0) {
|
|
||||||
memprintf(msg, "'%s' not applicable to meta-source 'all'", args[2]);
|
|
||||||
return LOG_ERR;
|
|
||||||
}
|
|
||||||
src = NULL;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
src = trace_find_source(args[1]);
|
orig_src = trace_find_source(args[1]);
|
||||||
if (!src) {
|
if (!orig_src) {
|
||||||
memprintf(msg, "No such trace source '%s'", args[1]);
|
memprintf(msg, "No such trace source '%s'", args[1]);
|
||||||
return LOG_ERR;
|
return LOG_ERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!*args[2]) {
|
cur_arg = 2;
|
||||||
|
if (!*args[cur_arg]) {
|
||||||
*msg = "Supported commands:\n"
|
*msg = "Supported commands:\n"
|
||||||
" event : list/enable/disable source-specific event reporting\n"
|
" event : list/enable/disable source-specific event reporting\n"
|
||||||
//" filter : list/enable/disable generic filters\n"
|
//" filter : list/enable/disable generic filters\n"
|
||||||
@ -512,10 +507,24 @@ static int trace_parse_statement(char **args, char **msg)
|
|||||||
*msg = strdup(*msg);
|
*msg = strdup(*msg);
|
||||||
return LOG_WARNING;
|
return LOG_WARNING;
|
||||||
}
|
}
|
||||||
else if (strcmp(args[2], "follow") == 0) {
|
|
||||||
|
next_stmt:
|
||||||
|
if (!*args[cur_arg])
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
src = orig_src;
|
||||||
|
if (src == NULL &&
|
||||||
|
strcmp(args[cur_arg], "follow") != 0 &&
|
||||||
|
strcmp(args[cur_arg], "sink") != 0 &&
|
||||||
|
strcmp(args[cur_arg], "level") != 0) {
|
||||||
|
memprintf(msg, "'%s' not applicable to meta-source 'all'", args[cur_arg]);
|
||||||
|
return LOG_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(args[cur_arg], "follow") == 0) {
|
||||||
const struct trace_source *origin = src ? HA_ATOMIC_LOAD(&src->follow) : NULL;
|
const struct trace_source *origin = src ? HA_ATOMIC_LOAD(&src->follow) : NULL;
|
||||||
|
|
||||||
if (!*args[3]) {
|
if (!*args[cur_arg+1]) {
|
||||||
/* no arg => report the list of supported sources as a warning */
|
/* no arg => report the list of supported sources as a warning */
|
||||||
if (origin)
|
if (origin)
|
||||||
chunk_printf(&trash, "Currently following source '%s'.\n", origin->name.ptr);
|
chunk_printf(&trash, "Currently following source '%s'.\n", origin->name.ptr);
|
||||||
@ -538,10 +547,10 @@ static int trace_parse_statement(char **args, char **msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
origin = NULL;
|
origin = NULL;
|
||||||
if (strcmp(args[3], "none") != 0) {
|
if (strcmp(args[cur_arg+1], "none") != 0) {
|
||||||
origin = trace_find_source(args[3]);
|
origin = trace_find_source(args[cur_arg+1]);
|
||||||
if (!origin) {
|
if (!origin) {
|
||||||
memprintf(msg, "No such trace source '%s'", args[3]);
|
memprintf(msg, "No such trace source '%s'", args[cur_arg+1]);
|
||||||
return LOG_ERR;
|
return LOG_ERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -552,13 +561,15 @@ static int trace_parse_statement(char **args, char **msg)
|
|||||||
list_for_each_entry(src, &trace_sources, source_link)
|
list_for_each_entry(src, &trace_sources, source_link)
|
||||||
if (src != origin)
|
if (src != origin)
|
||||||
HA_ATOMIC_STORE(&src->follow, origin);
|
HA_ATOMIC_STORE(&src->follow, origin);
|
||||||
|
cur_arg += 2;
|
||||||
|
goto next_stmt;
|
||||||
}
|
}
|
||||||
else if ((strcmp(args[2], "event") == 0 && (ev_ptr = &src->report_events)) ||
|
else if ((strcmp(args[cur_arg], "event") == 0 && (ev_ptr = &src->report_events)) ||
|
||||||
(strcmp(args[2], "pause") == 0 && (ev_ptr = &src->pause_events)) ||
|
(strcmp(args[cur_arg], "pause") == 0 && (ev_ptr = &src->pause_events)) ||
|
||||||
(strcmp(args[2], "start") == 0 && (ev_ptr = &src->start_events)) ||
|
(strcmp(args[cur_arg], "start") == 0 && (ev_ptr = &src->start_events)) ||
|
||||||
(strcmp(args[2], "stop") == 0 && (ev_ptr = &src->stop_events))) {
|
(strcmp(args[cur_arg], "stop") == 0 && (ev_ptr = &src->stop_events))) {
|
||||||
const struct trace_event *ev;
|
const struct trace_event *ev;
|
||||||
const char *name = args[3];
|
const char *name = args[cur_arg+1];
|
||||||
int neg = 0;
|
int neg = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -609,10 +620,8 @@ static int trace_parse_statement(char **args, char **msg)
|
|||||||
HA_ATOMIC_STORE(&src->lockon_ptr, NULL);
|
HA_ATOMIC_STORE(&src->lockon_ptr, NULL);
|
||||||
HA_ATOMIC_STORE(&src->state, TRACE_STATE_STOPPED);
|
HA_ATOMIC_STORE(&src->state, TRACE_STATE_STOPPED);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
else if (strcmp(name, "none") == 0)
|
||||||
if (strcmp(name, "none") == 0)
|
|
||||||
HA_ATOMIC_STORE(ev_ptr, 0);
|
HA_ATOMIC_STORE(ev_ptr, 0);
|
||||||
else if (strcmp(name, "any") == 0) {
|
else if (strcmp(name, "any") == 0) {
|
||||||
enum trace_state old = TRACE_STATE_STOPPED;
|
enum trace_state old = TRACE_STATE_STOPPED;
|
||||||
@ -638,9 +647,12 @@ static int trace_parse_statement(char **args, char **msg)
|
|||||||
if (ev_ptr == &src->start_events && HA_ATOMIC_LOAD(ev_ptr) != 0)
|
if (ev_ptr == &src->start_events && HA_ATOMIC_LOAD(ev_ptr) != 0)
|
||||||
HA_ATOMIC_CAS(&src->state, &old, TRACE_STATE_WAITING);
|
HA_ATOMIC_CAS(&src->state, &old, TRACE_STATE_WAITING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_arg += 2;
|
||||||
|
goto next_stmt;
|
||||||
}
|
}
|
||||||
else if (strcmp(args[2], "sink") == 0) {
|
else if (strcmp(args[cur_arg], "sink") == 0) {
|
||||||
const char *name = args[3];
|
const char *name = args[cur_arg+1];
|
||||||
struct sink *sink;
|
struct sink *sink;
|
||||||
|
|
||||||
if (!*name) {
|
if (!*name) {
|
||||||
@ -671,9 +683,12 @@ static int trace_parse_statement(char **args, char **msg)
|
|||||||
else
|
else
|
||||||
list_for_each_entry(src, &trace_sources, source_link)
|
list_for_each_entry(src, &trace_sources, source_link)
|
||||||
HA_ATOMIC_STORE(&src->sink, sink);
|
HA_ATOMIC_STORE(&src->sink, sink);
|
||||||
|
|
||||||
|
cur_arg += 2;
|
||||||
|
goto next_stmt;
|
||||||
}
|
}
|
||||||
else if (strcmp(args[2], "level") == 0) {
|
else if (strcmp(args[cur_arg], "level") == 0) {
|
||||||
const char *name = args[3];
|
const char *name = args[cur_arg+1];
|
||||||
int level = -1;
|
int level = -1;
|
||||||
|
|
||||||
if (*name)
|
if (*name)
|
||||||
@ -706,9 +721,12 @@ static int trace_parse_statement(char **args, char **msg)
|
|||||||
else
|
else
|
||||||
list_for_each_entry(src, &trace_sources, source_link)
|
list_for_each_entry(src, &trace_sources, source_link)
|
||||||
HA_ATOMIC_STORE(&src->level, level);
|
HA_ATOMIC_STORE(&src->level, level);
|
||||||
|
|
||||||
|
cur_arg += 2;
|
||||||
|
goto next_stmt;
|
||||||
}
|
}
|
||||||
else if (strcmp(args[2], "lock") == 0) {
|
else if (strcmp(args[cur_arg], "lock") == 0) {
|
||||||
const char *name = args[3];
|
const char *name = args[cur_arg+1];
|
||||||
|
|
||||||
if (!*name) {
|
if (!*name) {
|
||||||
chunk_printf(&trash, "Supported lock-on criteria for source %s:\n", src->name.ptr);
|
chunk_printf(&trash, "Supported lock-on criteria for source %s:\n", src->name.ptr);
|
||||||
@ -850,9 +868,12 @@ static int trace_parse_statement(char **args, char **msg)
|
|||||||
memprintf(msg, "Unsupported lock-on criterion '%s'", name);
|
memprintf(msg, "Unsupported lock-on criterion '%s'", name);
|
||||||
return LOG_ERR;
|
return LOG_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_arg += 2;
|
||||||
|
goto next_stmt;
|
||||||
}
|
}
|
||||||
else if (strcmp(args[2], "verbosity") == 0) {
|
else if (strcmp(args[cur_arg], "verbosity") == 0) {
|
||||||
const char *name = args[3];
|
const char *name = args[cur_arg+1];
|
||||||
const struct name_desc *nd;
|
const struct name_desc *nd;
|
||||||
int verbosity = -1;
|
int verbosity = -1;
|
||||||
|
|
||||||
@ -881,11 +902,16 @@ static int trace_parse_statement(char **args, char **msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
HA_ATOMIC_STORE(&src->verbosity, verbosity);
|
HA_ATOMIC_STORE(&src->verbosity, verbosity);
|
||||||
|
|
||||||
|
cur_arg += 2;
|
||||||
|
goto next_stmt;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
memprintf(msg, "Unknown trace keyword '%s'", args[2]);
|
memprintf(msg, "Unknown trace keyword '%s'", args[cur_arg]);
|
||||||
return LOG_ERR;
|
return LOG_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user