Tracer
Tracer will be capturing information in some way.
Collector will convert Tracer’s data_t to Tracking.
Note
Some filed of data_t will be converted to other more readable filed,
if you want to fit this feature, you should refer to Tracking.normalize_field.
- class duetector.tracers.BccTracer(config: Config | dict[str, Any] | None = None, *args, **kwargs)[source]
A Tracer use
bcc.BPFas a hostFor simple tracers, you can just set
attach_type,attatch_argsto attatch tobcc.BPF. Equal to bcc.BPF(prog).attatch_{attatch_type}(**attatch_args)For those tracers need to attatch multiple times, set
many_attatchsto attatch multiple times.set_callbackshould attatchcallbacktobpf, translate raw data todata_tthen call thecallback- FIXME:
Maybe it’s hard for using? Maybe we should use a more simple way to implement this?
- attach(host)[source]
Attatch to host.
Merge
attatch_type,attatch_argstomany_attatchsthen attatch.
- attach_type: str | None = None
Attatch type for
bcc.BPF, called asBPF.attatch_{attach_type},
- attatch_args: dict[str, str] = {}
Args for attatch function.
- property config_scope
Config scope for this tracer.
- data_t: namedtuple
Data type for this tracer.
- default_config = {'disabled': False}
Default config for this tracer.
- detach(host)[source]
Detach from host.
Merge
attatch_type,attatch_argstomany_attatchsthen detach.- FIXME:
Maybe we should specify
detach*for detaching?
- property disabled
If this tracer is disabled.
- many_attatchs: list[tuple[str, dict[str, str]]] = []
List of attatch function name and args.
attatch_type,attatch_argswill merge to this list.
- name: str | None
Name for this tracer. Will be used for collecting data.
- poll_args: dict[str, str] = {}
Args for poll function. Remenber to set
timeoutfor poll function inpoll_argsif needed,
- poll_fn: str
Poll function name in
bcc.BPF
- prog: str
bpf program
- class duetector.tracers.ShellTracer(config: Config | dict[str, Any] | None = None, *args, **kwargs)[source]
A tracer use
ShTracerHostas host. More detail on ShellMonitor and ShTracerHost.Output of shell command will be converted to
data_tand cached by default.- comm
shell command
- Type:
List[str]
- data_t
data type for this tracer
- Type:
NamedTuple
- Special config:
- enable_cache: If enable cache for this tracer.
Cache means the same output will not be converted and emited again.
- comm: list[str]
shell command
- property config_scope
Config scope for this tracer.
- data_t: ShellOutput
data type for this tracer
- default_config = {'disabled': False, 'enable_cache': True}
Default config for this tracer.
- property disabled
If this tracer is disabled.
- property enable_cache
If enable cache for this tracer.
- name: str | None
Name for this tracer. Will be used for collecting data.
- class duetector.tracers.SubprocessTracer(config: Config | dict[str, Any] | None = None, *args, **kwargs)[source]
-
- comm: list[str]
shell command
- property config_scope
Config scope for this tracer.
- data_t: namedtuple
Data type for this tracer.
- default_config = {'disabled': False}
Default config for this tracer.
- property disabled
If this tracer is disabled.
- name: str | None
Name for this tracer. Will be used for collecting data.
- preserve_env: bool = False
If preserve env for this command
- class duetector.tracers.Tracer(config: Config | dict[str, Any] | None = None, *args, **kwargs)[source]
A base class for all tracers.
As a reverse dependency for host, subclass should implement
attach,detach,get_pollerandset_callback. This allow tracer to decide how to attach to host, how to detach from host.data_tis a NamedTuple, which is used to convert raw data to aNamedTuple.Default scope for config is
Tracer.__class__.__name__.- property config_scope
Config scope for this tracer.
- data_t: namedtuple
Data type for this tracer.
- default_config = {'disabled': False}
Default config for this tracer.
- property disabled
If this tracer is disabled.
- name: str | None
Name for this tracer. Will be used for collecting data.