Last active
August 29, 2015 14:20
-
-
Save deanproctor/2474dbd04ace99c999f0 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
# check: vbucket_check.sh | |
# This check generates a test key for each node in the cluster. Each test key is fetched and success/failure reported by server. | |
# Requires: curl, Couchbase vbuckettool, Couchbase C client | |
host=localhost | |
bucket=default | |
rest_port=8091 | |
test_keys=$(curl -Ss http://$host:8091/pools/default/buckets/$bucket | /opt/couchbase/bin/tools/vbuckettool - monitor_key_{1..1024} | sort -k4,4 -u | awk {'print $2,$4'}) | |
default_ifs=$IFS | |
IFS=$'\n' | |
for line in $test_keys | |
do | |
IFS=$default_ifs | |
arr=($line) | |
key=${arr[0]} | |
server=$(echo ${arr[1]} | cut -f1 -d ':') | |
memcached_port=$(echo ${arr[1]} | cut -f2 -d ':') | |
result=$(cbc cat -U "couchbase://${server}:${memcached_port}/${bucket}" $key 2>&1 | grep -c fail) | |
if [ "$result" -eq "0" ] | |
then | |
echo $server success | |
else | |
check_warmup=$(cbc stats -U "couchbase://${server}:${rest_port}" 2>&1 | grep -c -e "${server}:${memcached_port}[[:blank:]]ep_warmup_thread[[:blank:]]running") | |
if [ "$check_warmup" -eq "0" ] | |
then | |
echo $server fail | |
else | |
echo $server warmup | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment