From 044f4d58a65650d03992196301916df1d023d865 Mon Sep 17 00:00:00 2001 From: "virgil@virgil" Date: Tue, 1 Apr 2025 08:29:19 -0400 Subject: [PATCH] added script to setup a tmux terminal to watch the cluster --- scripts/watch-cluster.sh | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 scripts/watch-cluster.sh diff --git a/scripts/watch-cluster.sh b/scripts/watch-cluster.sh new file mode 100755 index 0000000..aa2c573 --- /dev/null +++ b/scripts/watch-cluster.sh @@ -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