A flexible Bash script to SSH into a remote Ethereum node and retrieve Docker container logs. The script is interactive, allowing for dynamic configuration of the target node, container names, and log filtering methods without needing to edit the file.
- Interactive Setup: No need to hardcode values. The script prompts for all necessary information at runtime.
- Flexible Node Targeting: Specify any SSH-accessible node address.
- Container Confirmation: Confirms the list of target container names before running.
- Dual Filtering Modes:
- Time-based (Recommended): Efficiently fetches logs using Docker's
--sinceand--untilflags (e.g.,24h,3d). - Slot/Block Search: Performs a text-based search for a specific range of slot or block numbers, useful for targeting specific events.
- Time-based (Recommended): Efficiently fetches logs using Docker's
- Log Highlighting: When using the slot/block search method, the script automatically highlights the specified numbers in the output files, making them easy to spot in a terminal.
- Organized Output: Saves logs in a dedicated
~/container_logsdirectory, with clearly named files.
- Local machine must have
sshandbashinstalled. - Remote node must be running Docker and be accessible via SSH from your local machine.
- SSH keys should be configured for passwordless login to the remote node for the script to run without interruption.
- Make the script executable:
chmod +x get_container_logs.sh
- Run the script:
./get_container_logs.sh
- Follow the interactive prompts:
- Enter node address: Provide the
user@hostnamefor your remote node. - Confirm container names: Press
Enterto accept the defaults or type a new name and pressEnter. - Select log filtering method: Choose
Tfor time-based orSfor slot/block search. - Provide filter values: Enter the time duration (e.g.,
48h) or the start/end slot numbers.
- Enter node address: Provide the
The script will then connect to the node, retrieve the logs, and save them to ~/container_logs. If you used the slot/block search, the relevant numbers will be highlighted in red in the output files. To view the highlighted logs, use a command like cat or less -R.
less -R ~/container_logs/charon-distributed-validator-node-charon-1_logs_slot_12186698_to_12186698.txt