Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/cloudinit/analyze/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/cloudinit/analyze/__pycache__/show.cpython-310.pyc
o

}��f
+�@sddlZddlZddlZddlZddlmZmZddlmZdddddd	d
ddd
dd�Z	dZ
dZdZedddfZ
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZGd'd(�d(�Zd)d*�Zd+d,�Zd-d.�Z	/d6d0d1�Zd2d3�Zd4d5�ZdS)7�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�
successful�failure�	container���cCsTt��D]\}}||vr!|dvr|�|d|�}q|�|d|�}q|jdi|��S)N)rrrz
{%s:08.5f}z{%s}�)�
format_key�items�replace�format)�msg�event�i�jrr�8/usr/lib/python3/dist-packages/cloudinit/analyze/show.py�
format_record6s�rcC�|r|�d�SdS)Nr��get�rrrr�
event_nameA�
r#cCr)Nrr r"rrrrGr$cCs|rt|��d�dSdS)N�/r)r#�splitr"rrr�event_parentMsr'cCst|�d��S�Nr)�floatr!r"rrr�event_timestampSsr*cCstj�t|��S�N)�datetime�utcfromtimestampr*r"rrr�event_datetimeWsr.cCs||��Sr+)�
total_seconds)�t1�t2rrr�
delta_seconds[sr2cCstt|�t|��Sr+)r2r.)�start�finishrrr�event_duration_sr5c	CsH|��}|�t||�t|t|��ddt|��d�ddd��|S)N�|� r%�z`->)rrr	)�copy�updater5r2r.r#�count)�
start_timer3r4�recordrrr�event_recordcs��r>cCsd|S)NzTotal Time: %3.5f seconds
r)rrrr�total_time_recordpsr?c@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)N�	systemctl�showz-p)�epochr�which�args�append�extendr)�self�property�	parameterrrr�__init__yszSystemctlReader.__init__c
CsTztj|jdd�\}}|r|WS||_WdSty)}z|WYd}~Sd}~ww)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)rrErC�	Exception)rH�value�err�systemctl_failrrrr�s��zSystemctlReader.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 ({})�=r8i@B)r�RuntimeErrorrrCr&r))rHrrrr�parse_epoch_as_float�s	�z$SystemctlReader.parse_epoch_as_floatr+)�__name__�
__module__�__qualname__�__doc__rKrrTrrrrr@ts

r@cCs2t�rt�St��sdt��d��vrt�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.
    �gentoo�system)r�gather_timestamps_using_systemdr�
is_FreeBSD�system_info�lower�gather_timestamps_using_dmesg�TIMESTAMP_UNKNOWNrrrr�dist_check_timestamp�s

rac	Cs�zMtjdgdd�\}}|d��}|D]7}|�d��d�dkrJ|�d���}|d�d	�}t|�}tt���tt�	��}||}t
|||fWSqWtStyWYtSw)
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
    �dmesgTrLrzUTF-8�userrr8�])
r�
splitlines�decode�findr&�stripr)�timer�uptime�SUCCESS_CODErNr`)	�data�_�
split_entriesr�splitup�stripped�user_space_timestamp�kernel_start�
kernel_endrrrr_�s$����r_c
Cs�tt���tt���}z!td���}tdd���}|}t}t��r$t}||}||}Wnt	yE}zt
|�tWYd}~Sd}~ww||||fS)z�
    Gather timestamps that corresponds to kernel begin initialization,
    kernel finish initialization. and cloud-init systemd unit activation

    :return: the three timestamps
    �UserspaceTimestampMonotonic�InactiveExitTimestampMonotoniczcloud-init-localN)r)rirrjr@rTrk�is_container�CONTAINER_CODErN�printr`)rr�delta_k_end�
delta_ci_s�	base_time�statusrs�cloudinit_sysd�errrr[�s0������r[�(%n) %d seconds in %I%Dc	Cs�t|dd�d�}g}d}d}i}g}g}tt|��D]�}	||	}
z||	d}Wnty3d}Ynwt|
�dkr�|rU|
�d�d	krU|�t|��|�|�g}d}d}|durct|
�}||t	|
�<t
|
�t
|�kr~t|�d
kr}|�t|t||
|���q|�d|
�d��|�|
�q|�
�}t
|
�t
|�kr�t|||
�}
|�td|
�d
�||
�d�7}q|�|�q|�t|��|�|�|S)as
    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 print_format: formatting to represent event, time stamp,
    and time taken by the event in one line

    :return: boot records ordered chronologically
    cSs|dSr(r)�xrrr�<lambda>sz"generate_records.<locals>.<lambda>)�keyNgr8r3rz
init-localr4zStarting stage: %szFinished stage: (%n) %d seconds�
r)�sorted�range�len�
IndexErrorrr!rFr?r.r'r#rr>�pop)�events�print_format�
sorted_events�recordsr<r�stage_start_time�boot_records�unprocessedr~r�next_evt�prev_evtr=rrr�generate_records�sb�

���
��
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_eventsIs
r�cCsX|��}|��stj�d|j�t�d�zt�|�|fWSt	y+d|fYSw)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
    zEmpty file %s
r8N)
�readrh�sys�stderr�writer�exit�json�loads�
ValueError)�infilerlrrr�load_events_infileVs
�r�)r)r,r�r�ri�	cloudinitrr�cloudinit.distrosrrrk�	FAIL_CODErwr`rr#rr'r*r.r2r5r>r?r@rar_r[r�r�r�rrrr�<module>sP�
5#
�J

Spamworldpro Mini