collect command is the primary entry point for tracing packets in the Linux networking stack. It installs probes, gathers events, and can either display them instantly or save them to a file for later processing.
Usage
Overview
The collect command uses “collectors” to retrieve data and emit events. Collectors extract data from different parts of the kernel or userspace daemons using eBPF. Some install probes automatically, while each collector specializes in retrieving specific data.Core Options
Comma-separated list of collectors to enable.Available collectors:
auto- Enable all collectors if prerequisites are metskb-tracking- Packet tracking identifiersskb- Packet informationskb-drop- Drop reason informationovs- OpenVSwitch datanft- Nftables contextct- Conntrack informationdev- Network device informationns- Namespace information
Add a probe on the given target. Can be used multiple times.Probes follow the
[TYPE:]TARGET[/OPTIONS] pattern.Valid types:kprobeork- Kernel probeskretprobeorkr- Kernel return probesraw_tracepointortp- Kernel tracepoints
Filtering Options
Add a packet filter using pcap-filter syntax.
Add a metadata filter to match kernel structure fields.Syntax:
sk_buff.member1.[...].memberN.member_leaf [==|<=|>=|!=] valueOutput Options
Write events to a file rather than stdout.If the flag is used without a filename, defaults to
retis.data.Rotate the output file once a size limit is reached.Requires
--out. The limit must be suffixed with a size unit (MB, GB).Write events to stdout even if
--out is used.Format used when printing events.Options:
multi-line, single-lineAdvanced Options
Include stack traces in kernel events.
Automatically add probes based on stack traces.This mode evaluates stack traces and adds additional kprobes at runtime.Requirements:
- A filter is required (
--filter-packetand/or--filter-meta) - If no explicit probe is given, uses
tp:skb:kfree_skbandtp:skb:consume_skb
Execute a command and terminate collection once done.
Allow system changes needed for full tracing functionality.This includes:
- Mounting tracefs to
/sys/kernel/tracing - Creating nftables dummy table (for nft collector)
Path to kernel configuration file.Default: auto-detect
Print timestamps as UTC instead of monotonic.
Print link-layer information from packets.
Examples
Common Use Cases
Troubleshooting packet drops
Tracing OpenVSwitch flows
Following a specific connection
Limited duration collection
Default Behavior
When no options are specified:- All collectors are enabled if prerequisites are met
- Default probes:
tp:net:netif_receive_skbandtp:net:net_dev_start_xmit - Events are printed to stdout
- Multi-line format is used
