add parsers for memory info and system info
[logparse.git] / logparse / parsers / cron.py
index 3aba1408624e6eb7b59bcef80fcef26bcca3b20e..01a6135f35c27015f4e175db5068e81a9dafeedd 100644 (file)
@@ -24,12 +24,16 @@ def parse_log():
     # commands.append([str(match)for match in matches])
     #logger.debug("found cron command " + str(commands))
     logger.info("Found " + str(num) + " cron jobs")
-    subtitle = str(num) + " cron jobs run"
-    section.add_data(Data(subtitle))
+    jobs_data = Data(str(num) + " cron jobs run")
+    section.append_data(jobs_data)
+
     if (len(matches) > 0):
-        commands = ("`{0}`".format(x) for x in commands)
-        commands = orderbyfreq(list(commands))
-        commands = truncl(commands, config.prefs['maxcmd'])
-        section.add_data(Data("top cron commands", commands))
+        logger.debug("Analysing cron commands")
+        cmd_data = Data("Top cron commands")
+        cmd_data.items = ("`{0}`".format(x) for x in commands)
+        cmd_data.orderbyfreq()
+        cmd_data.truncl(config.prefs['maxcmd'])
+        section.append_data(cmd_data)
+
     logger.info("Finished cron section")
     return section