MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyc
�
d�bc@s)ddlZddlZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZmZm
Z
ddlmZddlmZmZe�Ze�Ze
�Zejjed�Zejjed�Zejjed	�Zejjed
�ZdZdZd
Zeejjed�ejjed�ejjed�ejjed�ejjed�ejjed�ejjedd�ejjedd�ejjeddd�dje�gZ dZ!d Z"ej#e$�Z%de&fd��YZ'dS(!i����N(tdatetime(theappushtheappop(tget_lib_dirtget_ext_log_dirtget_agent_log_file(tustr(tMANIFEST_NORMALt
MANIFEST_FULLtlogcollectort	truncatedsresults.txtslogs.zipscollect-logs.scopei����isGoalState.*.xmlsExtensionsConfig.*.xmlsHostingEnvironmentConfig.*.xmlsSharedConfig.*.xmls
*manifest.xmlswaagent_status.*.jsonthistorys*.zipt*s{0}.*iii�tLogCollectorcBs%eZdZed�Zed��Zed��Zed��Zed��Z	ee
jed��Zed��Z
d�Zed	��Zed
��Zed��Zed��Zed
��Zed��Zd�Zed��Zd�Zd�Zd�Zd�Zd�ZRS(t
truncated_cCsE||_|rtnt|_|j�|_|j�|j�dS(N(t
_is_full_modeRRt	_manifestt_expand_must_collect_filest_must_collect_filest_create_base_dirst_set_logger(tselftis_full_mode((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt__init__Ks
	
cCs&tjj|�s"tj|�ndS(N(tostpathtisdirtmakedirs(tdirname((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt_mkdirRscCs2t|d��}|jdjd��WdQXdS(Ntwbtsutf-8(topentwritetencode(tfilepathtout_file((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt_reset_fileWscCstjt�tjt�dS(N(R
Rt_LOG_COLLECTOR_DIRt_TRUNCATED_FILES_DIR(((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyR\s
cCsgtjtdd�}tjdddd�}tj|_|j|�tj	|�tj
tj�dS(Ntencodingsutf-8tfmts%%(asctime)s %(levelname)s %(message)stdatefmtu%Y-%m-%dT%H:%M:%SZ(tloggingtFileHandlertOUTPUT_RESULTS_FILE_PATHt	Formatterttimetgmtimet	convertertsetFormattert_LOGGERt
addHandlertsetLeveltINFO(t
_f_handlert	_f_format((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyRas	

c
s(�fd�}d�}yCtj�d|dtjdt�}|j�\}}|j}Wn?tk
r�}dj|��t|��}	t	j
|	�dSX|dkr�||�}
||�}d	j|��||
|�}	t	j
|	�dS|r$d
j|��||��}t	j|�ndS(s�
        Runs a shell command in a subprocess, logs any errors to the log file, enables changing the stdout stream,
        and logs the output of the command to the log file if indicated by the `log_output` parameter.
        :param command: Shell command to run
        :param stdout: Where to write the output of the command
        :param log_output: If true, log the command output to the log file
        cs t|t�rdj|�S�S(Nt (t
isinstancetlisttjoin(tcmd(tcommand(sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pytformat_commandtscSst|dddd�S(NR(sutf-8terrorstbackslashreplace(R(toutput((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt_encode_command_outputwststdouttstderrtshellu0Command [{0}] raised unexpected exception: [{1}]Nis?Command: [{0}], return code: [{1}], stdout: [{2}] stderr: [{3}]sOutput of command [{0}]:
{1}(t
subprocesstPopentPIPEtFalsetcommunicatet
returncodet	ExceptiontformatRR3terrortinfo(
R>RDt
log_outputR?RCtprocessREtreturn_codetet	error_msgtencoded_stdouttencoded_stderrtmsg((R>sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt_run_shell_commandks,		$

	
cCs7g}x*tD]"}|jttj|���q
W|S(N(t_MUST_COLLECT_FILEStextendtsortedtglob(tmanifestR((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyR�s
 cCs
|jj�S(N(Rt
splitlines(R((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt_read_manifest�scCs tjdd|gdt�dS(Ntlss-alFRQ(R
RYtTrue(tfolder((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt_process_ll_command�scCstj|�dS(N(R3RP(tmessage((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt_process_echo_command�scCs1tj|�}x|D]}tj|�qW|S(N(R]R3RP(Rt
file_pathst	file_path((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt_process_copy_command�s
cCsh|jt�rQ|tt�jtjj�}tj|j	tjjd�}|S|jtjj�SdS(Nt_(
t
startswithR'tlentlstripRRtsepR
t_TRUNCATED_FILE_PREFIXtreplace(t	file_nametoriginal_file_pathtarchive_file_name((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt"_convert_file_name_to_archive_name�s
cCsjtjt�}xT|D]L}tjjt|�}||krtjj|�rbtj|�qbqqWdS(N(RtlistdirR'RR<tisfiletremove(tfiles_to_collectttruncated_filesRht	full_path((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt#_remove_uncollected_truncated_files�s
cCs�tjdt�tjdt�tjdt�g}xQ|D]I}|jdt�}|jdt�}|jdt�}|j|�q=W|S(NsUsing %s as $LIB_DIRsUsing %s as $LOG_DIRsUsing %s as $AGENT_LOGs$LIB_DIRs$LOG_DIRs
$AGENT_LOG(R3RPt_AGENT_LIB_DIRt_EXTENSION_LOG_DIRt
_AGENT_LOGRptappend(t
manifest_datatnew_manifesttlinetnew_line((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt_expand_parameters�s
cCst�}|j�}tj|�}x�|D]�}|jd�}t|�dkr�|jd�r+t|j��dkr+tj	d|�q+q+n|\}}|dkr�|j
|�q+|dkr�|j|�q+|dkr+|j|j
|��q+q+W|S(	Nt,it#isCouldn't parse "%s"tlltechotcopy(tsetR`R
R�tsplitRlRktstripR3RORdRftupdateRi(RRxtdatatmanifest_entriestentrytcontentsR>tvalue((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt_process_manifest_file�s"	
(c	Csy�tjj|�d}|dkr9tjd|�dStjjt|jtjj	d��}tjj
|�r�tjj|�}tjj|�}||kr�|Snt|d��,}t
jdd	tt�|gd
|�WdQX|SWn*tk
r}tjdt|��dSXdS(
Nis.gzs.zips.xzsDiscarding large binary file %sRjsw+ttails-cRDs!Failed to truncate large file: %s(s.gzs.zips.xz(RRtsplitextR3twarningtNoneR<R'RpRntexiststgetmtimeR R
RYtstrt_FILE_SIZE_LIMITtOSErrorROR(Rhtextttruncated_file_pathtoriginal_file_mtimettruncated_file_mtimetfhRT((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt_truncate_large_file�s"'+cCs-y|jj|�SWntk
r(dSXdS(Ni�ɚ;(Rtindext
ValueError(Rt
file_entry((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt_get_file_prioritys
cCs=g}x0|D](}|j|�}t|||f�q
W|S(N(R�R(Rt	file_listtpriority_file_queueR�tpriority((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt_get_priority_files_lists

cCstjd�d}g}x�|r�t|�d}ttjj|�t�}||tkrntj	d�Pntjj|�tkr�|j
|�tjd||�n8|j|�}|r�tjd||�|j
|�n||7}qWtjd|�|S(Ns1### Preparing list of files to add to archive ###iis(Archive too big, done with adding files.sAdding file %s, size %s bs#Adding truncated file %s, size %s bs!Uncompressed archive size is %s b(R3RPRtminRRtgetsizeR�t _UNCOMPRESSED_ARCHIVE_SIZE_LIMITR�RR�(RR�ttotal_uncompressed_sizetfinal_files_to_collectRht	file_sizeR�((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt_get_final_list_for_archive%s&
	

cCs.|j�}|j|�}|j|�}|S(N(R�R�R�(Rtparsed_file_pathstprioritized_file_pathsRx((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt _create_list_of_files_to_collectCscCsg}z�y�|j�tjt�tj�}tjd|jd��tjd|j	r`dnd�|j
�}tjd�d}ztj
tddtj�}x9|D]1}tj|�}|j|jd	�d
|�q�Wtjjt�}tjd|�tj�}||}t|jdd
d
|jd|jd�}	tjd|j�jd��tjd|	�|jtjd	�d
d�Wd|dk	r�|j�nXtSWn8tk
r�}
djt|
��}tj|��nXWd|j|�XdS(s�
        Public method that collects necessary log files in a compressed zip archive.
        :return: Returns the path of the collected compressed archive
        sStarting log collection at %ss%Y-%m-%dT%H:%M:%SZsUsing log collection mode %stfulltnormals#### Creating compressed archive ###twtcompressionsutf-8tarcnames>Successfully compressed files. Compressed archive size is %s bii<i�g@�@sFinishing log collection at %ssElapsed time: %s mssresults.txtNsFailed to collect logs: {0}( RR
R%R-RtutcnowR3RPtstrftimeRR�R�tzipfiletZipFiletCOMPRESSED_ARCHIVE_PATHtZIP_DEFLATEDRtR!R"RRR�tinttdaystsecondstmicrosecondstcloseRMRNRROR{(RRxt
start_timetcompressed_archivetfile_to_collectRstcompressed_archive_sizetend_timetdurationt
elapsed_msRTRX((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pytcollect_logs_and_get_archiveNs@



 
1 
(t__name__t
__module__RoRJRtstaticmethodRR%RRRGRIRYRR`RdRfRiRtR{R�R�R�R�R�R�R�R�(((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyR
Gs.
%		
				
		ixi�iXi`	((R]R+RRGR/R�RtheapqRRtazurelinuxagent.common.confRRRtazurelinuxagent.common.futureRt-azurelinuxagent.common.logcollector_manifestsRRR}R|R~RR<R&R'R-R�tCGROUPS_UNITtFORCE_KILLED_ERRCODEtINVALID_CGROUPS_ERRCODERNRZR�R�t	getLoggerR�R3tobjectR
(((sG/usr/lib/python2.7/site-packages/azurelinuxagent/common/logcollector.pyt<module>sF