-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtpstats-get.sh
executable file
·55 lines (41 loc) · 1.24 KB
/
tpstats-get.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function print_usage
{
cat << EOF
Usage: $(basename $0) [ip_address1 ipaddress2 ipaddress3 ...]
This tool will loop through all the Cassandra nodes specified on
the command line and call nodetool tpstats, one server per 5 seconds.
Output will be appended to a file called tpstats.out
If no addresses are specified, /etc/dse/cassandra/cassandra.yaml is
parsed to return the seed list.
After completion, run tpstats-diff.sh to summarize the delta for
any one metric across each of the stat files or use tpstat-summarize.sh
to detect changes between statatistics.
EOF
}
file="/etc/dse/cassandra/cassandra.yaml"
outfile=tpstats.out
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]] ; then
print_usage
exit 1
fi
if [ $# -lt 1 ]; then
echo "Using seed list from $file"
seeds=`sed -n "s/ - {*seeds:.\(.*\)/\1/p" $file | tr ",\'\"{}" " "`
else
seeds="$@"
fi
if [ -e tpstats.out ]; then
echo "ERROR: $outfile exists!"
echo "If you are starting a new test, stop $0 and then archive/delete $outfile"
echo "Exiting."
exit 1
fi
while [ 1 ]
do
for host in $seeds
do
date=`date +"%Y-%m-%dT%H:%M:%S"`
nodetool -h $host tpstats 2>/dev/null | awk -v d="$date" -v h="$host" '{for(i=1;i<=NF;++i)$i=(i==1)?d " " h " " $i:$i;print}' >> $outfile
done
sleep 5
done