403Webshell
Server IP : 23.254.227.96  /  Your IP : 216.73.216.7
Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k
System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64
User : viralblo ( 1001)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.6/site-packages/cloudinit/analyze/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.6/site-packages/cloudinit/analyze/__pycache__/show.cpython-36.opt-1.pyc
3

��b�1�@s6ddlZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
dddddd	d
ddd
dd�Zdjdd�ej
�D��ZdZdZdZed<d=d>fZdd�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|]\}}dj|jdd�|��qS)z{0}: {1}�%z%%)�format�replace)�.0�k�v�r�/usr/lib/python3.6/show.py�
<listcomp>3srZ
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_record;sr"cCsrtdd�|j�D��}|d}g}xJ|D]B}|d}tjj|�}tj|d�jd�}tj	||�|j
|�q(W|S)Ncss"|]\}}|dkr||fVqdS)�contentN)r#r)rrrrrr�	<genexpr>Gsz#dump_event_files.<locals>.<genexpr>�files�pathr#�ascii)�dictr�osr&�basename�base64Z	b64decode�decoderZ
write_file�append)rr#r%Zsaved�fZfnameZfn_localZfcontentrrr�dump_event_filesFs
r/cCs|r|jd�SdS)Nr)�get)rrrr�
event_nameTs
r1cCs|r|jd�SdS)Nr)r0)rrrrrZs
cCs|rt|�jd�dSdS)N�/r)r1�split)rrrr�event_parent`sr4cCst|jd��S)Nr)�floatr0)rrrr�event_timestampfsr6cCstjjt|��S)N)�datetimeZutcfromtimestampr6)rrrr�event_datetimejsr8cCs||j�S)N)Z
total_seconds)Zt1Zt2rrr�
delta_secondsnsr9cCstt|�t|��S)N)r9r8)�start�finishrrr�event_durationrsr<cCsH|j�}|jt||�t|t|��ddt|�jd�ddd��|S)N�|rr2rz`->)rrr	)�copy�updater<r9r8r1�count)�
start_timer:r;�recordrrr�event_recordvs$rCcCsd|S)NzTotal Time: %3.5f seconds
r)rrrr�total_time_record�srDc@s*eZdZdZd	dd�Zdd�Zdd�ZdS)
�SystemctlReaderzQ
    Class for dealing with all systemctl subp calls in a consistent manner.
    NcCs>d|_ddg|_|r |jj|�|jjd|g�|j�|_dS)Nz/bin/systemctlZshowz-p)�epoch�argsr-�extendrr)�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)rrGrF�	Exception)rI�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�RuntimeErrorrrFr3r5)rIrrrr�parse_epoch_as_float�s	
z$SystemctlReader.parse_epoch_as_float)N)�__name__�
__module__�__qualname__�__doc__rKrrRrrrrrE�s
rEcCs2t�rt�Stj�s(dtj�dj�kr.t�StS)a2
    Determine which init system a particular linux distro is using.
    Each init system (systemd, upstart, 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

r\c	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)rLrzUTF-8�userr�]���)
r�
splitlinesr,�findr3�stripr5�timer�uptime�SUCCESS_CODErMr[)	�data�_Z
split_entriesr Zsplitup�strippedZuser_space_timestamp�kernel_start�
kernel_endrrrrZ�s
rZc
Csttj��ttj��}y�td�j�}tdd�j�}|}t}tj�r�tj	dkr�ttj��ttj
��}ytjd�}|j
}Wn2tk
r�}ztdj|��|�WYdd}~XnXt}nt}||}||}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-local�z/proc/1/cmdlinezBCould not determine container boot time from /proc/1/cmdline. ({})N)rkrk)r5rcrrdrErRreZis_container�sys�version_infoZ	monotonicr)�stat�st_atime�OSErrorrQr�CONTAINER_CODE�	FAIL_CODErM�printr[)
riZdelta_k_endZ
delta_ci_sZ	base_timeZstatusZ	file_statrOrjZcloudinit_sysd�errrrX�s6



rXF�(%n) %d seconds in %I%DcCs�t|dd�d�}g}d}d}i}	g}
g}g}�xjtdt|��D�]V}
||
}y||
d}Wntk
rtd}YnXt|�dk�rB|jd	�|
kr�|jt|��|j|�g}d}d}|dkr�g}
t|�}||	t	|�<t
|�t
|�k�rt|�d
k�r@|jt|t|||���n0|jd|jd	��|j|�|
j|jd	��q>q>|j
�}t
|�t
|�k�r�t|||�}|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>8sz"generate_records.<locals>.<lambda>)�keyNgrrr:rr;zStarting stage: %szFinished stage: (%n) %d seconds�
r)�sorted�range�len�
IndexErrorrr0r-rDr8r4r1r"rC�pop)�eventsZ
blame_sort�print_formatZ
dump_filesZ
log_datafilesZ
sorted_eventsZrecordsrArZstage_start_timeZstages_seenZboot_recordsZunprocessedrtrZnext_evtZprev_evtrBrrr�generate_records#s\



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�)rr�rrr�show_eventsvs
r�cCs4|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)Zinfilerfrrr�load_events_infile�s
r�r_r_r_)FruFF)&r+r7r�r)rlrcZ	cloudinitrrZcloudinit.distrosrr�joinrZformatting_helprerrrqr[r"r/r1rr4r6r8r9r<rCrD�objectrEr\rZrXr�r�r�rrrr�<module>sZ
54
N

Youez - 2016 - github.com/yon3zu
LinuXploit