logger = logging.getLogger(__name__)
def parse_log():
- output = ''
+
logger.debug("Starting zfs section")
- output += opentag('div', 1, 'zfs', 'section')
+ section = Section("zfs")
+
zfslog = readlog(config.prefs['logs']['zfs'])
+
logger.debug("Analysing zpool log")
pool = re.search('.*---\n(\w*)', zfslog).group(1)
scrub = re.search('.* scrub repaired (\d+\s*\w+) in .* with (\d+) errors on (\w+)\s+(\w+)\s+(\d+)\s+(\d{1,2}:\d{2}):\d+\s+(\d{4})', zfslog)
logger.debug("Found groups {0}".format(scrub.groups()))
iostat = re.search('.*---\n\w*\s*(\S*)\s*(\S*)\s', zfslog)
scrubrepairs = scruberrors = scrubdate = None
+ alloc = iostat.group(1)
+ free = iostat.group(2)
+
try:
scrubrepairs = scrub.group(1)
scruberrors = scrub.group(2)
except Exception as e:
logger.debug("Error getting scrub data: " + str(e))
traceback.print_exc(limit=2, file=sys.stdout)
- alloc = iostat.group(1)
- free = iostat.group(2)
- output += writetitle("zfs")
+
if (scrubdate != None):
- subtitle = "Scrub of " + pool + " on " + scrubdate
- data = [scrubrepairs + " repaired", scruberrors + " errors", alloc + " used", free + " free"]
+ scrub_data = Data("Scrub of " + pool + " on " + scrubdate)
+ scrub_data.items = [scrubrepairs + " repaired", scruberrors + " errors", alloc + " used", free + " free"]
else:
- subtitle = pool
- data = [alloc + " used", free + " free"]
- output += writedata(subtitle, data)
- output += closetag('div', 1)
+ scrub_data = Data(pool)
+ scrub_data.items = [alloc + " used", free + " free"]
+
+ section.append_data(scrub_data)
+
logger.info("Finished zfs section")
- return output
+ return section