Skip to content

Instantly share code, notes, and snippets.

@JensRantil
Last active January 13, 2023 02:50
Show Gist options
  • Save JensRantil/dc544cac73a0e336d717963690c45b85 to your computer and use it in GitHub Desktop.
Save JensRantil/dc544cac73a0e336d717963690c45b85 to your computer and use it in GitHub Desktop.
Hacky one-liner for estimating progress when adding a new Cassandra node. Run on the join that’s joining and be sure to set NODES to number of nodes in the cluster that are streaming to the new node.
#!/bin/bash
while [ 1 ];do date -Iseconds | tr -d '\n';sudo nodetool netstats | grep Receiving | grep -Eo '[0-9]* bytes' | sed 's/ bytes//' | awk 'BEGIN {NODES=6;} NR%2==1 {TOTAL+=$0;} NR%2==0 {PROGRESS+=$0;} END {NODESRUNNING=NR/2;NODESDONE=NODES-NODESRUNNING;print " progress:", 100*(NODESDONE/NODES+(NODESRUNNING/NODES)*(PROGRESS/TOTAL)) "%", "running:", NODESRUNNING, "done:", NODESDONE;}';sleep 30;done
@JensRantil
Copy link
Author

Example output: 2021-06-23T22:11:51+02:00progress: 89.2757% running: 1 done: 5

@todd-tink
Copy link

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment