initial version of plugin that parses log files to see number of conflicterrors
authorArthur Lutz <arthur.lutz@logilab.fr>
Mon, 30 Jun 2008 16:47:02 +0200
changeset 5 a0d3ec1dccde
parent 4 80b859422abf
child 6 98e064318246
initial version of plugin that parses log files to see number of conflicterrors
zope_conflict_errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zope_conflict_errors	Mon Jun 30 16:47:02 2008 +0200
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+
+from sys import argv
+from datetime import datetime
+import time
+
+logs = ['event.log']
+date_format = '%Y-%m-%dT%H:%M:%S'
+
+if len(argv) > 1 and argv[1] == 'config':
+
+    print """graph_title Zope Conflict Errors 
+    graph_vlabel Count 
+    graph_category Zope
+    graph_info The number of conflict errors in event logs over the past 24h""".replace("\n    ","\n")
+    for i in range(0,len(logs)):
+        print """error_count%(i)s.label %(n)s error count
+        type_count%(i)s.label %(n)s type counts
+        user_count%(i)s.label %(n)s nb of user""".replace("\n        ","\n") % dict(i=i,
+                                                                                     n=logs[i])
+else:
+    for i in range(0,len(logs)):
+        log = logs[i]
+        error_count = 0
+        for line in file(log):
+            splitted = line.split()
+            if 'ConflictError' in splitted:
+                logdate = datetime(*time.strptime(splitted[0], date_format)[:-3])
+                delta = datetime.now() - logdate
+                if delta.days >= 1:
+                    pass
+                error_count += 1 
+        id = dict(i=i)
+        print 'error_count%(i)s.value' % id, error_count
+