Skip to content

Commit

Permalink
Merge pull request #3161 from AleoHQ/fetch-logs
Browse files Browse the repository at this point in the history
Adds devnet bash script to fetch log files
  • Loading branch information
howardwu committed Mar 9, 2024
2 parents 7fe320f + f0c1ab8 commit fe2051a
Showing 1 changed file with 32 additions and 0 deletions.
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."

0 comments on commit fe2051a

Please sign in to comment.