def gauge_stats(osd, osd_spec): for stat in [ 'osd.op_w', 'osd.op_in_bytes', 'osd.op_r', 'osd.op_out_bytes' ]: prop = stat.split('.')[1] rates = CephService.get_rates('osd', osd_spec, stat) osd['stats'][prop] = get_most_recent_rate(rates) osd['stats_history'][prop] = rates # Gauge stats for stat in ['osd.numpg', 'osd.stat_bytes', 'osd.stat_bytes_used']: osd['stats'][stat.split('.')[1]] = mgr.get_latest( 'osd', osd_spec, stat)
def list(self): osds = self.get_osd_map() # Extending by osd stats information for stat in mgr.get('osd_stats')['osd_stats']: if stat['osd'] in osds: osds[stat['osd']]['osd_stats'] = stat # Extending by osd node information nodes = mgr.get('osd_map_tree')['nodes'] for node in nodes: if node['type'] == 'osd' and node['id'] in osds: osds[node['id']]['tree'] = node # Extending by osd parent node information for host in [n for n in nodes if n['type'] == 'host']: for osd_id in host['children']: if osd_id >= 0 and osd_id in osds: osds[osd_id]['host'] = host removing_osd_ids = self.get_removing_osds() # Extending by osd histogram and orchestrator data for osd_id, osd in osds.items(): osd['stats'] = {} osd['stats_history'] = {} osd_spec = str(osd_id) if 'osd' not in osd: continue # pragma: no cover - simple early continue for stat in [ 'osd.op_w', 'osd.op_in_bytes', 'osd.op_r', 'osd.op_out_bytes' ]: prop = stat.split('.')[1] rates = CephService.get_rates('osd', osd_spec, stat) osd['stats'][prop] = get_most_recent_rate(rates) osd['stats_history'][prop] = rates # Gauge stats for stat in ['osd.numpg', 'osd.stat_bytes', 'osd.stat_bytes_used']: osd['stats'][stat.split('.')[1]] = mgr.get_latest( 'osd', osd_spec, stat) osd['operational_status'] = self._get_operational_status( osd_id, removing_osd_ids) return list(osds.values())
def get_pool_list_with_stats(cls, application=None): # pylint: disable=too-many-locals pools = cls.get_pool_list(application) pools_w_stats = [] pg_summary = mgr.get("pg_summary") pool_stats = mgr.get_updated_pool_stats() for pool in pools: pool['pg_status'] = pg_summary['by_pool'][pool['pool'].__str__()] stats = pool_stats[pool['pool']] s = {} for stat_name, stat_series in stats.items(): rates = get_time_series_rates(stat_series) s[stat_name] = { 'latest': stat_series[0][1], 'rate': get_most_recent_rate(rates), 'rates': rates } pool['stats'] = s pools_w_stats.append(pool) return pools_w_stats
def get_rate(cls, svc_type, svc_name, path): """returns most recent rate""" return get_most_recent_rate(cls.get_rates(svc_type, svc_name, path))
def get_iscsi_info(): daemons = {} # type: Dict[str, dict] images = {} # type: Dict[str, dict] for service in CephService.get_service_list(SERVICE_TYPE): metadata = service['metadata'] if metadata is None: continue status = service['status'] hostname = service['hostname'] daemon = daemons.get(hostname, None) if daemon is None: daemon = { 'server_hostname': hostname, 'version': metadata['ceph_version'], 'optimized_paths': 0, 'non_optimized_paths': 0 } daemons[hostname] = daemon service_id = service['id'] device_id = service_id.split(':')[-1] image = images.get(device_id) if image is None: image = { 'device_id': device_id, 'pool_name': metadata['pool_name'], 'name': metadata['image_name'], 'id': metadata.get('image_id', None), 'optimized_paths': [], 'non_optimized_paths': [] } images[device_id] = image if status.get('lock_owner', 'false') == 'true': daemon['optimized_paths'] += 1 image['optimized_paths'].append(hostname) perf_key_prefix = "librbd-{id}-{pool}-{name}.".format( id=metadata.get('image_id', ''), pool=metadata['pool_name'], name=metadata['image_name']) perf_key = "{}lock_acquired_time".format(perf_key_prefix) lock_acquired_time = (mgr.get_counter( 'tcmu-runner', service_id, perf_key)[perf_key] or [[0, 0]])[-1][1] / 1000000000 if lock_acquired_time > image.get('optimized_since', 0): image['optimized_daemon'] = hostname image['optimized_since'] = lock_acquired_time image['stats'] = {} image['stats_history'] = {} for s in ['rd', 'wr', 'rd_bytes', 'wr_bytes']: perf_key = "{}{}".format(perf_key_prefix, s) rates = CephService.get_rates('tcmu-runner', service_id, perf_key) image['stats'][s] = get_most_recent_rate(rates) image['stats_history'][s] = rates else: daemon['non_optimized_paths'] += 1 image['non_optimized_paths'].append(hostname) # clear up races w/ tcmu-runner clients that haven't detected # loss of optimized path for image in images.values(): optimized_daemon = image.get('optimized_daemon', None) if optimized_daemon: for daemon_name in image['optimized_paths']: if daemon_name != optimized_daemon: daemon = daemons[daemon_name] daemon['optimized_paths'] -= 1 daemon['non_optimized_paths'] += 1 image['non_optimized_paths'].append(daemon_name) image['optimized_paths'] = [optimized_daemon] return { 'daemons': sorted(daemons.values(), key=lambda d: d['server_hostname']), 'images': sorted(images.values(), key=lambda i: ['id']), }