Viewing File: /usr/lib/python2.7/site-packages/cloudinit/analyze/__main__.pyc

ó
oBú]c@sêddlZddlZddlZddlmZddlmZddlmZddlmZdd„Z
d„Zd	„Zd
„Z
d„Zd„Zd
„Zedkræe
ƒZejƒZej\ZZeeeƒndS(iÿÿÿÿN(t
json_dumps(tdatetimei(tdump(tshowcCsZ|s!tjddddƒ}n|jddddƒ}t|_|jd	d
dƒ}|jdd
ddddddd
dƒ|jddddddddd
dƒ|jdd	tfƒ|jdd
dƒ}|jddddddddd
dƒ|jdd
ddddddd
dƒ|jddddddddd
d ƒ|jddt	fƒ|jd!d
d"ƒ}|jdd
ddddddd
d#ƒ|jddddddddd
dƒ|jdd!t
fƒ|jd$d
d%ƒ}|jdd
ddddddd
d#ƒ|jddddddddd
d ƒ|jdd$tfƒ|S(&Ntprogscloudinit-analyzetdescriptions,Devel tool: Analyze cloud-init logs and datattitletSubcommandstdestt
subcommandtblamethelps5Print list of executed stages ordered by time to inits-is--infiletactiontstoretinfiletdefaults/var/log/cloud-init.logsspecify where to read input.s-os	--outfiletoutfilet-sspecify where to write output. Rs.Print list of in-order events during executions-fs--formattprint_formats%I%D @%Es +%dssspecify formatting of output.sspecify where to write output.Rs%Dump cloud-init events in JSON formatsspecify where to read input. tboots2Print list of boot times for kernel and cloud-init(targparsetArgumentParsertadd_subparserstTruetrequiredt
add_parsertadd_argumenttset_defaultst
analyze_blametanalyze_showtanalyze_dumptanalyze_boot(tparsert
subparserstparser_blametparser_showtparser_dumptparser_boot((s>/usr/lib/python2.7/site-packages/cloudinit/analyze/__main__.pyt
get_parsers^		cCs‡t|ƒ\}}tjƒ}|\}}}}tj|ƒ}	tj|ƒ}
tj|ƒ}yZgt|ƒD],}|ddkrmd|dkrm|^qmd}
tj|
dƒ}Wn tk
rÙd}tj}nXd}d	}d
}i|tj6|tj6|tj	6}||}||}i	|	d6|
d6|d
6|d6|d6|d6|d6|d6|d6}|j
||j|ƒ|S(s‹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>
    tnames
init-localsstarting searchRiÿÿÿÿt	timestamps4Could not find init-local log-line in cloud-init.logsôYour Linux distro or container does not support this functionality.
You must be running a Kernel Telemetry supported distro.
Please check https://cloudinit.readthedocs.io/en/latest/topics/analyze.html for more information on supported distros.
s*-- 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}
sŸ-- 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}
tk_s_ttk_e_ttk_rtbt_rtk_etk_stci_sysdt	ci_sysd_ttci_start(tconfigure_ioRtdist_check_timestampRtutcfromtimestampt_get_eventst
IndexErrort	FAIL_CODEtCONTAINER_CODEtSUCCESS_CODEtwritetformat(R'targstinfhtoutfhtkernel_infotstatus_codetkernel_startt
kernel_endt
ci_sysd_starttkernel_start_timestamptkernel_end_timestamptci_sysd_start_timestamptetlast_init_localR1tFAILURE_MSGtSUCCESS_MSGt
CONTAINER_MSGt
status_maptkernel_runtimetbetween_process_runtimetkwargs((s>/usr/lib/python2.7/site-packages/cloudinit/analyze/__main__.pyRCsD# 

	





c	CsÏt|ƒ\}}d}tjdtjƒ}x†ttjt|ƒ|ƒƒD]f\}}tt	|j
|ƒdtƒ}|jd|dƒ|jdj
|ƒdƒ|jdƒqLW|jd|dƒdS(	szReport 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')
    s
     %ds (%n)s(^\s+\d+\.\d+)treverses-- Boot Record %02d --
is
s%d boot records analyzed
N(R2tretcompilet	MULTILINEt	enumerateRtshow_eventsR5tsortedtfiltertmatchRR:tjoin(	R'R<R=R>tblame_formattrtidxtrecordtsrecs((s>/usr/lib/python2.7/site-packages/cloudinit/analyze/__main__.pyRŽscCs¦t|ƒ\}}xxttjt|ƒ|jƒƒD]U\}}|jd|dƒ|jdƒ|jdƒ|jdj|ƒdƒq4W|jd|dƒdS(sGenerate 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
    s-- Boot Record %02d --
isUThe total time elapsed since completing an event is printed after the "@" character.
s>The time the event takes is printed after the "+" character.

s
s%d boot records analyzed
N(R2RTRRUR5RR:RY(R'R<R=R>R\R]((s>/usr/lib/python2.7/site-packages/cloudinit/analyze/__main__.pyR¦s

cCs3t|ƒ\}}|jtt|ƒƒdƒdS(s%Dump cloud-init events in json formats
N(R2R:RR5(R'R<R=R>((s>/usr/lib/python2.7/site-packages/cloudinit/analyze/__main__.pyRÆscCs@d}tj|ƒ\}}|s<tjd|ƒ\}}n|S(Ntrawdata(tNoneRtload_events_infileRtdump_events(RR_teventst_((s>/usr/lib/python2.7/site-packages/cloudinit/analyze/__main__.pyR5Ìs
cCsÜ|jdkrtj}nNyt|jdƒ}Wn5tk
rhtjjd|jƒtjdƒnX|jdkr„tj	}nNyt|jdƒ}Wn5tk
rÑtjjd|jƒtjdƒnX||fS(s.Common parsing and setup of input/output filesRR[sCannot open file %s
itw(
RtsyststdintopentOSErrortstderrR:texitRtstdout(R<R=R>((s>/usr/lib/python2.7/site-packages/cloudinit/analyze/__main__.pyR2Ôs

t__main__(RRQRftcloudinit.utilRRtRRR`R&RRRRR5R2t__name__R t
parse_argsR<RR'taction_functor(((s>/usr/lib/python2.7/site-packages/cloudinit/analyze/__main__.pyt<module>s$4	K		 				
Back to Directory File Manager