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() {
|
||||
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]
|
||||
<node> Nomenklatur ist <svc><cluster><env><node>
|
||||
Usage: $(basename $0) <action> <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
|
||||
<cluster> [0-9] 1 character
|
||||
<env> [pte] 1 character
|
||||
<node> [0-9] 1 character
|
||||
help zeigt diese Hilfe
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
case $1 in
|
||||
COMMAND=$1
|
||||
case ${COMMAND} in
|
||||
enable)
|
||||
ACTION=enable
|
||||
;;
|
||||
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
|
||||
exit 0
|
||||
|
@ -35,25 +58,62 @@ shift
|
|||
UMG=${1:4:1}
|
||||
CLUSTER=${1:0:4}
|
||||
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 )
|
||||
SERVERS=( ${CLUSTER}${NODE} ${CLUSTER}${NODE}d )
|
||||
HAADMINSOCK=/run/haproxy/admin.sock
|
||||
|
||||
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
|
||||
Umgebung: $UMG
|
||||
Cluster: $CLUSTER
|
||||
Node: $NODE
|
||||
Loadbalancers: ${LBS[*]}
|
||||
Backend: ${BACKENDS[$i]}
|
||||
Server: ${SERVERS[$i]}
|
||||
Backend: ${BACKENDS[$i]}
|
||||
Server: ${SERVERS[$i]}
|
||||
What: ${WHAT}
|
||||
------------------------------------
|
||||
|
||||
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))
|
||||
done
|
||||
|
||||
case $ACTION in
|
||||
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