mirror of
https://github.com/ceph/ceph
synced 2025-01-21 02:31:19 +00:00
Merge pull request #1651 from enovance/wip-brag
Few bug fixes in ceph-brag Reviewed-by: Sage Weil <sage@inktank.com>
This commit is contained in:
commit
6230146238
@ -24,7 +24,8 @@ Run 'ceph-brag -h' to get the usage information of this tool.
|
|||||||
"cluster_creation_date": "2014-01-16 13:38:41.928551",
|
"cluster_creation_date": "2014-01-16 13:38:41.928551",
|
||||||
"uuid": "20679d0e-04b1-4004-8ee9-45ac271510e9",
|
"uuid": "20679d0e-04b1-4004-8ee9-45ac271510e9",
|
||||||
"components_count": {
|
"components_count": {
|
||||||
"num_bytes": 0,
|
"num_data_bytes": 0,
|
||||||
|
"num_bytes_total": 1209312904,
|
||||||
"num_osds": 1,
|
"num_osds": 1,
|
||||||
"num_objects": 0,
|
"num_objects": 0,
|
||||||
"num_pgs": 192,
|
"num_pgs": 192,
|
||||||
|
@ -30,14 +30,6 @@ def get_uuid():
|
|||||||
|
|
||||||
return uid
|
return uid
|
||||||
|
|
||||||
def get_cluster_creation_date():
|
|
||||||
(rc, o, e) = run_command(['ceph', 'mon', 'dump', '-f', 'json'])
|
|
||||||
if rc is not 0:
|
|
||||||
raise RuntimeError("\'ceph mon dump\' failed - " + e)
|
|
||||||
|
|
||||||
oj = json.loads(o)
|
|
||||||
return oj['created']
|
|
||||||
|
|
||||||
def bytes_pretty_to_raw(byte_count, byte_scale):
|
def bytes_pretty_to_raw(byte_count, byte_scale):
|
||||||
if byte_scale == 'kB':
|
if byte_scale == 'kB':
|
||||||
return byte_count >> 10
|
return byte_count >> 10
|
||||||
@ -66,7 +58,8 @@ def get_nums():
|
|||||||
|
|
||||||
pgmap = oj['pgmap']
|
pgmap = oj['pgmap']
|
||||||
num_pgs = pgmap['num_pgs']
|
num_pgs = pgmap['num_pgs']
|
||||||
num_bytes = pgmap['data_bytes']
|
num_data_bytes = pgmap['data_bytes']
|
||||||
|
num_bytes_total = pgmap['bytes_total']
|
||||||
|
|
||||||
(rc, o, e) = run_command(['ceph', 'pg', 'dump', 'pools', '-f', 'json-pretty'])
|
(rc, o, e) = run_command(['ceph', 'pg', 'dump', 'pools', '-f', 'json-pretty'])
|
||||||
if rc is not 0:
|
if rc is not 0:
|
||||||
@ -82,7 +75,8 @@ def get_nums():
|
|||||||
'num_osds':num_osds,
|
'num_osds':num_osds,
|
||||||
'num_mdss':num_mdss,
|
'num_mdss':num_mdss,
|
||||||
'num_pgs':num_pgs,
|
'num_pgs':num_pgs,
|
||||||
'num_bytes':num_bytes,
|
'num_data_bytes':num_data_bytes,
|
||||||
|
'num_bytes_total':num_bytes_total,
|
||||||
'num_pools':num_pools,
|
'num_pools':num_pools,
|
||||||
'num_objects':num_objs}
|
'num_objects':num_objs}
|
||||||
return nums
|
return nums
|
||||||
@ -100,31 +94,23 @@ def get_crush_types():
|
|||||||
for t in crush_dump['types']:
|
for t in crush_dump['types']:
|
||||||
crush_types[t['type_id']] = t['name']
|
crush_types[t['type_id']] = t['name']
|
||||||
|
|
||||||
buckets = {}
|
types_list = []
|
||||||
items_list = []
|
|
||||||
for bucket in crush_dump['buckets']:
|
for bucket in crush_dump['buckets']:
|
||||||
buckets[bucket['id']] = bucket['type_id']
|
types_list.append(bucket['type_id'])
|
||||||
for item in bucket['items']:
|
|
||||||
items_list.append(item['id'])
|
|
||||||
|
|
||||||
crush_map = []
|
crush_map = []
|
||||||
counter = Counter(items_list)
|
types_counter = Counter(types_list)
|
||||||
append = lambda t,c: crush_map.append({'type':t, 'count':c})
|
append = lambda t,c: crush_map.append({'type':t, 'count':c})
|
||||||
for id,count in counter.items():
|
for id,count in types_counter.items():
|
||||||
if id in buckets:
|
append(crush_types[id],
|
||||||
append(crush_types[buckets[id]],
|
|
||||||
count)
|
count)
|
||||||
del buckets[id]
|
|
||||||
else:
|
|
||||||
append(crush_types[id], count)
|
|
||||||
|
|
||||||
#the root item
|
if 'devices' in crush_dump:
|
||||||
for id,type_id in buckets.items():
|
append('devices', len(crush_dump['devices']))
|
||||||
append(crush_types[type_id], 1)
|
|
||||||
|
|
||||||
return crush_map
|
return crush_map
|
||||||
|
|
||||||
def get_pool_metadata():
|
def get_osd_dump_info():
|
||||||
(rc, o, e) = run_command(['ceph', 'osd', 'dump', '-f', 'json'])
|
(rc, o, e) = run_command(['ceph', 'osd', 'dump', '-f', 'json'])
|
||||||
if rc is not 0:
|
if rc is not 0:
|
||||||
raise RuntimeError("\'ceph osd dump\' failed - " + e)
|
raise RuntimeError("\'ceph osd dump\' failed - " + e)
|
||||||
@ -135,7 +121,7 @@ def get_pool_metadata():
|
|||||||
for p in oj['pools']:
|
for p in oj['pools']:
|
||||||
pool_meta.append(proc(p))
|
pool_meta.append(proc(p))
|
||||||
|
|
||||||
return pool_meta
|
return oj['created'], pool_meta
|
||||||
|
|
||||||
def get_sysinfo(max_osds):
|
def get_sysinfo(max_osds):
|
||||||
count = 0
|
count = 0
|
||||||
@ -218,12 +204,11 @@ def output_json():
|
|||||||
url = None
|
url = None
|
||||||
|
|
||||||
out['uuid'] = get_uuid()
|
out['uuid'] = get_uuid()
|
||||||
out['cluster_creation_date'] = get_cluster_creation_date()
|
|
||||||
nums = get_nums()
|
nums = get_nums()
|
||||||
num_osds = int(nums['num_osds'])
|
num_osds = int(nums['num_osds'])
|
||||||
out['components_count'] = nums
|
out['components_count'] = nums
|
||||||
out['crush_types'] = get_crush_types()
|
out['crush_types'] = get_crush_types()
|
||||||
out['pool_metadata'] = get_pool_metadata()
|
out['cluster_creation_date'], out['pool_metadata'] = get_osd_dump_info()
|
||||||
out['sysinfo'] = get_sysinfo(num_osds)
|
out['sysinfo'] = get_sysinfo(num_osds)
|
||||||
|
|
||||||
owner = get_ownership_info()
|
owner = get_ownership_info()
|
||||||
|
@ -22,7 +22,8 @@ def jsonify_cluster_info(ci):
|
|||||||
@jsonify.register(db.components_info)
|
@jsonify.register(db.components_info)
|
||||||
def jsonify_components_info(comps):
|
def jsonify_components_info(comps):
|
||||||
return dict(
|
return dict(
|
||||||
num_bytes=comps.num_bytes,
|
num_data_bytes=comps.num_data_bytes,
|
||||||
|
num_bytes_total=comps.num_bytes_total,
|
||||||
num_osds=comps.num_osds,
|
num_osds=comps.num_osds,
|
||||||
num_objects=comps.num_objects,
|
num_objects=comps.num_objects,
|
||||||
num_pgs=comps.num_pgs,
|
num_pgs=comps.num_pgs,
|
||||||
|
@ -35,7 +35,8 @@ class components_info(Base):
|
|||||||
|
|
||||||
index = Column(Integer, primary_key=True)
|
index = Column(Integer, primary_key=True)
|
||||||
vid = Column(ForeignKey('version_info.index'))
|
vid = Column(ForeignKey('version_info.index'))
|
||||||
num_bytes = Column(BigInteger)
|
num_data_bytes = Column(BigInteger)
|
||||||
|
num_bytes_total = Column(BigInteger)
|
||||||
num_osds = Column(Integer)
|
num_osds = Column(Integer)
|
||||||
num_objects = Column(Integer)
|
num_objects = Column(Integer)
|
||||||
num_pgs = Column(Integer)
|
num_pgs = Column(Integer)
|
||||||
@ -168,7 +169,8 @@ def put_new_version(data):
|
|||||||
def add_components_info(vi):
|
def add_components_info(vi):
|
||||||
comps_count= info['components_count']
|
comps_count= info['components_count']
|
||||||
comps_info = components_info(vid=vi.index,
|
comps_info = components_info(vid=vi.index,
|
||||||
num_bytes=comps_count['num_bytes'],
|
num_data_bytes=comps_count['num_data_bytes'],
|
||||||
|
num_bytes_total=comps_count['num_bytes_total'],
|
||||||
num_osds=comps_count['num_osds'],
|
num_osds=comps_count['num_osds'],
|
||||||
num_objects=comps_count['num_objects'],
|
num_objects=comps_count['num_objects'],
|
||||||
num_pgs=comps_count['num_pgs'],
|
num_pgs=comps_count['num_pgs'],
|
||||||
|
Loading…
Reference in New Issue
Block a user