Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mheler/91a90b70ac6f37a0c9e499bf07573543 to your computer and use it in GitHub Desktop.
Save mheler/91a90b70ac6f37a0c9e499bf07573543 to your computer and use it in GitHub Desktop.
Detect oversized buckets on Ceph
#!/bin/bash
BUCKETS=($(radosgw-admin bucket list | jq -r .[]))
OVERSIZED_BUCKETS=0
for BUCKET in "${BUCKETS[@]}"
do
OBJECT_SIZE=$(radosgw-admin bucket stats --bucket=${BUCKET} | jq -r '.usage["rgw.main"].num_objects')
SHARDS=$(radosgw-admin bucket stats --bucket=${BUCKET} | jq -r .max_marker | awk -F "," '{print $NF}' | sed 's/[^0-9]*//g')
OBJECT_SHARD_RATIO=$(( OBJECT_SIZE/(SHARDS+1)/50000 ))
#printf "${BUCKET}: ${OBJECT_SHARD_RATIO} | Shards: ${SHARDS}\n"
if [ $OBJECT_SHARD_RATIO -gt 1 ]; then
printf "${BUCKET} has a object to shard ratio greater than 1 - Objects: ${OBJECT_SIZE} | Shards: ${SHARDS}\n"
((OVERSIZED_BUCKETS = $OVERSIZED_BUCKETS + 1 ))
fi
done
echo -e "# HELP ceph_oversized_buckets The amount of buckets that have a object-shard ratio greater than 1\n# TYPE ceph_oversized_buckets counter\nceph_oversized_buckets{cluster=\"archive-ceph-prod-a\"} ${OVERSIZED_BUCKETS}">/be-mobile/node-exporter/textfile-collector/ceph-radosgw.prom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment