python command provides an interactive Python shell or executes Python scripts with Retis events automatically imported.
Usage
Overview
The python command enables custom event analysis using Python. You can either drop into an interactive shell for exploration or execute scripts for automated processing.Arguments
Python script to execute.Can be:
- Full path to a
.pyfile - Script name (without
.py) from standard locations - Omitted to start an interactive shell
$HOME/.config/retis/python//usr/share/retis/python/
Arguments for the Python script.Available in the script as
sys.argv.Options
File from which to read events.
Examples
Python API
In Python scripts or the interactive shell, Retis events are automatically available:Event Object Structure
Events have the following sections (when available):Script Examples
Count packets by probe
Extract packet data
Filter by criteria
Timestamp analysis
Interactive Shell
Start an interactive Python shell:Script Locations
Scripts are searched in the following order:- Exact path if provided (e.g.,
./script.py) $HOME/.config/retis/python/script.py/usr/share/retis/python/script.py
.py extension:
Script Arguments
Arguments are passed to scripts viasys.argv:
Common Use Cases
Custom statistics
Data export
Correlation analysis
Integration with other tools
Python Dependencies
Scripts can import any Python modules available in your environment:Performance Tips
- For large event files, process events in batches
- Use generators instead of loading all events in memory
- Consider filtering events during collection to reduce file size
