404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.135.218.63: ~ $
3

\�me�.�@sddlZddlZddlZddlZddlmZmZddlmZdddddd	d
ddd
dd�Z	dj
dd�e	j�D��ZdZ
dZdZed:d;d<fZdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�ZGd*d+�d+�Zd,d-�Zd.d/�Zd0d1�Zd=d4d5�Zd6d7�Z d8d9�Z!dS)>�N)�subp�util)�uses_systemd�delta�description�elapsed�
event_type�indent�level�name�origin�result�	timestamp�
total_time)z%dz%Dz%Ez%ez%Iz%lz%nz%oz%rz%tz%T� cCs$g|]\}}dj|jdd�|��qS)z{0}: {1}�%z%%)�format�replace)�.0�k�v�r�/usr/lib/python3.6/show.py�
<listcomp>1srZ
successful�failureZ	container�cCsTxFtj�D]:\}}||kr
|dkr4|j|d|�}q
|j|d|�}q
W|jf|�S)Nrrrz
{%s:08.5f}z{%s})rrr)�
format_key�itemsrr)�msg�event�i�jrrr�
format_record9sr"cCs|r|jd�SdS)Nr)�get)rrrr�
event_nameDs
r$cCs|r|jd�SdS)Nr)r#)rrrrrJs
cCs|rt|�jd�dSdS)N�/r)r$�split)rrrr�event_parentPsr'cCst|jd��S)Nr)�floatr#)rrrr�event_timestampVsr)cCstjjt|��S)N)�datetimeZutcfromtimestampr))rrrr�event_datetimeZsr+cCs||j�S)N)Z
total_seconds)Zt1Zt2rrr�
delta_seconds^sr,cCstt|�t|��S)N)r,r+)�start�finishrrr�event_durationbsr/cCsH|j�}|jt||�t|t|��ddt|�jd�ddd��|S)N�|rr%rz`->)rrr	)�copy�updater/r,r+r$�count)�
start_timer-r.�recordrrr�event_recordfs$r6cCsd|S)NzTotal Time: %3.5f seconds
r)rrrr�total_time_recordssr7c@s*eZdZdZd	dd�Zdd�Zdd�ZdS)
�SystemctlReaderzQ
    Class for dealing with all systemctl subp calls in a consistent manner.
    NcCsDd|_tjd�dg|_|r&|jj|�|jjd|g�|j�|_dS)NZ	systemctlZshowz-p)�epochrZwhich�args�append�extendr)�self�propertyZ	parameterrrr�__init__|szSystemctlReader.__init__cCsLy&tj|jdd�\}}|r|S||_dStk
rF}z|Sd}~XnXdS)z�
        Make a subp call based on set args and handle errors by setting
        failure code

        :return: whether the subp call failed or not
        T)�captureN)rr:r9�	Exception)r=�value�errZsystemctl_failrrrr�szSystemctlReader.subpcCs2|jrtdj|j���|jjd�d}t|�dS)z{
        If subp call succeeded, return the timestamp from subp as a float.

        :return: timestamp as a float
        zBSubprocess call to systemctl has failed, returning error code ({})�=ri@B)r�RuntimeErrorrr9r&r()r=rrrr�parse_epoch_as_float�s	
z$SystemctlReader.parse_epoch_as_float)N)�__name__�
__module__�__qualname__�__doc__r?rrFrrrrr8ws
r8cCs2t�rt�Stj�s(dtj�dj�kr.t�StS)a)
    Determine which init system a particular linux distro is using.
    Each init system (systemd, etc) has a different way of
    providing timestamps.

    :return: timestamps of kernelboot, kernelendboot, and cloud-initstart
    or TIMESTAMP_UNKNOWN if the timestamps cannot be retrieved.
    Zgentoo�system)r�gather_timestamps_using_systemdrZ
is_FreeBSDZsystem_info�lower�gather_timestamps_using_dmesg�TIMESTAMP_UNKNOWNrrrr�dist_check_timestamp�s

rPc	Cs�y�tjdgdd�\}}|dj�}xp|D]h}|jd�jd�d	kr(|jd�j�}|djd�}t|�}ttj��ttj	��}||}t
|||fSq(WWntk
r�YnXtS)
a
    Gather timestamps that corresponds to kernel begin initialization,
    kernel finish initialization using dmesg as opposed to systemctl

    :return: the two timestamps plus a dummy timestamp to keep consistency
    with gather_timestamps_using_systemd
    ZdmesgT)r@rzUTF-8�userr�]���)
r�
splitlines�decode�findr&�stripr(�timer�uptime�SUCCESS_CODErArO)	�data�_Z
split_entriesr Zsplitup�strippedZuser_space_timestamp�kernel_start�
kernel_endrrrrN�s
rNc
Cs�ttj��ttj��}y�td�j�}tdd�j�}|}t}tj�r�ttj��ttj��}yt	j
d�}|j}Wn2tk
r�}zt
dj|��|�WYdd}~XnXt}||}||}Wn(tk
r�}	zt|	�tSd}	~	XnX||||fS)z�
    Gather timestamps that corresponds to kernel begin initialization,
    kernel finish initialization. and cloud-init systemd unit activation

    :return: the three timestamps
    ZUserspaceTimestampMonotonicZInactiveExitTimestampMonotoniczcloud-init-localz/proc/1/cmdlinezBCould not determine container boot time from /proc/1/cmdline. ({})N)r(rXrrYr8rFrZZis_containerZ	monotonic�os�stat�st_atime�OSErrorrEr�CONTAINER_CODErA�printrO)
r^Zdelta_k_endZ
delta_ci_sZ	base_timeZstatusZ	file_statrCr_Zcloudinit_sysd�errrrL�s2


rLF�(%n) %d seconds in %I%DcCs�t|dd�d�}g}d}d}i}	g}
g}�xZtdt|��D�]F}||}
y||d}Wntk
rpd}YnXt|
�dk�r.|r�|
jd	�d
kr�|jt|��|
j|�g}d}d}|dkr�t|
�}||	t	|
�<t
|
�t
|�k�rt|�dk�r,|jt|t||
|���n |jd|
jd	��|j|
�q:q:|j
�}t
|
�t
|�k�rxt|||
�}|jtd
|�d�||jd�7}q:|j|�q:W|jt|��|
j|�|
S)a2
    Take in raw events and create parent-child dependencies between events
    in order to order events in chronological order.

    :param events: JSONs from dump that represents events taken from logs
    :param blame_sort: whether to sort by timestamp or by time taken.
    :param print_format: formatting to represent event, time stamp,
    and time taken by the event in one line
    :param dump_files: whether to dump files into JSONs
    :param log_datafiles: whether or not to log events generated

    :return: boot records ordered chronologically
    cSs|dS)Nrr)�xrrr�<lambda>$sz"generate_records.<locals>.<lambda>)�keyNgrrr-rz
init-localr.zStarting stage: %szFinished stage: (%n) %d seconds�
r)�sorted�range�len�
IndexErrorrr#r;r7r+r'r$r"r6�pop)�eventsZ
blame_sort�print_formatZ
dump_filesZ
log_datafilesZ
sorted_eventsZrecordsr4rZstage_start_timeZboot_recordsZunprocessedrfrZnext_evtZprev_evtr5rrr�generate_recordssV



rscCst||d�S)a<
    A passthrough method that makes it easier to call generate_records()

    :param events: JSONs from dump that represents events taken from logs
    :param print_format: formatting to represent event, time stamp,
    and time taken by the event in one line

    :return: boot records ordered chronologically
    )rr)rs)rqrrrrr�show_events_s
rtcCs4|j�}ytj|�|fStk
r.d|fSXdS)z�
    Takes in a log file, read it, and convert to json.

    :param infile: The Log file to be read

    :return: json version of logfile, raw file
    N)�read�json�loads�
ValueError)Zinfiler[rrr�load_events_infilels
ryrSrSrS)FrgFF)"r*rvr`rXZ	cloudinitrrZcloudinit.distrosrr�joinrZformatting_helprZZ	FAIL_CODErdrOr"r$rr'r)r+r,r/r6r7r8rPrNrLrsrtryrrrr�<module>sT
50
K

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