This commit is contained in:
brent s 2017-10-09 14:45:37 -04:00
parent 7786f0f49d
commit 300beededb

View File

@ -32,18 +32,19 @@ def getDisks():
return(disks) return(disks)


def chkDisk(disk): def chkDisk(disk):
d = disk.replace('/', '.') d = '.'.join(os.path.split(disk)[1:])
if os.path.isfile('/var/log/badblocks.{0}.log'.format(d)): os.makedirs('/var/log/badblocks', exist_ok = True)
if os.path.isfile('/var/log/badblocks/{0}.log'.format(d)):
# for some reason this file was just created within the past 24 hours, # for some reason this file was just created within the past 24 hours,
# so we better play it safe and write to a different log file # so we better play it safe and write to a different log file
now = datetime.datetime.now() now = datetime.datetime.now()
modified = datetime.datetime.fromtimestamp(os.path.getmtime('/var/log/badblocks.{0}.log'.format(d))) modified = datetime.datetime.fromtimestamp(os.path.getmtime('/var/log/badblocks/{0}.log'.format(d)))
diff = now - modified diff = now - modified
timedelta = datetime.timedelta(days = 1) timedelta = datetime.timedelta(days = 1)
if not diff >= timedelta: if not diff >= timedelta:
d += '_secondary' d += '_secondary'
bb = ['badblocks', bb = ['badblocks',
'-o /var/log/badblocks.{0}.log'.format(d), '-o /var/log/badblocks/{0}.log'.format(d),
disk] disk]
smctl = ['smartctl', smctl = ['smartctl',
'-t long', '-t long',