-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloud.py
More file actions
43 lines (34 loc) · 927 Bytes
/
cloud.py
File metadata and controls
43 lines (34 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from lex import log
def process(text):
# 'ssh klatu tail -f /tmp/cloud_graphs.log'
if text.startswith("Error "):
return None
if text.startswith("connection failed"):
return None
dt, tt, line = text.split(' ', 2)
if line.startswith("No fields for "):
return None
if line.startswith('Drop'):
code, line = line.split(' ', 1)
elif line.startswith('TX'):
code, line = line.split(' ', 1)
elif line.startswith('No change'):
size = len('No change')
code, line = line[:size], line[size:]
elif " None " in line:
return None
else:
log("Malformed line?", `line`)
return None
dev, line = line.split(' ', 1)
d = {
'type' : 'cloudgraph',
'date' : dt,
'time' : tt,
'code' : code,
'dev' : dev,
'msg' : line,
'whole' : text,
}
return d
# FIN