Skip to content

Instantly share code, notes, and snippets.

@drakonstein
Last active December 5, 2017 20:38
Show Gist options
  • Save drakonstein/0b2e72e1c1bc56d08b02e6c422f808b0 to your computer and use it in GitHub Desktop.
Save drakonstein/0b2e72e1c1bc56d08b02e6c422f808b0 to your computer and use it in GitHub Desktop.
Find the average objects per pg in each Ceph pool
#!/bin/bash
declare -A pool_pgs
declare -A pool_objs
output=$(ceph pg dump 2>/dev/null | awk '/active/ {print $1,$2}' | sed 's/\.[[:alnum:]]*//')
while read pool objs; do
pool_objs[$pool]=$(( ${pool_objs[$pool]:-0} + $objs))
pool_pgs[$pool]=$(( ${pool_pgs[$pool]} + 1 ))
done <<< "$output"
output="pool+objects+pgs+per"
for pool in ${!pool_pgs[@]}; do
objs=${pool_objs[$pool]}
pgs=${pool_pgs[$pool]}
output="$output
$pool+$objs+$pgs+$(awk 'BEGIN {print '${objs}' / '${pgs}'}')"
done
echo "$output" | sort -n | column -t -s'+'
unset pool_pgs
unset pool_avg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment