Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drakonstein/8188b5e554075cc49121939834baf65c to your computer and use it in GitHub Desktop.
Save drakonstein/8188b5e554075cc49121939834baf65c to your computer and use it in GitHub Desktop.
Random Ceph Commands
pg_state=backfilling
counts=$(ceph pg dump pgs_brief 2>/dev/null | awk -F'.' '/'${pg_state}'/ {print $1}' | sort | uniq -c)
pools=$(echo "$counts" | awk '{print $2}' | sed 's/^/ /' | sed 's/$/\$\\\|/' | sed 's/\\|$//')
output=$(ceph df | awk '{print $1" "$3" "$2}' | grep "$pools")
while read count pool; do
output=$(echo "$output" | sed "s/ $pool$/ $count/")
done <<< "$counts"
echo "pool used #pgs $pg_state
$output" | column -t -s' '
# one-liner
pg_state=backfilling; counts=$(ceph pg dump pgs_brief 2>/dev/null | awk -F'.' '/'${pg_state}'/ {print $1}' | sort | uniq -c); pools=$(echo "$counts" | awk '{print $2}' | sed 's/^/ /' | sed 's/$/\$\\\|/' | sed 's/\\|$//'); output=$(ceph df | awk '{print $1" "$3" "$2}' | grep "$pools"); while read count pool; do output=$(echo "$output" | sed "s/ $pool$/ $count/"); done <<< "$counts"; echo "pool used #pgs $pg_state
$output" | column -t -s' '
watch -n10 -d "ceph pg dump pgs_brief 2>&1 | awk '/backfilling/ {print \$3}' | grep -Eo '[[:digit:]]+' | sort -nr | uniq -c | sort -nr"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment