Skip to content

Instantly share code, notes, and snippets.

@f3lan
Created June 27, 2017 07:11
Show Gist options
  • Save f3lan/9f387e81c428007113f390ca01427162 to your computer and use it in GitHub Desktop.
Save f3lan/9f387e81c428007113f390ca01427162 to your computer and use it in GitHub Desktop.
Webshop4 Monitoring Script
#!/bin/bash
# Declare Session Variable
SESSION="ey"
function hassession {
tmux has-session -t ey 2>/dev/null
}
# Change to the Webshop 4 Project Dir
cd /Users/$USER/Projects/webshop4/
# # Get the servers addresses
SERVERS=($(ey servers --environment="Production" | awk '{print $1}'))
SERVERS=("${SERVERS[@]:2}")
# Create tmux session
if ! hassession ; then
echo "Starting new session for ey"
tmux new -s $SESSION -d
# Handle first host.
host=${SERVERS[0]}
echo "Creating window split for host: $host"
tmux send-key "ssh deploy@$host" C-m
tmux send-key "htop" C-m
unset SERVERS[0]
# Loop through the other hosts
for host in "${SERVERS[@]}"
do
echo "Creating window split for host: $host"
tmux split-window -v
tmux select-layout tiled > /dev/null
tmux send-key "ssh deploy@$host" C-m
tmux send-key "htop" C-m
done
fi
tmux attach -t $SESSION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment