/usr/lib/python3/dist-packages/cloudinit/analyze/__pycache__
NameSizeModeActions
dump.cpython-310.pyc45080644editdlrm
show.cpython-310.pyc93770644editdlrm
__init__.cpython-310.pyc77920644editdlrm
Edit: /usr/lib/python3/dist-packages/cloudinit/analyze/__pycache__/show.cpython-310.pyc (9377B)
o th*7 @sJddlZddlZddlZddlZddlmZmZmZmZm Z m Z m Z m Z ddl mZmZddlmZddddd d d d d ddd ZdZdZdZedddfZeZdededefddZde ede efddZde ede efddZde ede efddZdedefdd Zdedejfd!d"Zd#ejd$ejdefd%d&Z d'ed(edefd)d*Z!d+ejd'ed(edefd,d-Z"dedefd.d/Z#Gd0d1d1Z$de eeeeffd2d3Z%de eeeeffd4d5Z&de eeeeffd6d7Z' 8dBd9eed:edeeefd;d<Z(d9eed:edeeefd=d>Z)d?ede e eeffd@dAZ*dS)CN)IOAnyDictListOptionalTupleUnioncast)subputil) uses_systemddelta descriptionelapsed event_typeindentlevelnameoriginresult timestamp total_time) z%dz%Dz%Ez%ez%Iz%lz%nz%oz%rz%tz%T successfulfailure containermsgeventreturncCsTtD]\}}||vr!|dvr||d|}q||d|}q|jdi|S)N)r rrz {%s:08.5f}z{%s}) format_keyitemsreplaceformat)rrijrr8/usr/lib/python3/dist-packages/cloudinit/analyze/show.py format_record9sr'cC|r|dSdS)Nrgetrrrr& event_nameD r,cCr()Nrr)r+rrr&rJr-cCst|}|r |ddSdS)N/r)r,split)rrrrr& event_parentPsr0cCs"|d}|dur tdt|S)NrzEvent is missing a 'timestamp')r* ValueErrorfloat)rtsrrr&event_timestampWs r4cCstjt|tjjSN)datetime fromtimestampr4timezoneutcr+rrr&event_datetime^s r:t1t2cCs ||Sr5) total_seconds)r;r<rrr& delta_secondsds r>startfinishcCstt|t|Sr5)r>r:)r?r@rrr&event_durationhsrA start_timecCsX|}t|}d}|r|d|ddd7}|t||t|t||d|S)N| r.z`->)r rr)copyr,countupdaterAr>r:)rBr?r@recordrrrrr& event_recordls rJcCsd|S)NzTotal Time: %3.5f seconds r)rrrr&total_time_recordsrKc@sPeZdZdZd dedeefddZdeeeeffdd Z de fd d Z dS) SystemctlReaderzQ Class for dealing with all systemctl subp calls in a consistent manner. Nproperty parametercCsFd|_tddg|_|r|j||jd|dg||_dS)N systemctlshowz-pz--timestamp=us+utc)stdoutr whichargsappendextend_subpr)selfrMrNrrr&__init__s  zSystemctlReader.__init__rc 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 TcaptureN)r rSrQ Exception)rWvalueerrsystemctl_failrrr&rVszSystemctlReader._subpcCsv|jr td|j|jdurtd|jdd}|r*t|d}|Stj |dj tj j d }|S) 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 ({})Nz.stdout of subprocess call to systemctl is None=rEi@Bz%a %Y-%m-%d %H:%M:%S.%f %Z)tzinfo)r RuntimeErrorr#rQr/strip isnumericr2r6strptimer"r8r9r)rWvalrrrr&convert_val_to_floats&    z$SystemctlReader.convert_val_to_floatr5) __name__ __module__ __qualname____doc__strrrXrr[rVr2rfrrrr&rLs rLcCs2trtStsdtdvrtStS)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. gentoosystem)r gather_timestamps_using_systemdr is_FreeBSD system_infolowergather_timestamps_using_dmesgTIMESTAMP_UNKNOWNrrrr&dist_check_timestamps  rtc CszMtjdgdd\}}|d}|D]7}|dddkrJ|d}|dd }t|}tttt }||}t |||fWSqWt St yWYt 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 dmesgTrYrzUTF-8userrrE]) r splitlinesdecodefindr/rbr2timer uptime SUCCESS_CODEr[rs) data_ split_entriesr$splitupstrippeduser_space_timestamp kernel_start kernel_endrrr&rrs$  rrc Csz0trtd}td}n td}td}td|}tdd|}WntyH}z t|tWYd}~Sd}~wwtrOtnt}||||||fS)z Gather timestamps that corresponds to kernel begin initialization, kernel finish initialization. and cloud-init systemd unit activation :return: the three timesread_propertystamps UserspaceTimestampUserspaceTimestampMonotonicKernelTimestampKernelTimestampMonotonicInactiveExitTimestampMonotoniczcloud-init-localN) r is_containerrLrfr[printrsCONTAINER_CODEr})rmonotonic_offsetrcloudinit_sysdestatusrrr&rns^rn(%n) %d seconds in %I%Devents print_formatc Cst|ddd}g}d}d}i}g}g}tt|D]} || } z|| d} Wn ty3d} Ynwt| dkr|rU| dd krU|t|||g}d}d}|durct| }||t | <t | t | krt| d krt t | } |t |t|| | q|d | d|| q|} t | t | kr|rt|| | } |t d | d || dpd7}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|dS)Nrr)xrrr&Wsz"generate_records..)keyNgrEr?rz init-localr@zStarting stage: %szFinished stage: (%n) %d seconds r )sortedrangelen IndexErrorrr*rTrKr:r0r,r rr'rJpop)rr sorted_eventsrecordsrBrstage_start_time boot_records unprocessedrrnext_evtprev_evtrIrrr&generate_recordsHsl           rcCs t||dS)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)rrrrr& show_eventss rinfilecCsX|}|stjd|jtdzt||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 rEN) readrbsysstderrwriterexitjsonloadsr1)rr~rrr&load_events_infiles   r)r)+r6rrr{typingrrrrrrrr cloudinitr r cloudinit.distrosr r r} FAIL_CODErrsEventrkr'r,rr0r2r4r:r>rArJrKrLrtrrrnrrrrrrr&sp(    U;  "P"