def refresh(self, cycle_id): self._cycle = cycle_id self.size = self._so.size stats_path = os.path.join(self._path, 'statistics/scsi_lu') self.iops = int(fread(os.path.join(stats_path, "num_cmds"))) read_mb = float(fread(os.path.join(stats_path, "read_mbytes"))) write_mb = float(fread(os.path.join(stats_path, "write_mbytes"))) self.read_bytes_per_sec = int(read_mb * 1024 ** 2) self.write_bytes_per_sec = int(write_mb * 1024 ** 2) self.total_bytes_per_sec = self.read_bytes_per_sec + \ self.write_bytes_per_sec if self._tpg_lun.alua_tg_pt_gp_name == 'ao': self.active_path = 1 else: self.active_path = 0
def get_osd_type(osd_path): osd_type_fname = os.path.join(osd_path, 'type') if os.path.exists(osd_type_fname): return fread(osd_type_fname) else: if os.path.exists(os.path.join(osd_path, 'journal')): return "filestore" else: raise ValueError("Unrecognised OSD type")
def _dev_to_osd(self): """ Look at the system to determine which disks are acting as OSD's """ # the logic here uses the mount points to determine which OSD's are # in the system. The encryption state is determine just by the use # devicemapper (i.e. /dev/mapper prefixed devices) - since at this time # this is all dm is used for. osd_indicators = {'var', 'lib', 'osd'} for mnt in freadlines('/proc/mounts'): items = mnt.split(' ') dev_path, path_name = items[:2] if path_name.startswith('/var/lib'): # take a close look since this is where ceph osds usually # get mounted dirs = set(path_name.split('/')) if dirs.issuperset(osd_indicators): # get the osd_id from the name is the most simple way # to get the id, due to naming conventions. If this fails # though, plan 'b' is the whoami file osd_id = path_name.split('-')[-1] if not osd_id.isdigit(): osd_id = fread(os.path.join(path_name, 'whoami')) if osd_id not in self.osd: osd_type = OSDs.get_osd_type(path_name) self.osd[osd_id] = OSDstats(osd_type=osd_type) self.osd_id_list.append(osd_id) osd_type = self.osd[osd_id]._osd_type if osd_type == 'filestore': if dev_path.startswith('/dev/mapper'): encrypted = 1 uuid = dev_path.split('/')[-1] partuuid = '/dev/disk/by-partuuid/{}'.format( uuid) dev_path = os.path.realpath(partuuid) osd_device = dev_path.split('/')[-1] else: encrypted = 0 osd_device = dev_path.split('/')[-1] elif osd_type == 'bluestore': block_link = os.path.join(path_name, 'block') osd_path = os.path.realpath(block_link) osd_device = osd_path.split('/')[-1] encrypted = 0 else: raise ValueError("Unknown OSD type encountered") # if the osd_id hasn't been seem neither has the # disk self.osd[osd_device] = Disk(osd_device, path_name=path_name, osd_id=osd_id, in_osd_type=osd_type, encrypted=encrypted) self.dev_lookup[osd_device] = 'osd' self.osd_count += 1 if osd_type == 'filestore': journal_link = os.path.join(path_name, 'journal') else: journal_link = os.path.join(path_name, 'block.wal') if os.path.exists(journal_link): link_tgt = os.readlink(journal_link) if link_tgt.startswith('/dev/mapper'): encrypted = 1 else: encrypted = 0 partuuid_path = os.path.join( '/dev/disk/by-partuuid', link_tgt.split('/')[-1]) jrnl_path = os.path.realpath(partuuid_path) jrnl_dev = jrnl_path.split('/')[-1] if jrnl_dev not in self.osd: self.jrnl[jrnl_dev] = Disk( jrnl_dev, osd_id=osd_id, in_osd_type=osd_type, encrypted=encrypted) self.dev_lookup[jrnl_dev] = 'jrnl' else: # No journal or WAL link..? pass