403Webshell
Server IP : 195.114.193.97  /  Your IP : 216.73.217.68
Web Server : LiteSpeed
System : Linux host 5.15.0-126-generic #136-Ubuntu SMP Wed Nov 6 10:38:22 UTC 2024 x86_64
User : sembi4241 ( 1126)
PHP Version : 8.1.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/cloudinit/analyze/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

쑛h�&�	@s\ddlZddlZddlZddlmZmZddlmZmZmZm	Z	m
Z
mZddlm
Z
mZddlmZ	dde	ejdejfdd	�Zd
edejdefdd
�Zdejddfdd�Zdejddfdd�Zdejddfdd�Zdedeeeeeefffdd�Zdejde
eeffdd�Zdeddfdd�Zedkr�e�Ze� �Z!e!j"\Z#Z$e$e#e!�dSdS)�N)�datetime�timezone)�IO�Dict�List�Optional�Tuple�Union)�dump�show)�
json_dumps�parser�returncCsh|s	tjddd�}|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�description�Subcommands�
subcommand)�title�destT�blamez5Print list of executed stages ordered by time to init)�helpz-iz--infile�store�infilez/var/log/cloud-init.logzspecify where to read input.)�actionr�defaultrz-oz	--outfile�outfile�-zspecify where to write output. )rrz.Print list of in-order events during executionz-fz--format�print_formatz%I%D @%Es +%dszspecify formatting of output.zspecify where to write output.r
z%Dump cloud-init events in JSON formatzspecify where to read input. �bootz2Print list of boot times for kernel and cloud-init)�argparse�ArgumentParser�add_subparsers�required�
add_parser�add_argument�set_defaults�
analyze_blame�analyze_show�analyze_dump�analyze_boot)r
�
subparsers�parser_blame�parser_show�parser_dump�parser_boot�r/�</usr/lib/python3/dist-packages/cloudinit/analyze/__init__.py�
get_parsers���������������r1�name�argsc
Cs
t|�\}}t��}|\}}}}t�|tj�}	t�|tj�}
t�|tj�}zdd�t|�D�d}t�t|d�tj�}
Wnt	yKd}
tj
}Ynwd}d}d}tj
|tj|tj|i}||}||}|	|
|||||||
d	�	}|�
||jdi|���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|]}|ddkrdt|d�vr|�qS)r2z
init-localzstarting searchr)�str)�.0�er/r/r0�
<listcomp>�s�z analyze_boot.<locals>.<listcomp>����	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://docs.cloud-init.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}
)	�k_s_t�k_e_t�k_r�bt_r�k_e�k_s�ci_sysd�	ci_sysd_t�ci_startNr/)�configure_ior�dist_check_timestampr�
fromtimestampr�utc�_get_events�float�
IndexError�	FAIL_CODE�CONTAINER_CODE�SUCCESS_CODE�write�format�clean_io)r2r3�infh�outfh�kernel_info�status_code�kernel_start�
kernel_end�
ci_sysd_start�kernel_start_timestamp�kernel_end_timestamp�ci_sysd_start_timestamp�last_init_localrB�FAILURE_MSG�SUCCESS_MSG�
CONTAINER_MSG�
status_map�kernel_runtime�between_process_runtime�kwargsr/r/r0r)vs\����
������
r)c	Cs�t|�\}}d}t�dtj�}d}tt�t|�|��D]&\}}tt	|j
|�dd�}|�d|d�|�d�|�d�|�d�q|�d	|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)�reverse�-- Boot Record %02d --
��
�%d boot records analyzed
N)rC�re�compile�	MULTILINE�	enumerater�show_eventsrG�sorted�filter�matchrM�joinrO)	r2r3rPrQ�blame_format�r�idx�record�srecsr/r/r0r&�s�r&cCs�t|�\}}tt�t|�|j��D]!\}}|�d|d�|�d�|�d�|�d�|�d�q|�d|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
    rcrdzUThe total time elapsed since completing an event is printed after the "@" character.
z>The time the event takes is printed after the "+" character.

rerfN)	rCrjrrkrGrrMrorO)r2r3rPrQrrrsr/r/r0r'�s���r'cCs0t|�\}}|�tt|��d�t||�dS)z%Dump cloud-init events in json formatreN)rCrMrrGrO)r2r3rPrQr/r/r0r(
sr(rcCs*d}t�|�\}}|stj|d�\}}|S)N)�rawdata)r�load_events_infiler
�dump_events)rru�events�_r/r/r0rGs
rGcCs�|jdkr	tj}n zt|jd�}Wnty(tj�d|j�t�d�Ynw|jdkr5tj	}||fSzt|jd�}W||fStyZtj�d|j�t�d�Y||fSw)z.Common parsing and setup of input/output filesrrqzCannot open file %s
rd�w)
r�sys�stdin�open�OSError�stderrrM�exitr�stdout)r3rPrQr/r/r0rCs&
�
���rC�file_handlescGs(|D]}|tjtjfvr
q|��qdS)zclose filehandlesN)r{r|r��close)r��file_handler/r/r0rO3s

�rO�__main__)N)%rrgr{rr�typingrrrrrr	�cloudinit.analyzer
r�cloudinit.atomic_helperrr r1r4�	Namespace�intr)r&r'r(rHrGrCrO�__name__r
�
parse_argsr3rr2�action_functorr/r/r/r0�<module>s4 ��
�gW%&
�

Youez - 2016 - github.com/yon3zu
LinuXploit