Forked from ZiggyMaes/radosgw-object-shard-checker.sh
Created
September 8, 2022 19:20
-
-
Save mheler/91a90b70ac6f37a0c9e499bf07573543 to your computer and use it in GitHub Desktop.
Detect oversized buckets on Ceph
This file contains hidden or 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
#!/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