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: //lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pyo
�
d�bc@sZddlZddlZddlZddlZddlZddlmZmZddlj	j
Z
ddlmZddlm
Z
mZmZddlmZmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlm Z m!Z!m"Z"m#Z#dZ$d�Z%d�Z&defd��YZ'dS(i����N(tcgroupconfiguratortlogcollector(tlogger(telapsed_millisecondst	add_eventtWALAEventOperation(tsubprocess_dev_nulltustr(tThreadHandlerInterface(tCOMPRESSED_ARCHIVE_PATH(tCGroupConfigurator(tget_protocol_util(t	shellutil(tCommandError(tPY_VERSION_MAJORtPY_VERSION_MINORt
AGENT_NAMEtCURRENT_VERSIONii<cCst�S(N(tCollectLogsHandler(((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pytget_collect_logs_handler)scCs�tj�}tj�j�}tdkr6tdkn	tdk}|oQ|oQ|}dj||||�}tj	|�t
dtdtdt
jd|d	|d
t�|S(Niiis�Checking if log collection is allowed at this time [{0}]. All three conditions must be met: configuration enabled [{1}], cgroups enabled [{2}], python supported: [{3}]tnametversiontopt
is_successtmessaget	log_event(tconftget_collect_logsR
tget_instancetenabledRRtformatRtinfoRRRRt
LogCollectiontFalse(tconf_enabledtcgroups_enabledtsupported_pythont
is_allowedtmsg((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pytis_log_collection_allowed-s$$	
	RcBs�eZdZdZdZed��Zed��Zed��Zed��Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(sI
    Periodically collects and uploads logs from the VM to the host.
    Rt1_AZURE_GUEST_AGENT_LOG_COLLECTOR_MONITOR_CGROUPS_cCstjS(N(Rt_THREAD_NAME(((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pytget_thread_namePscCsdtjtj<dS(Nt1(tostenvironRt._CollectLogsHandler__CGROUPS_FLAG_ENV_VARIABLE(((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pytenable_cgroups_validationTscCs&tjtjkr"tjtj=ndS(N(RR.R,R-(((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pytdisable_cgroups_validationXscCs*tjtjkr&tjtjdkStS(NR+(RR.R,R-R!(((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pytshould_validate_cgroups]scCs@d|_d|_d|_t|_d|_tj�|_	dS(N(
tNonetprotocolt
protocol_utiltevent_threadtTruet
should_runt
last_stateRtget_collect_logs_periodtperiod(tself((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pyt__init__cs					cCs|j�dS(N(tstart(R;((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pytrunkscCs|jS(N(R7(R;((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pyt
keep_alivenscCs
|jj�S(N(R5tis_alive(R;((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pyR@qscCsOtjd|j�|_|jjt�|jj|j��|jj�dS(Nttarget(	t	threadingtThreadtdaemonR5t	setDaemonR6tsetNameR*R=(R;((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pyR=tscCs|jj�dS(N(R5tjoin(R;((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pyRGzscCs|jS(N(R7(R;((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pytstopped}scCs&t|_|j�r"|j�ndS(N(R!R7R@RG(R;((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pytstop�s	cCs"t�|_|jj�|_dS(N(RR4tget_protocolR3(R;((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pytinit_protocols�scCs�tjt�z�y�tj�|jdks;|jdkrH|j�nxb|j	�s�z>y|j
�Wn)tk
r�}tj
dt|��nXWdtj|j�XqKWWn)tk
r�}tj
dt|��nXWdtj�XdS(Ns^An error occurred in the log collection thread main loop; will skip the current iteration.
{0}sIAn error occurred in the log collection thread; will exit the thread.
{0}(ttimetsleept_INITIAL_LOG_COLLECTION_DELAYRR/R4R2R3RKRHtcollect_and_send_logst	ExceptionRterrorRR:R0(R;te((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pyRD�s"


	cCs|j�r|j�ndS(N(t
_collect_logst
_send_logs(R;((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pyRO�scs�tjd�ddjtj�djtj�dg}tjdtj	ddg}||���fd	�}zWyt
tj�d
�}Wn-t
k
r�t��}||�SWdQXnX||�SWd|dk	r�|j�nXdS(NsStarting log collection...ssystemd-runs
--unit={0}s--slice={0}s--scopes-uis
-collect-logscs�tjj�}t}d}z>yjtj�dtd|d|�t|�}tjj	t
�}dj||�}tj
|�t}tSWn�tk
rW}t|�}t|�}t|t�rAtd�j|j�}|jtjkrtj
d��j�qA|jtjkr1tj
d��j�qAtj
|�ndj||�}tSXWdtd	td
tdtjd|d
|dt�XdS(Nt	log_errortstdouttstderrsGSuccessfully collected logs. Archive size: {0} b, elapsed time: {1} ms.s"Log Collector exited with code {0}sMDisabling periodic log collection until service restart due to process error.sIDisabling periodic log collection until service restart due to OOM error.s8Failed to collect logs. Elapsed time: {0} ms. Error: {1}RRRRRR(tdatetimetutcnowR!R2Rtrun_commandRR,tpathtgetsizeR	RRRR6RPRt
isinstanceR
t
returncodeRtINVALID_CGROUPS_ERRCODERItFORCE_KILLED_ERRCODERRRRR (toutput_filet
start_timetsuccessR&tdurationtarchive_sizeRRterr_msg(t
final_commandR;(sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pytexec_command�sD		




		sa+(RRRRtCGROUPS_UNITRtLOGCOLLECTOR_SLICEtsyst
executabletargvtopenRtget_agent_log_fileRPRR2tclose(R;tsystemd_cmdtcollect_logs_cmdRhtlogfiletDEVNULL((RgR;sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pyRS�s

2
cCs�d}t}z�yQttd��6}|j�}|jj|�d}tj|�WdQXt	}Wn5t
k
r�}djt|��}tj
|�nXWdtdtdtdtjd|d|d	t�XdS(
NtrbsSuccessfully uploaded logs.s!Failed to upload logs. Error: {0}RRRRRR(R2R!RnR	treadR3tupload_logsRRR6RPRRtwarnRRRRR (R;R&Rctfhtarchive_contentRR((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pyRT�s(
	(t__name__t
__module__t__doc__R)R.tstaticmethodR*R/R0R1R<R>R?R@R=RGRHRIRKRDRORSRT(((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pyRHs(												Ki,((RXR,RkRBRLtazurelinuxagent.commonRRtazurelinuxagent.common.conftcommonRRtazurelinuxagent.common.eventRRRtazurelinuxagent.common.futureRRt!azurelinuxagent.common.interfacesRt#azurelinuxagent.common.logcollectorR	t)azurelinuxagent.common.cgroupconfiguratorR
t$azurelinuxagent.common.protocol.utilRtazurelinuxagent.common.utilsRt&azurelinuxagent.common.utils.shellutilR
tazurelinuxagent.common.versionRRRRRNRR'R(((sC/usr/lib/python2.7/site-packages/azurelinuxagent/ga/collect_logs.pyt<module>s("