summaryrefslogtreecommitdiff
path: root/cloudinit/analyze/dump.py
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2020-05-06 13:17:37 -0400
committerGitHub <noreply@github.com>2020-05-06 13:17:37 -0400
commit73d8748e797134fa0a06415b6cb16be2e05abc7e (patch)
tree3f92d81cfa44f84923628c502a1dfd7fbe9c04f0 /cloudinit/analyze/dump.py
parentf9b393bb4f15258de230884949e543e0f62f9abb (diff)
downloadvyos-cloud-init-73d8748e797134fa0a06415b6cb16be2e05abc7e.tar.gz
vyos-cloud-init-73d8748e797134fa0a06415b6cb16be2e05abc7e.zip
analyze/dump: add support for Amazon Linux 2 log lines (#346)
Amazon Linux 2 is configured with a log format different to the one shipped by upstream, which means analyze fails to parse any of the log lines. This updates the code to know how to parse such lines. LP: #1876323
Diffstat (limited to 'cloudinit/analyze/dump.py')
-rw-r--r--cloudinit/analyze/dump.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/cloudinit/analyze/dump.py b/cloudinit/analyze/dump.py
index 1f3060d0..f5762854 100644
--- a/cloudinit/analyze/dump.py
+++ b/cloudinit/analyze/dump.py
@@ -74,8 +74,11 @@ def parse_ci_logline(line):
#
# 2017-05-22 18:02:01,088 - util.py[DEBUG]: Cloud-init v. 0.7.9 running \
# 'init-local' at Mon, 22 May 2017 18:02:01 +0000. Up 2.0 seconds.
+ #
+ # Apr 30 19:39:11 cloud-init[2673]: handlers.py[DEBUG]: start: \
+ # init-local/check-cache: attempting to read from cache [check]
- separators = [' - ', ' [CLOUDINIT] ']
+ separators = [' - ', ' [CLOUDINIT] ', ' cloud-init[']
found = False
for sep in separators:
if sep in line:
@@ -98,7 +101,14 @@ def parse_ci_logline(line):
hostname = extra.split()[-1]
else:
hostname = timehost.split()[-1]
- timestampstr = timehost.split(hostname)[0].strip()
+ if sep == ' cloud-init[':
+ # This is an Amazon Linux style line, with no hostname and a PID.
+ # Use the whole of timehost as timestampstr, and strip off the PID
+ # from the start of eventstr.
+ timestampstr = timehost.strip()
+ eventstr = eventstr.split(maxsplit=1)[1]
+ else:
+ timestampstr = timehost.split(hostname)[0].strip()
if 'Cloud-init v.' in eventstr:
event_type = 'start'
if 'running' in eventstr: