added script to setup a tmux terminal to watch the cluster
This commit is contained in:
parent
8109669fa0
commit
044f4d58a6
52
scripts/watch-cluster.sh
Executable file
52
scripts/watch-cluster.sh
Executable file
@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Define the tmux session name
|
||||||
|
SESSION="cluster_watch"
|
||||||
|
|
||||||
|
tmux has-session -t $SESSION 2>/dev/null
|
||||||
|
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
|
||||||
|
# Define the list of cupids
|
||||||
|
HOSTS=("apollo" "artemis" "cupid1" "cupid2" "cupid3" "cupid4" "ares")
|
||||||
|
|
||||||
|
# Start a new tmux session
|
||||||
|
tmux new-session -d -s $SESSION
|
||||||
|
|
||||||
|
# Create the bottom row with 6 panes arranged in a 2x3 grid
|
||||||
|
tmux split-window -v -t $SESSION
|
||||||
|
tmux select-pane -t $SESSION.1
|
||||||
|
|
||||||
|
tmux split-window -v -t $SESSION.1
|
||||||
|
|
||||||
|
tmux split-window -h -t $SESSION.1
|
||||||
|
tmux split-window -h -t $SESSION.1
|
||||||
|
|
||||||
|
|
||||||
|
tmux split-window -h -t $SESSION.4
|
||||||
|
tmux split-window -h -t $SESSION.5
|
||||||
|
|
||||||
|
tmux select-layout tile
|
||||||
|
|
||||||
|
# Select the first pane
|
||||||
|
tmux select-pane -t $SESSION.1
|
||||||
|
|
||||||
|
# SSH into each host and run 'sudo htop'
|
||||||
|
tmux send-keys -t $SESSION.0 "ssh ${HOSTS[0]}" C-m
|
||||||
|
for i in {1..6}; do
|
||||||
|
tmux send-keys -t $SESSION.$i "ssh ${HOSTS[$i]}" C-m
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
# Wait for SSH connections to establish
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
# Send 'sudo htop' command to each pane synchronously
|
||||||
|
tmux set-window-option synchronize-panes on
|
||||||
|
tmux send-keys "sudo htop" C-m
|
||||||
|
tmux set-window-option synchronize-panes off
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Attach to the tmux session
|
||||||
|
tmux attach-session -t $SESSION
|
||||||
Loading…
Reference in New Issue
Block a user