Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds devnet bash script to fetch log files #3161

Merged
merged 1 commit into from Mar 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions .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."