add new functions
This commit is contained in:
parent
64a7a906be
commit
1c9dc9a937
1 changed files with 72 additions and 12 deletions
|
@ -3,24 +3,47 @@
|
||||||
function help() {
|
function help() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
|
||||||
Usage: $(basename $0) <action> <node>
|
Legt einzelne Nodes aus einem Cluster im Loadbalancer still
|
||||||
|
Das Skript $(basename $0) wird von der lokalen Workstation aus ausgeführt
|
||||||
|
|
||||||
<action> [enable|disable|help]
|
Usage: $(basename $0) <action> <node>
|
||||||
<node> Nomenklatur ist <svc><cluster><env><node>
|
$(basename $0) help
|
||||||
|
|
||||||
|
<action> [enable|disable|serverstate|showstat|showmaint]
|
||||||
|
<node> Nomenklatur ist <svc><cluster><env><node> (z.B. jra4t1 - Jira, Cluster 4 (ITSM), Test, Node 1)
|
||||||
<svc> [jra|cnf] 3 characters
|
<svc> [jra|cnf] 3 characters
|
||||||
<cluster> [0-9] 1 character
|
<cluster> [0-9] 1 character
|
||||||
<env> [pte] 1 character
|
<env> [pte] 1 character
|
||||||
<node> [0-9] 1 character
|
<node> [0-9] 1 character
|
||||||
|
help zeigt diese Hilfe
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
case $1 in
|
COMMAND=$1
|
||||||
|
case ${COMMAND} in
|
||||||
enable)
|
enable)
|
||||||
ACTION=enable
|
ACTION=enable
|
||||||
;;
|
;;
|
||||||
disable)
|
disable)
|
||||||
ACTION=disable
|
ACTION=disable
|
||||||
;;
|
;;
|
||||||
|
backend)
|
||||||
|
ACTION=show
|
||||||
|
WHAT="backend"
|
||||||
|
;;
|
||||||
|
serverstate)
|
||||||
|
ACTION=show
|
||||||
|
WHAT="servers state"
|
||||||
|
;;
|
||||||
|
showstat)
|
||||||
|
ACTION=show
|
||||||
|
WHAT="stat"
|
||||||
|
;;
|
||||||
|
showmaint)
|
||||||
|
ACTION=showmaint
|
||||||
|
WHAT="stat"
|
||||||
|
;;
|
||||||
help)
|
help)
|
||||||
help
|
help
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -35,25 +58,62 @@ shift
|
||||||
UMG=${1:4:1}
|
UMG=${1:4:1}
|
||||||
CLUSTER=${1:0:4}
|
CLUSTER=${1:0:4}
|
||||||
NODE=${1:5:1}
|
NODE=${1:5:1}
|
||||||
LBS=( atlb${UMG}1 atlb${UMG}2 )
|
#LBS=( atlb${UMG}1 atlb${UMG}2 )
|
||||||
|
LBS=( sl${UMG}ebsatlassianlb01 sl${UMG}ebsatlassianlb02 )
|
||||||
BACKENDS=( ${CLUSTER} ${CLUSTER}_direct )
|
BACKENDS=( ${CLUSTER} ${CLUSTER}_direct )
|
||||||
SERVERS=( ${CLUSTER}${NODE} ${CLUSTER}${NODE}d )
|
SERVERS=( ${CLUSTER}${NODE} ${CLUSTER}${NODE}d )
|
||||||
HAADMINSOCK=/run/haproxy/admin.sock
|
HAADMINSOCK=/run/haproxy/admin.sock
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
while [ $i -lt ${#BACKENDS[@]} ];do
|
case $COMMAND in
|
||||||
|
backend|showstat)
|
||||||
|
cat << EOF
|
||||||
|
Action: $ACTION
|
||||||
|
Umgebung: $UMG
|
||||||
|
Cluster: $CLUSTER
|
||||||
|
Loadbalancers: ${LBS[*]}
|
||||||
|
Backend: ${BACKENDS[$i]}
|
||||||
|
What: ${WHAT}
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
cat << EOF
|
EOF
|
||||||
|
echo "echo '$ACTION $WHAT'|socat stdio $HAADMINSOCK"
|
||||||
|
parallel-ssh -i $(for l in ${LBS[@]};do echo -H $l;done) "echo '$ACTION $WHAT'|socat stdio $HAADMINSOCK"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
while [ $i -lt ${#BACKENDS[@]} ];do
|
||||||
|
|
||||||
|
cat << EOF
|
||||||
Action: $ACTION
|
Action: $ACTION
|
||||||
Umgebung: $UMG
|
Umgebung: $UMG
|
||||||
Cluster: $CLUSTER
|
Cluster: $CLUSTER
|
||||||
Node: $NODE
|
Node: $NODE
|
||||||
Loadbalancers: ${LBS[*]}
|
Loadbalancers: ${LBS[*]}
|
||||||
Backend: ${BACKENDS[$i]}
|
Backend: ${BACKENDS[$i]}
|
||||||
Server: ${SERVERS[$i]}
|
Server: ${SERVERS[$i]}
|
||||||
|
What: ${WHAT}
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
parallel-ssh -i $(for l in ${LBS[@]};do echo -H $l;done) "echo '$ACTION server ${BACKENDS[$i]}/${SERVERS[$i]}'|socat stdio $HAADMINSOCK"
|
|
||||||
i=$((i+1))
|
case $ACTION in
|
||||||
done
|
enable|disable)
|
||||||
|
echo "echo '$ACTION server ${BACKENDS[$i]}/${SERVERS[$i]}'|socat stdio $HAADMINSOCK"
|
||||||
|
parallel-ssh -i $(for l in ${LBS[@]};do echo -H $l;done) "echo '$ACTION server ${BACKENDS[$i]}/${SERVERS[$i]}'|socat stdio $HAADMINSOCK"
|
||||||
|
;;
|
||||||
|
show)
|
||||||
|
echo "echo '$ACTION $WHAT ${BACKENDS[$i]}'|socat stdio $HAADMINSOCK"
|
||||||
|
parallel-ssh -i $(for l in ${LBS[@]};do echo -H $l;done) "echo '$ACTION $WHAT ${BACKENDS[$i]}'|socat stdio $HAADMINSOCK"
|
||||||
|
;;
|
||||||
|
showmaint)
|
||||||
|
UMG=t LBS=( sl${UMG}ebsatlassianlb01 sl${UMG}ebsatlassianlb02 )
|
||||||
|
UMG=p LBS=( ${LBS[@]} sl${UMG}ebsatlassianlb01 sl${UMG}ebsatlassianlb02 )
|
||||||
|
echo LBS: ${LBS[@]}
|
||||||
|
echo "echo '$ACTION $WHAT ${BACKENDS[$i]}'|socat stdio $HAADMINSOCK"
|
||||||
|
parallel-ssh --inline-stdout $(for l in ${LBS[@]};do echo -H $l;done) "echo 'show $WHAT ${BACKENDS[$i]}'|socat stdio $HAADMINSOCK"| awk -F, '$1~/^\[[0-9][0-9]*/ {print $0} $18=="MAINT" {print "backend "$1" - "$2" "$18}'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
Loading…
Reference in a new issue