From f0c1ab81f6f32e621ac7a4da2dd6d38790fa900a Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Tue, 5 Mar 2024 14:38:30 -0800 Subject: [PATCH] Adds devnet script to fetch log files --- .devnet/fetch-logs.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 .devnet/fetch-logs.sh diff --git a/.devnet/fetch-logs.sh b/.devnet/fetch-logs.sh new file mode 100755 index 0000000000..aa518e584f --- /dev/null +++ b/.devnet/fetch-logs.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Determine the number of AWS EC2 instances by checking ~/.ssh/config +NODE_ID=0 +while [ -n "$(grep "aws-n${NODE_ID}" ~/.ssh/config)" ]; do + NODE_ID=$((NODE_ID + 1)) +done + +# Read the number of AWS EC2 instances to query from the user +read -p "Enter the number of AWS EC2 instances to query (default: $NODE_ID): " NUM_INSTANCES +NUM_INSTANCES="${NUM_INSTANCES:-$NODE_ID}" + +echo "Using $NUM_INSTANCES AWS EC2 instances for querying." + +# Define the directory where logs will be saved +log_directory="$HOME/snarkos_logs" + +# Create the log directory if it doesn't already exist +mkdir -p "$log_directory" + +# Loop from 0 to 49 +for i in $(seq 0 $(($NUM_INSTANCES - 1))); do + echo "Connecting to aws-n$i..." + # Use sftp to connect, execute commands, and exit + sftp aws-n$i << EOF +cd /tmp +get snarkos.log "$log_directory/snarkos-$i.log" +EOF + echo "Downloaded snarkos.log from aws-n$i as snarkos-$i.log into $log_directory" +done + +echo "All files have been downloaded to $log_directory."