Last active
April 8, 2021 07:56
-
-
Save wido/b1328dd45aae07c45cb8075a24de9f1f to your computer and use it in GitHub Desktop.
Calculate Ceph BlueStore OSD overhead per object
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
#!/usr/bin/env python | |
''' | |
Talk to local Ceph OSDs running with BlueStore and calculate the overhead | |
per object in the RocksDB database from BlueStore. | |
Author: Wido den Hollander <[email protected]> | |
''' | |
import json | |
from os import listdir | |
from os.path import isfile, join | |
from subprocess import check_output | |
SOCKET_DIR = '/var/run/ceph' | |
def get_local_osds(): | |
mypath = '/var/run/ceph/' | |
sockets = [f for f in listdir(SOCKET_DIR) if (f.startswith('ceph-osd') and f.endswith('asok'))] | |
osds = list() | |
for socket in sockets: | |
osds.append(socket.split('.')[1]) | |
return osds | |
def osd_perf_dump(osd_id): | |
cmd = ['ceph', 'daemon', 'osd.' + str(osd_id), 'perf', 'dump'] | |
return json.loads(check_output(cmd)) | |
def get_osd_perf(): | |
perf = dict() | |
for osd_id in get_local_osds(): | |
perf[osd_id] = osd_perf_dump(osd_id) | |
return perf | |
if __name__ == '__main__': | |
perf = get_osd_perf() | |
for osd_id, perf in perf.items(): | |
if 'bluestore' in perf: | |
onodes = perf['bluestore']['bluestore_onodes'] | |
stat_bytes_used = perf['osd']['stat_bytes_used'] | |
db_used_bytes = perf['bluefs']['db_used_bytes'] | |
overhead = db_used_bytes / onodes | |
avg_obj_size = stat_bytes_used / onodes | |
print('osd.{0} onodes={1} db_used_bytes={2} avg_obj_size={3} overhead_per_obj={4}'.format(osd_id, onodes, db_used_bytes, avg_obj_size, overhead)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For mixed (filestore / bluestore) osd-host (ignore non bluestore osds):