404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.147.127.54: ~ $
3

\�me%�@s�ddlZddlZddlZddlmZddlmZddlmZmZddl	m
Z
ddd�Zdd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�Zedd�dd�Zedkr�e�Zej�Zej\ZZeee�dS)�N)�datetime)�IO)�dump�show)�
json_dumpscCsh|stjddd�}|jddd�}d|_|jdd	d
�}|jddd
dddd�|jddd
dddd�|jdtfd�|jddd
�}|jddd
dddd�|jddd
dddd�|jddd
dddd�|jdtfd�|jd d!d
�}|jddd
ddd"d�|jddd
dddd�|jd t	fd�|jd#d$d
�}|jddd
ddd"d�|jddd
dddd�|jd#t
fd�|S)%Nzcloudinit-analyzez,Devel tool: Analyze cloud-init logs and data)�prog�descriptionZSubcommandsZ
subcommand)�title�destTZblamez5Print list of executed stages ordered by time to init)�helpz-iz--infileZstore�infilez/var/log/cloud-init.logzspecify where to read input.)�actionr
�defaultrz-oz	--outfile�outfile�-zspecify where to write output. )r
rz.Print list of in-order events during executionz-fz--format�print_formatz%I%D @%Es +%dszspecify formatting of output.zspecify where to write output.rz%Dump cloud-init events in JSON formatzspecify where to read input. Zbootz2Print list of boot times for kernel and cloud-init)�argparse�ArgumentParserZadd_subparsersZrequiredZ
add_parser�add_argumentZset_defaults�
analyze_blame�analyze_show�analyze_dump�analyze_boot)�parserZ
subparsersZparser_blameZparser_showZparser_dumpZparser_boot�r�/usr/lib/python3.6/__init__.py�
get_parsers�



rcCs�t|�\}}tj�}|\}}}}tj|�}	tj|�}
tj|�}y(dd�t|�D�d
}tj|d�}
Wntk
r�d}
tj}YnXd}d}d}tj|tj|tj	|i}||}||}|	|
|||||||
d	�	}|j
||jf|��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>
    cSs(g|] }|ddkrd|dkr|�qS)�namez
init-localzstarting searchrr)�.0�errr�
<listcomp>�sz analyze_boot.<locals>.<listcomp>�Z	timestampz4Could not find init-local log-line in cloud-init.logz�Your Linux distro or container does not support this functionality.
You must be running a Kernel Telemetry supported distro.
Please check https://cloudinit.readthedocs.io/en/latest/topics/analyze.html for more information on supported distros.
a*-- Most Recent Boot Record --
    Kernel Started at: {k_s_t}
    Kernel ended boot at: {k_e_t}
    Kernel time to boot (seconds): {k_r}
    Cloud-init activated by systemd at: {ci_sysd_t}
    Time between Kernel end boot and Cloud-init activation (seconds): {bt_r}
    Cloud-init start: {ci_start}
z�-- Most Recent Container Boot Record --
    Container started at: {k_s_t}
    Cloud-init activated by systemd at: {ci_sysd_t}
    Cloud-init start: {ci_start}
)	Zk_s_tZk_e_tZk_rZbt_rZk_eZk_sZci_sysdZ	ci_sysd_t�ci_start���)
�configure_iorZdist_check_timestamprZutcfromtimestamp�_get_events�
IndexErrorZ	FAIL_CODEZCONTAINER_CODEZSUCCESS_CODE�write�format�clean_io)r�args�infh�outfhZkernel_infoZstatus_codeZkernel_startZ
kernel_endZ
ci_sysd_startZkernel_start_timestampZkernel_end_timestampZci_sysd_start_timestampZlast_init_localr"ZFAILURE_MSGZSUCCESS_MSGZ
CONTAINER_MSGZ
status_mapZkernel_runtimeZbetween_process_runtime�kwargsrrrrtsD






rc	Cs�t|�\}}d}tjdtj�}d}xdttjt|�|��D]L\}}tt	|j
|�dd�}|jd|d�|jdj|�d�|jd�q8W|jd	|d�t
||�d
S)azReport a list of records sorted by largest time delta.

    For example:
      30.210s (init-local) searching for datasource
       8.706s (init-network) reading and applying user-data
        166ms (modules-config) ....
        807us (modules-final) ...

    We generate event records parsing cloud-init logs, formatting the output
    and sorting by record data ('delta')
    z
     %ds (%n)z(^\s+\d+\.\d+)rT)�reversez-- Boot Record %02d --
r!�
z%d boot records analyzed
N)r$�re�compile�	MULTILINE�	enumerater�show_eventsr%�sorted�filter�matchr'�joinr))	rr*r+r,Zblame_format�r�idx�recordZsrecsrrrr�srcCs�t|�\}}x\ttjt|�|j��D]B\}}|jd|d�|jd�|jd�|jdj|�d�q$W|jd|d�t||�dS)aGenerate output records using the 'standard' format to printing events.

    Example output follows:
        Starting stage: (init-local)
          ...
        Finished stage: (init-local) 0.105195 seconds

        Starting stage: (init-network)
          ...
        Finished stage: (init-network) 0.339024 seconds

        Starting stage: (modules-config)
          ...
        Finished stage: (modules-config) 0.NNN seconds

        Starting stage: (modules-final)
          ...
        Finished stage: (modules-final) 0.NNN seconds
    z-- Boot Record %02d --
r!zUThe total time elapsed since completing an event is printed after the "@" character.
z>The time the event takes is printed after the "+" character.

r/z%d boot records analyzed
N)	r$r3rr4r%rr'r8r))rr*r+r,r:r;rrrr�srcCs0t|�\}}|jtt|��d�t||�dS)z%Dump cloud-init events in json formatr/N)r$r'rr%r))rr*r+r,rrrrsrcCs*d}tj|�\}}|s&tj|d�\}}|S)N)�rawdata)rZload_events_infilerZdump_events)rr<Zevents�_rrrr%s
r%cCs�|jdkrtj}nByt|jd�}Wn0tk
rRtjjd|j�tjd�YnX|jdkrftj	}nByt|jd�}Wn0tk
r�tjjd|j�tjd�YnX||fS)z.Common parsing and setup of input/output filesrr9zCannot open file %s
r!�w)
r�sys�stdin�open�OSError�stderrr'�exitr�stdout)r*r+r,rrrr$s

r$)�file_handles�returncGs,x&|D]}|tjtjfkrq|j�qWdS)zclose filehandlesN)r?r@rE�close)rFZfile_handlerrrr)-s
r)�__main__)N)rr0r?rZtypingrZcloudinit.analyzerrZcloudinit.atomic_helperrrrrrrr%r$r)�__name__r�
parse_argsr*r
rZaction_functorrrrr�<module>s&
eS%


Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 7.19 KB 0644
__init__.cpython-36.pyc File 7.19 KB 0644
dump.cpython-36.opt-1.pyc File 3.52 KB 0644
dump.cpython-36.pyc File 3.52 KB 0644
show.cpython-36.opt-1.pyc File 8.5 KB 0644
show.cpython-36.pyc File 8.5 KB 0644