import operator
import rados
from threading import Event
-from datetime import datetime, timedelta, date, time
+from datetime import datetime, timedelta
TIME_FORMAT = '%Y%m%d-%H%M%S'
DEVICE_HEALTH_TOOMANY: 'Too many daemons are expected to fail soon',
}
-MAX_SAMPLES=500
+MAX_SAMPLES = 500
class Module(MgrModule):
self.has_device_pool = False
def is_valid_daemon_name(self, who):
- l = who.split('.')
- if len(l) != 2:
+ parts = who.split('.')
+ if len(parts) != 2:
return False
- if l[0] not in ('osd', 'mon'):
- return False;
- return True;
+ return parts[0] in ('osd', 'mon')
def handle_command(self, _, cmd):
self.log.error("handle_command")
self.log.debug(' %s = %s', opt['name'], getattr(self, opt['name']))
def notify(self, notify_type, notify_id):
- # create device_health_metrics pool if it doesn't exist
- if notify_type == "osd_map" and self.enable_monitoring:
+ # create device_health_metrics pool if it doesn't exist
+ if notify_type == "osd_map" and self.enable_monitoring:
if not self.has_device_pool:
self.create_device_pool()
self.has_device_pool = True
if ls:
try:
last_scrape = datetime.strptime(ls, TIME_FORMAT)
- except ValueError as e:
+ except ValueError:
pass
self.log.debug('Last scrape %s', last_scrape)
erase = []
try:
with rados.ReadOpCtx() as op:
- omap_iter, ret = ioctx.get_omap_keys(op, "", MAX_SAMPLES) # fixme
+ # FIXME
+ omap_iter, ret = ioctx.get_omap_keys(op, "", MAX_SAMPLES)
assert ret == 0
ioctx.operate_read_op(op, devid)
for key, _ in list(omap_iter):
}), '')
r, outb, outs = result.wait()
if r != 0:
- self.log.warning('Could not mark OSD %s out. r: [%s], outb: [%s], outs: [%s]' % (osd_ids, r, outb, outs))
+ self.log.warning('Could not mark OSD %s out. r: [%s], outb: [%s], outs: [%s]',
+ osd_ids, r, outb, outs)
for osd_id in osd_ids:
result = CommandResult('')
self.send_command(result, 'mon', '', json.dumps({
}), '')
r, outb, outs = result.wait()
if r != 0:
- self.log.warning('Could not set osd.%s primary-affinity, r: [%s], outs: [%s]' % (osd_id, r, outb, outs))
+ self.log.warning('Could not set osd.%s primary-affinity, '
+ 'r: [%s], outb: [%s], outs: [%s]',
+ osd_id, r, outb, outs)
def extract_smart_features(self, raw):
# FIXME: extract and normalize raw smartctl --json output and