Last active
January 18, 2019 21:44
-
-
Save ThinGuy/08e83c4eefcaa20d53e011d6e6e685a5 to your computer and use it in GitHub Desktop.
bash function script to connect to all ipmi consoles using byobu (tmux) given an array of IPs. 6 consoles per window. Tmux limit of 15 windows.
This file contains hidden or 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
ipmi-consoles() { | |
declare -ag IPMI_IP_LIST=($(printf 10.38.14."%s\n" {4..39})) | |
byobu new-session -d -s CONSOLES | |
SPLITS=6 | |
WIN=0 | |
export IPMI_USER=root | |
export IPMI_PASSWORD=calvin | |
for ((i=0; i<${#IPMI_IP_LIST[@]}; i+=${SPLITS}));do | |
PANES=("${IPMI_IP_LIST[@]:i:${SPLITS}}") | |
for p in ${!PANES[@]};do | |
if [[ ${p} -eq 0 ]];then | |
export WIN=$(($WIN+1)) | |
printf "Creating Window $WIN with $SPLITS consoles\n" | |
printf "\e[2G- Connecting to IPMI Console @ ${PANES[$p]}\n" | |
byobu new-window -n "${PANES[0]}-${PANES[-1]}" -t CONSOLES bash -lic \ | |
'echo;clear | |
export IPMI_IP='${PANES[$p]}' IPMI_USER='${IPMI_USER}' IPMI_PASSWORD='${IPMI_PASSWORD}' | |
byobu select-layout tiled;echo | |
ipmitool -H ${IPMI_IP} -I lanplus -U ${IPMI_USER} -E sol activate | |
reconnect(){ ipmitool -H ${IPMI_IP} -I lanplus -U ${IPMI_USER} -E sol activate; };export -f reconnect | |
clear;echo "Type \"reconnect\" to reestablish the ipmi console session";echo;echo | |
bash' | |
else | |
byobu select-layout tiled | |
printf "\e[2G- Connecting to IPMI Console @ ${PANES[$p]}\n" | |
byobu splitw -h bash -lic \ | |
'echo;clear | |
export IPMI_IP='${PANES[$p]}' IPMI_USER='${IPMI_USER}' IPMI_PASSWORD='${IPMI_PASSWORD}' | |
byobu select-layout tiled | |
ipmitool -H ${IPMI_IP} -I lanplus -U ${IPMI_USER} -E sol activate | |
reconnect(){ ipmitool -H ${IPMI_IP} -I lanplus -U ${IPMI_USER} -E sol activate; };export -f reconnect | |
clear;echo "Type \"reconnect\" to reestablish the ipmi console session";echo;echo | |
bash' | |
fi | |
done | |
done | |
byobu attach-session -t CONSOLES | |
};export -f ipmi-consoles |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment