def __init__(self, fence, name, pool=None): self.fence = fence self.name = name self.pool = pool self.curkey = None self.nvme = None self.cam = None if self.name.startswith('nvd'): self.nvme = nvme.NvmeDevice(f'/dev/{name}') else: self.cam = cam.CamDevice(f'/dev/{name}')
def get_temperature(self, disk): if disk.startswith('da'): try: return cam.CamDevice(disk).get_temperature() except Exception: pass cp = subprocess.run(['/usr/local/sbin/smartctl', '-a', '-n', self.powermode, f'/dev/{disk}'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) if cp.returncode != 0: collectd.info(f'Failed to run smartctl for {disk}: {cp.stdout.decode("utf8", "ignore")}') return None stdout = cp.stdout.decode('utf8', 'ignore') return get_temperature(stdout)
async def temperature(self, name, powermode): """ Returns temperature for device `name` using specified S.M.A.R.T. `powermode`. """ if name.startswith('da'): smartctl_args = await self.middleware.call('disk.smartctl_args', name) or [] if not any(s.startswith('/dev/arcmsr') for s in smartctl_args): try: temperature = await self.middleware.run_in_thread(lambda: cam.CamDevice(name).get_temperature()) if temperature is not None: return temperature except Exception: pass output = await self.middleware.call('disk.smartctl', name, ['-a', '-n', powermode.lower()], {'silent': True}) if output is None: return None return get_temperature(output)
def __init__(self, fence, name, pool=None): self.fence = fence self.name = name self.pool = pool self.cam = cam.CamDevice(f'/dev/{name}') self.curkey = None