Created
June 27, 2017 07:11
-
-
Save f3lan/9f387e81c428007113f390ca01427162 to your computer and use it in GitHub Desktop.
Webshop4 Monitoring Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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