몇가지 Shell Script - jupark33/Spring GitHub Wiki
#!/bin/sh
if [ $# -ne 2 ]; then
echo 'param not 2'
exit
fi
echo 'param ok'
#!/bin/sh
echo "Get Kafka Active Topics"
ARR_CG=( `bin/kafka-consumer-groups.sh --list --bootstrap-server localhost:9092` )
for (( i=0; i<${#ARR_CG[@]}; i++ )); do
cmd=` bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group ${ARR_CG[i]} --describe`
echo "$cmd"
done
/////// active topic 목록, 파라미터로 broker ip 와 port 전달
#!/bin/sh
echo "Get Kafka Active Topics"
if [ $# -ne 2 ]; then
echo 'please input host & port parameter'
echo 'ex) get-active-topics.sh localhost 9200'
exit
fi
# ARR_CG=( `bin/kafka-consumer-groups.sh --list --bootstrap-server localhost:9092` )
ARR_CG=( `bin/kafka-consumer-groups.sh --list --bootstrap-server ${1}:${2}` )
for (( i=0; i<${#ARR_CG[@]}; i++ )); do
# cmd=` bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group ${ARR_CG[i]} --describe`
cmd=` bin/kafka-consumer-groups.sh --bootstrap-server ${1}:${2} --group ${ARR_CG[i]} --describe`
echo "$cmd"
done
//////// rmq consumer 목록 조회 하여, 사용중인 큐 목록
#!/bin/sh
echo "Get RMQ Active Consumer List"
# topic 이름을 중복 없이 저장하는 배열
arr_topic=()
function isExistTopic() {
#echo "argv: $1"
for topic in ${arr_topic[@]}; do
if [ "${topic}" == "$1" ]; then
# 이미 존재하는 topic 이름
#echo "alreay exist, ${topic}"
return;
fi
done
echo $1
len_arr_topic=${#arr_topic[*]}
#echo "len_arr_topic = ${len_arr_topic}"
arr_topic[len_arr_topic]=$1
}
while read line; do
#echo $line
array=($line)
#echo ${array[0]}
isExistTopic ${array[0]}
done < rmq_consumers.txt
echo "len : ${#arr_topic[*]}"