-
Notifications
You must be signed in to change notification settings - Fork 6
/
cassandra_sstable_count_by_size_magnitude
executable file
·48 lines (39 loc) · 1.39 KB
/
cassandra_sstable_count_by_size_magnitude
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
#!/usr/bin/env bash
#
# Show cassandra cluster internal and external addresses
# uses nodetool to get internal addresses and icanhazip.com for external addressses
#
# cassandra_node_sstable_count_by_size_magnatude [directory]
[ "root" != "$USER" ] && exec sudo $0 "$@"
showall=false
list_file_sample=0
if [ x"$1" == "x-s" ]; then list_file_sample=1; shift; fi
if [ x"$1" != x ]; then cd "$1"; fi
count_db_files () {
min_size=$1
max_size=$2
#set -x
file_count=$(find . -name '*Data.db' -type f -size +${min_size}c -size -${max_size}c -print 2>/dev/null | grep -v '/snapshots/' | grep -v '/backups/' | wc -l )
if [ 0 == $file_count ]; then
if [ $showall == true ]; then
printf '%20s %20s %20s\n' $min_size $max_size $file_count
fi
else
printf '%20s %20s %20s\n' $min_size $max_size $file_count
if [ $list_file_sample != 0 ]; then
find $(pwd) -name '*Data.db' -type f -size +${min_size}c -size -${max_size}c -print 2>/dev/null | grep -v '/snapshots/' | grep -v '/backups/' | head -n 1
fi
fi
}
printf '%20s %20s %20s\n' 'From Size' 'To Size' 'Count'
min=1
max=99999999999999999
lower=$min
power=2 # for 2x and 10x
until [ $lower -gt $max ]; do
upper=$((power*lower-1))
count_db_files $lower $upper
lower=$((upper+1))
done
printf '%20s %20s %20s\n' '--------------------' '--------------------' '--------------------'
count_db_files $min $upper