From a24550aee4c7282cd3624bf63f9501444e517678 Mon Sep 17 00:00:00 2001 From: Sam Gilson Date: Mon, 15 Jul 2019 21:50:33 +0000 Subject: Cloud-init analyze module: Added ability to analyze boot events. This branch introduces a new command line feature for cloud-init. Currently, the cloud-init module has the capability to analyze events in cloud-init.log in three ways: 'show', 'blame', 'dump'. These changes add a fourth capability, called 'boot'. Running the command 'cloud-init analyze boot' will provide the user three timestamps. 1) Timestamp for when the kernel starts initializing. 2) Timestamp for when the kernel finishes its initialization. 3) Timestamp for when systemd activates cloud-init. This feature enables cloud-init users to analyze different boot phases. This would aid in debugging performance issues related to cloud-init startup or tracking regression. --- cloudinit/analyze/__main__.py | 88 ++++++++++++++- cloudinit/analyze/show.py | 202 +++++++++++++++++++++++++++++++++-- cloudinit/analyze/tests/test_boot.py | 170 +++++++++++++++++++++++++++++ doc/rtd/topics/analyze.rst | 84 +++++++++++++++ doc/rtd/topics/capabilities.rst | 1 + doc/rtd/topics/debugging.rst | 13 +++ 6 files changed, 546 insertions(+), 12 deletions(-) create mode 100644 cloudinit/analyze/tests/test_boot.py create mode 100644 doc/rtd/topics/analyze.rst diff --git a/cloudinit/analyze/__main__.py b/cloudinit/analyze/__main__.py index f8613656..99e5c203 100644 --- a/cloudinit/analyze/__main__.py +++ b/cloudinit/analyze/__main__.py @@ -7,7 +7,7 @@ import re import sys from cloudinit.util import json_dumps - +from datetime import datetime from . import dump from . import show @@ -52,9 +52,93 @@ def get_parser(parser=None): dest='outfile', default='-', help='specify where to write output. ') parser_dump.set_defaults(action=('dump', analyze_dump)) + parser_boot = subparsers.add_parser( + 'boot', help='Print list of boot times for kernel and cloud-init') + parser_boot.add_argument('-i', '--infile', action='store', + dest='infile', default='/var/log/cloud-init.log', + help='specify where to read input. ') + parser_boot.add_argument('-o', '--outfile', action='store', + dest='outfile', default='-', + help='specify where to write output.') + parser_boot.set_defaults(action=('boot', analyze_boot)) return parser +def analyze_boot(name, args): + """Report a list of how long different boot operations took. + + For Example: + -- Most Recent Boot Record -- + Kernel Started at: