�
܍~c% � � � d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZmZ d dl m
Z
dd�Zd� Zd� Z
d � Zd
� Zd� Zd� Zd
eddfd�Zedk r6 e� � Ze� � � Zej \ ZZ eee� � dS dS )� N)�datetime)�IO)�dump�show)�
json_dumpsc � � | st j dd�� � } | � dd�� � }d|_ |� dd �
� � }|� ddd
ddd�� � |� ddd
ddd�� � |� dt f�� � |� dd�
� � }|� ddd
ddd�� � |� ddd
ddd�� � |� ddd
ddd�� � |� dt f�� � |� d d!�
� � }|� ddd
ddd"�� � |� ddd
ddd�� � |� d t f�� � |� d#d$�
� � }|� ddd
ddd"�� � |� ddd
ddd�� � |� d#t f�� � | S )%Nzcloudinit-analyzez,Devel tool: Analyze cloud-init logs and data)�prog�description�Subcommands�
subcommand)�title�destT�blamez5Print list of executed stages ordered by time to init)�helpz-iz--infile�store�infilez/var/log/cloud-init.logzspecify where to read input.)�actionr �defaultr z-oz --outfile�outfile�-zspecify where to write output. )r r z.Print list of in-order events during executionz-fz--format�print_formatz%I%D @%Es +%dszspecify formatting of output.zspecify where to write output.r z%Dump cloud-init events in JSON formatzspecify where to read input. �bootz2Print list of boot times for kernel and cloud-init)�argparse�ArgumentParser�add_subparsers�required�
add_parser�add_argument�set_defaults�
analyze_blame�analyze_show�analyze_dump�analyze_boot)�parser�
subparsers�parser_blame�parser_show�parser_dump�parser_boots �</usr/lib/python3/dist-packages/cloudinit/analyze/__main__.py�
get_parserr+ s� � ��
��(�$�F�
�
�
�� �&�&�]��&�N�N�J��J���(�(��M� )� � �L� ������
�)�
+�
� � � � ������
��
.�
� � � � ���g�}�%=��>�>�>��'�'��E� (� � �K� ������
� �
,�
� � � � ������
�)�
+�
� � � � ������
��
-�
� � � � ���V�\�$:��;�;�;��'�'��<� (� � �K� ������
�)�
,�
� � � � ������
��
.�
� � � � ���V�\�$:��;�;�;��'�'��I� (� � �K� ������
�)�
,�
� � � � ������
��
-�
� � � � ���V�\�$:��;�;�;��M� c
�x � t |� � \ }}t j � � }|\ }}}}t j |� � } t j |� � }
t j |� � } d� t |� � D � � d }t j |d � � }
n# t $ r d}
t j }Y nw xY wd}d}d}t j |t j |t j |i}||z
}||z
}| |
|||||||
d� }|�
|| j d i |��� � t ||� � |S )
a� Report a list of how long different boot operations took.
For Example:
-- Most Recent Boot Record --
Kernel Started at: <time>
Kernel ended boot at: <time>
Kernel time to boot (seconds): <time>
Cloud-init activated by systemd at: <time>
Time between Kernel end boot and Cloud-init activation (seconds):<time>
Cloud-init start: <time>
c �> |