-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_read_write_count_cfstats.sh
More file actions
53 lines (46 loc) · 1.41 KB
/
Copy pathparse_read_write_count_cfstats.sh
File metadata and controls
53 lines (46 loc) · 1.41 KB
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
53
#!/bin/bash
# Copy this script in the directory where the cfstats file resides
# Requires gawk to be installed in MacOS
gawk '
BEGIN {
FS=":[ \t]*"; # Define field separator
keyspace="";
table="";
readCount="";
writeCount="";
print "Starting parsing...";
IGNORECASE=1; # Ignore case sensitivity
}
/^Keyspace/ {
if (keyspace != "" && table != "" && readCount != "" && writeCount != "") {
print keyspace, table, readCount, writeCount, (readCount + writeCount);
}
# Reset table, readCount, and writeCount for new keyspace
table="";
readCount="";
writeCount="";
sub(/^[ \t]*/, "", $2); # Trim leading whitespace
keyspace=$2;
}
/^[ \t]*Table/ {
if (table != "" && readCount != "" && writeCount != "") {
print keyspace, table, readCount, writeCount, (readCount + writeCount);
}
# Reset readCount and writeCount for new table
readCount="";
writeCount="";
sub(/^[ \t]*/, "", $2); # Trim leading whitespace
table=$2;
}
/^[ \t]*Local read count/ {
readCount=$2;
}
/^[ \t]*Local write count/ {
writeCount=$2;
}
END {
if (keyspace != "" && table != "" && readCount != "" && writeCount != "") {
print keyspace, table, readCount, writeCount, (readCount + writeCount);
}
}
' cfstats | sort -k5,5nr | awk '{ printf "Keyspace: %s, Table: %s, Local read count: %s, Local write count: %s, Total count: %s\n", $1, $2, $3, $4, $5 }'