Skip to content

Instantly share code, notes, and snippets.

@RitterHou RitterHou/es-test.sh

Last active May 16, 2020
Embed
What would you like to do?
#!/usr/bin/env bash
date '+%Y-%m-%d %H:%M:%S'
# 打印查询DSL
echo -n 'Query DSL: '
cat query.json
echo ''
# 默认并发数
cocurrency=60
# 默认压测持续时间
timelimit=10
while getopts "t:c:" opt
do
case "$opt" in
c ) cocurrency="$OPTARG" ;;
t ) timelimit="$OPTARG" ;;
? ) echo "Unknown option ${OPTARG}" ;;
esac
done
echo "Benchmark ${timelimit} second(s) and cocurrency is ${cocurrency}"
declare -a nodes=(
# "172.19.66.58#1.5.2"
"172.19.66.70#1.5.2"
"172.19.66.77#7.5.2"
# "172.19.66.133#7.5.2"
)
# 打印一行分割线
printLine() {
cols=$(tput cols)
for _ in $(seq 2 "${cols}")
do
echo -n "$1"
done
echo ""
}
for node in "${nodes[@]}"
do
IFS='#' read -ra n <<< "$node"
host=${n[0]}
version=${n[1]}
printLine "#"
echo "Elasticsearch-${version} >>> ${host}"
printLine "#"
ab -t "${timelimit}" -c "${cocurrency}" -p query.json -T 'application/json' http://"${host}":9200/acct-trades-bills/_search
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.