Skip to content

Instantly share code, notes, and snippets.

@folex
Last active June 4, 2018 12:24
Cassandra Nodetool snippets

Table latency

function table_latency {
	(echo 'Table ReadCount WriteCount ReadLatency(ms) WriteLatency(ms) TotalRead(sec) TotalWrite(sec)' && \
	nodetool cfstats $1 | grep 'Table:\|Local' | \
		awk -F" " '{ 
		if (index($1,"Table:") != 0) {
			t = $2; getline
			rc = $4; getline
			rl = $4; getline
			wc = $4; getline
			wl = $4
			printf "%s %s %s %s %s %.2f %.2f \n", t, rc, wc, rl, wl, rc*rl/1000, wc*wl/1000
		}  
	}'  \
	| sort -nk4) | column -t
}

Index latency

function index_latency {
	(echo 'Table ReadCount WriteCount ReadLatency(ms) WriteLatency(ms) TotalRead(sec) TotalWrite(sec)' && \
	nodetool cfstats $1 | grep 'Local\|Table (' |  sed -e "s/ (index)//" | \
	awk -F" " '{ 
		if (index($1,"Table") != 0) {
			t = $2; getline
			rc = $4; getline
			rl = $4; getline
			wc = $4; getline
			wl = $4
			printf "%s %s %s %s %s %.2f %.2f \n", t, rc, wc, rl, wl, rc*rl/1000, wc*wl/1000
		}  
	}'  \
	| sort -nk4) | column -t
}

Tombstones

function tombstones {
	(echo 'Table LiveAverage LiveMax TombsoneAverage TombsoneMax' && \
	nodetool cfstats $1 | grep 'live cells\|tombstone\|Table (\|Table:' |  sed -e "s/ (index)//" | \
	awk -F" " '{ 
	    if (index($1,"Table") != 0) {
	        t = $2; getline
	        avglive = $9; getline
	        maxlive = $9; getline
	        avgtomb = $8; getline
	        maxtomb = $8; 
	        printf "%s %.2f %.2f %.2f %.2f \n", t, avglive, maxlive, avgtomb, maxtomb
	    }  
	}'  \
	| sort -nk4) | column -t
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment