etcdctl --endpoints=http://127.0.0.1:2379 \
endpoint status --write-out=json |
python3 -c '
import json
import sys
data = json.load(sys.stdin)
print("{:<30} {:>12} {:>12} {:>16} {:>12}".format(
"ENDPOINT", "DB_MiB", "IN_USE_MiB", "FRAGMENTED_MiB", "FRAG_%"
))
for item in data:
status = item["Status"]
total = status.get("dbSize", 0)
used = status.get("dbSizeInUse", 0)
fragmented = max(total - used, 0)
percentage = fragmented * 100 / total if total else 0
print("{:<30} {:>12.2f} {:>12.2f} {:>16.2f} {:>11.2f}%".format(
item["Endpoint"],
total / 1048576,
used / 1048576,
fragmented / 1048576,
percentage
))
'





0 comments:
Post a Comment