Last active
December 16, 2019 21:16
-
-
Save drakonstein/8188b5e554075cc49121939834baf65c to your computer and use it in GitHub Desktop.
Random Ceph Commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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