Skip to content

Instantly share code, notes, and snippets.

@wido
Last active June 9, 2022 07:44
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wido/27d7525a1d4effdc72efa6764351e518 to your computer and use it in GitHub Desktop.
Save wido/27d7525a1d4effdc72efa6764351e518 to your computer and use it in GitHub Desktop.
Ceph RADOS Gateway bucket statistics
#!/bin/bash
#
# Get the usage statistics of all RGW buckets
#
# Sort output with: ./rgw-bucket-stats.sh|sort -k 2 -n|tac
#
# Author: Wido den Hollander <wido@widodh.nl>
#
for BUCKET in $(radosgw-admin bucket list|python -c "import json,sys; [sys.stdout.write(bucket + '\n') for bucket in json.load(sys.stdin)]"); do
STATS=$(radosgw-admin bucket stats --bucket=$BUCKET)
KB=$(echo $STATS|python -c 'import sys, json; print(json.load(sys.stdin)["usage"]["rgw.main"]["size_kb_actual"])')
if [ "$?" -ne 0 ]; then
continue
fi
echo "$BUCKET $KB"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment