annotate importFromOpenMind/importer/check_ismi_log.py @ 38:9ab136f412a1

new first version of check_ismi_log analyser.
author casties
date Fri, 21 Oct 2016 19:20:17 +0200
parents
children 1867bc2180c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
1
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
2 # coding: utf-8
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
3
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
4 import re
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
5
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
6 maxLinecnt = None
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
7 #logLevels = {'INFO', 'WARNING', 'ERROR', 'SYSMSG'}
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
8 logLevels = {'ERROR', 'SYSMSG'}
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
9
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
10 def log(level, message):
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
11 if level in logLevels:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
12 print("%s: %s"%(level, message))
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
13
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
14
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
15 def prettyPrintNode(node):
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
16 nt = node['node-type']
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
17 att = ''
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
18 if nt == 'ENTITY':
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
19 att = " %s=%s "%('oc',node['object-class'])
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
20
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
21 elif nt == 'ATTRIBUTE':
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
22 att = " %s=%s "%('name',node['name'])
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
23
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
24 elif nt == 'RELATION':
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
25 att = " %s=%s "%('oc',node['object_class'])
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
26
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
27 s = "%s%s[%s]"%(nt, att, node)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
28 return s
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
29
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
30
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
31 def parseStart(line):
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
32 tstamp = None
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
33 tm = re.match('(\d+-\d+-\d+ \d+:\d+:\d+)', line)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
34 if tm:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
35 tstamp = tm.group(1)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
36
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
37 sm = re.search('START Saving (\w+) \[ID=(\d*)', line)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
38 if sm:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
39 return {'time': tstamp, 'oc': sm.group(1), 'id': sm.group(2)}
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
40
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
41 return None
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
42
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
43
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
44 def parseSave(line):
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
45 match = re.search('([A-Z]+)\[([^\]]+)\]', line)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
46 if match:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
47 data = {'node-type': match.group(1)}
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
48 segs = match.group(2).split(', ')
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
49 for seg in segs:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
50 k, v = seg.split('=', 1)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
51 data[k] = v.strip('"')
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
52
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
53 return data
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
54
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
55 return None
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
56
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
57
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
58 def equalNodes(prev, cur):
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
59 log("DEBUG", "compare: %s vs %s"%(prev, cur))
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
60 if prev['id'] != cur['id']:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
61 log("INFO", "node id mismatch!")
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
62 return False
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
63
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
64 if prev['node-type'] != cur['node-type']:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
65 log("INFO", "node node-type mismatch!")
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
66 return False
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
67
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
68 if prev.get('source-id', None) != cur.get('source-id', None):
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
69 log("INFO", "node source_id mismatch!")
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
70 return False
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
71
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
72 if prev.get('target-id', None) != cur.get('target-id', None):
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
73 log("INFO", "node target_id mismatch!")
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
74 return False
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
75
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
76 if prev['b64-value'] != cur['b64-value']:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
77 log("INFO", "node ownvalue mismatch!")
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
78 return False
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
79
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
80 return True
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
81
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
82
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
83 def getSimilarNode(prev, curList):
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
84 nt = prev['node-type']
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
85 if nt == 'ATTRIBUTE':
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
86 for n in curList:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
87 if n['node-type'] == 'ATTRIBUTE' \
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
88 and prev['name'] == n['name']:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
89 # attribute with same name
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
90 log("DEBUG", "similar attributes: %s vs %s"%(prev, n))
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
91 return n
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
92
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
93 elif nt == 'RELATION':
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
94 for n in curList:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
95 if n['node-type'] == 'RELATION' \
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
96 and prev['source-id'] == n['source-id'] \
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
97 and prev['target-id'] == n['target-id'] \
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
98 and prev['object_class'] == n['object_class']:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
99 # relation with same source, target and type
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
100 log("DEBUG", "similar relations: %s vs %s"%(prev, n))
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
101 return n
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
102
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
103 return None
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
104
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
105
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
106 def compareNodeLists(prev, cur, ctx):
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
107 prevNodes = {}
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
108 curNodes = {}
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
109
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
110 #
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
111 # read nodes
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
112 #
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
113 for n in prev:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
114 nid = n['id']
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
115 if nid not in prevNodes:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
116 prevNodes[nid] = n
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
117 else:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
118 log("DEBUG", "duplicate save of prev node id="+nid)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
119 if isinstance(prevNodes[nid], list):
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
120 prevNodes[nid].append(n)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
121 else:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
122 prevNodes[nid] = [prevNodes[nid], n]
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
123
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
124 for n in cur:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
125 nid = n['id']
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
126 if nid not in curNodes:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
127 curNodes[nid] = n
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
128 else:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
129 log("DEBUG", "duplicate save of cur node id="+nid)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
130 if isinstance(curNodes[nid], list):
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
131 curNodes[nid].append(n)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
132 else:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
133 curNodes[nid] = [curNodes[nid], n]
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
134
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
135 #
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
136 # compare nodes
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
137 #
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
138 curNodeUnchecked = set(curNodes.keys())
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
139 addPrevNodes = []
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
140 addCurNodes = []
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
141
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
142 for nid in prevNodes:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
143 prevNode = prevNodes[nid]
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
144 if isinstance(prevNode, list):
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
145 log("DEBUG", "multi-save prev node: %s"%prevNode)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
146 # use the last version(?)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
147 prevNode = prevNode[-1]
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
148
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
149 if nid not in curNodes:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
150 if prevNode['node-type'] == 'ATTRIBUTE' and prevNode['b64-value'] == '':
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
151 # emtpy attribute - ignore
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
152 continue
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
153
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
154 else:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
155 log("DEBUG", "node %s not in cur saves! %s"%(nid,prevNode))
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
156 addPrevNodes.append(prevNode)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
157 continue
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
158
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
159 curNode = curNodes[nid]
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
160 if isinstance(curNode, list):
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
161 log("DEBUG", "multi-save cur node: %s"%curNode)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
162 # use the last version?
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
163 curNode = curNode[-1]
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
164
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
165 equalNodes(prevNode, curNode)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
166
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
167 curNodeUnchecked.remove(nid)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
168
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
169 # make list of additional current (=new) nodes
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
170 for nid in curNodeUnchecked:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
171 addCurNodes.append(curNodes[nid])
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
172 log("DEBUG", "new node %s"%curNodes[nid])
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
173
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
174 # compare missing and new nodes
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
175 for n in addPrevNodes.copy():
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
176 sn = getSimilarNode(n, addCurNodes)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
177 if sn is not None:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
178 # similar is good enough
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
179 addPrevNodes.remove(n)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
180 addCurNodes.remove(sn)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
181
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
182 if len(addPrevNodes) > 0:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
183 #print("ERROR: lost nodes: %s"%[prettyPrintNode(n) for n in addPrevNodes])
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
184 log("ERROR", "in %s"%ctx)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
185 for n in addPrevNodes:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
186 log("ERROR","lost node: %s"%prettyPrintNode(n))
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
187
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
188 if len(addCurNodes) > 0:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
189 #print("INFO: new nodes: %s"%[prettyPrintNode(n) for n in addCurNodes])
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
190 for n in addCurNodes:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
191 log("INFO", "new node: %s"%prettyPrintNode(n))
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
192
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
193
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
194
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
195 def analyseLogfile(filename):
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
196 with open(filename) as f:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
197 saving = 0
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
198 linecnt = 0
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
199 saveCtx = None
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
200 prevSaves = []
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
201 saves = []
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
202
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
203 for line in f:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
204 linecnt += 1
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
205 if '*************** START Saving' in line:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
206 saving += 1
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
207 log('DEBUG', line)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
208 saveCtx = parseStart(line)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
209
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
210 if saving > 1:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
211 log("ERROR", "Concurrent save (%s) in #%s of %s"%(saving, linecnt, line))
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
212 # TODO: what now?
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
213
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
214 elif 'INFO transactionlog' in line:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
215 if 'save previous' in line:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
216 data = parseSave(line)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
217 if data is None:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
218 log("DEBUG", "Error parsing line: %s"%line)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
219 continue
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
220
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
221 prevSaves.append(data)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
222
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
223 elif 'save' in line:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
224 data = parseSave(line)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
225 if data is None:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
226 log("DEBUG", "Error parsing line: %s"%line)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
227 continue
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
228
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
229 saves.append(parseSave(line))
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
230
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
231 elif '*************** END Saving' in line:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
232 saving -= 1
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
233 log('DEBUG', line)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
234
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
235 if saving > 0:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
236 log("ERROR", "Concurrent end save (%s) in #%s of %s"%(saving, linecnt, line))
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
237
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
238 elif saving < 0:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
239 log("ERROR", "Too many END saves!")
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
240 break
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
241
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
242 log("INFO", "saving %s"%saveCtx)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
243 log("INFO", "prev saves: %s"%len(prevSaves))
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
244 log("INFO", "saves: %s"%len(saves))
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
245
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
246 if len(prevSaves) > 0:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
247 compareNodeLists(prevSaves, saves, saveCtx)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
248
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
249 prevSaves = []
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
250 saves = []
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
251
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
252
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
253 if maxLinecnt is not None and linecnt >= maxLinecnt:
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
254 break
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
255
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
256 log("SYSMSG", "%s lines of logfile scanned"%linecnt)
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
257
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
258
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
259 # run analysis
9ab136f412a1 new first version of check_ismi_log analyser.
casties
parents:
diff changeset
260 analyseLogfile('ismi-161011.log')