Ubuntu Pastebin

Paste from daniel at Thu, 10 Nov 2016 14:17:19 +0000

Download as text
 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
diff --git a/cloudinit_analyze/dump.py b/cloudinit_analyze/dump.py
index 034ec27..a79c256 100755
--- a/cloudinit_analyze/dump.py
+++ b/cloudinit_analyze/dump.py
@@ -23,9 +23,13 @@ def parse_timestamp(timestampstr):
     # default syslog time does not include the current year
     if timestampstr.split()[0] in [calendar.month_abbr[m]
                                    for m in range(1, 13)]:
-        # Aug 29 22:55:26
+        # Aug 29 22:55:26(.789)?
+        if '.' in timestampstr:
+            dt_format = "%b %d %H:%M:%S.%f %Y"
+        else:
+            dt_format = "%b %d %H:%M:%S %Y"
         dt = datetime.strptime(timestampstr + " " + str(datetime.now().year),
-                               "%b %d %H:%M:%S %Y")
+                               dt_format)
         timestamp = dt.strftime("%s.%f")
     elif "," in timestampstr:
         # 2016-09-12 14:39:20,839
@@ -62,6 +66,9 @@ def parse_ci_logline(line):
         timestampstr += ",%s" % extra.split()[0]
         if ' ' in extra:
             hostname = extra.split()[-1]
+    elif timehost.endswith(':'):
+        # journalctl format
+        timestampstr, hostname, _ = timehost.rsplit(' ', maxsplit=2)
     else:
         hostname = timehost.split()[-1]
         timestampstr = timehost.split(hostname)[0].strip()
diff --git a/cloudinit_analyze/show.py b/cloudinit_analyze/show.py
index 0208274..37fe1af 100755
--- a/cloudinit_analyze/show.py
+++ b/cloudinit_analyze/show.py
@@ -183,7 +183,7 @@ def generate_records(events, blame_sort=False,
                 unprocessed.append(event)
                 stages_seen.append(event.get('name'))
                 continue
-        else:
+        elif unprocessed:
             prev_evt = unprocessed.pop()
             if event_name(event) == event_name(prev_evt):
                 record = event_record(start_time, prev_evt, event)
Download as text