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: sonne (1011)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyo
�
d�bc@s�ddlZddlZddlZddljjZddljjZddljj	j
Z
ddlmZddl
mZddlmZddlmZmZmZddlmZddlmZddlmZdd	lmZdd
lmZddlm Z ddl!m"Z"dd
l#m$Z$ddl%m&Z&m'Z'ddl(m)Z)d�Z*de)fd��YZ+de)fd��YZ,de)fd��YZ-de)fd��YZ.de)fd��YZ/de)fd��YZ0defd��YZ1dS(i����N(tCGroupConfigurator(tCGroupsTelemetry(t
ErrorState(t	add_eventtWALAEventOperationt
report_metric(tustr(tThreadHandlerInterface(t
get_osutil(t
HealthService(tget_imds_client(tget_protocol_util(tIOErrorCounter(thash_strings(t
AGENT_NAMEtCURRENT_VERSION(tPeriodicOperationcCst�S(N(tMonitorHandler(((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pytget_monitor_handler)stPollResourceUsagecBs eZdZd�Zd�ZRS(s�
    Periodic operation to poll the tracked cgroups for resource usage data.

    It also checks whether there are processes in the agent's cgroup that should not be there.
    cCs/tt|�jtj��tj�|_dS(N(tsuperRt__init__tconftget_cgroup_check_periodtget_cgroup_log_metricst_PollResourceUsage__log_metrics(tself((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR3scCs\tj�}x6|D].}t|j|j|j|jd|j�qWtj	�j
|�dS(Nt	log_event(Rtpoll_all_trackedRtcategorytcountertinstancetvalueRRtget_instancet
check_cgroups(Rttracked_metricstmetric((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyt
_operation7s
,(t__name__t
__module__t__doc__RR%(((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR-s	tResetPeriodicLogMessagescBs eZdZd�Zd�ZRS(s�
    Periodic operation to clean up the hash-tables maintained by the loggers. For reference, please check
    azurelinuxagent.common.logger.Logger and azurelinuxagent.common.event.EventLogger classes
    cCs&tt|�jtjdd��dS(Nthoursi(RR)Rtdatetimet	timedelta(R((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyREscCstj�dS(N(tloggertreset_periodic(R((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR%Hs(R&R'R(RR%(((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR)@s	tReportNetworkErrorscBseZd�Zd�ZRS(cCs&tt|�jtjdd��dS(Ntminutesi(RR/RR+R,(R((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyRMscCs�tj�}|jd�}|jd�}|jd�}|dks]|dks]|dkr�dj|||�}tdtjd|�ndS(Nt
hostplugintprotocoltotheris%hostplugin:{0};protocol:{1};other:{2}toptmessage(Rt
get_and_resettgettformatRRt
HttpErrors(Rt	io_errorsthostplugin_errorstprotocol_errorstother_errorstmsg((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR%Ps$(R&R'RR%(((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR/Ls	t!ReportNetworkConfigurationChangescBs)eZdZd�Zd�Zd�ZRS(sO
    Periodic operation to check and log changes in network configuration.
    cCsDtt|�jtjdd��t�|_d|_i|_dS(NR0it(	RR?RR+R,Rtosutiltlast_route_table_hashtlast_nic_state(R((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR_s"	c	Cs
y�d}tjj|�r�g}t|��W}xM|D]E}|j|�t|�dkr7|jdjt|���Pq7q7WWdQXtjd|dj	|��n|j
jdt�}|dkr�tjd|�nWn)t
k
r}tjdt|��nXdS(	Ns/proc/net/routeids<TRUNCATED TO {0} LINESsRouting table from {0}:
{1}R@t	as_stringsNetwork interfaces:
{0}s-Error fetching the network configuration: {0}(tostpathtexiststopentappendtlenR8R-tinfotjoinRAt
get_nic_statetTruet	ExceptiontwarnR(Rt
route_filetlinestfile_objecttlinetnetwork_interfacest	exception((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pytlog_network_configurationes 

cCs�|jj�}t|�}||jkrv||_|jj|�}tjdjdjt	t
jj|����n|jj
�}||jkr�|jikr�dnd}tjdj|djt	t|j�����||_ndS(NsRoute table: [{0}]t,tInitialtUpdateds{0} NIC state: [{1}]s, (RAtread_route_tableR
RBtget_list_of_routesR-RKR8RLtmaptnetworkutilt
RouteEntrytto_jsonRMRCtstrtvalues(Rtraw_route_listtdigestt
route_listt	nic_statetdescription((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR%ws	11(R&R'R(RRWR%(((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR?[s		tSendHostPluginHeartbeatcBsDeZdZd�Zejdd�Zejdd�Zd�ZRS(s�
    Periodic operation for reporting the HostGAPlugin's health. The signal is 'Healthy' when we have been able to communicate with
    plugin at least once in the last _HOST_PLUGIN_HEALTH_PERIOD.
    cCsDtt|�jtj�||_||_tdtj�|_dS(Nt
min_timedelta(	RRhRt_HOST_PLUGIN_HEARTBEAT_PERIODR2thealth_serviceRt_HOST_PLUGIN_HEALTH_PERIODthost_plugin_error_state(RR2Rk((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR�s		R0iic
Cs7y�|jjj�}|j�|jj�|j�}|rN|jj�n
|jj�|jj	�t
k}tjd|�|j
j|�|s�tdtdtdtjdt
ddj|jj�dt
�nWnYtk
r2}d	jt|��}tdtdtdtjdt
d|dt
��nXdS(
NsHostGAPlugin health: {0}tnametversionR4t
is_successR5s{0} since successful heartbeatRs,Exception sending host plugin heartbeat: {0}(R2tclienttget_host_plugintensure_initializedt"update_host_plugin_from_goal_statet
get_healthRmtresettincrtis_triggeredtFalseR-tverboseRktreport_host_plugin_heartbeatRRRRtHostPluginHeartbeatExtendedR8t	fail_timeRORtHostPluginHeartbeat(Rthost_plugintis_currently_healthyt
is_healthyteR>((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR%�s:


		(	R&R'R(RR+R,RjRlR%(((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyRh�s
	tSendImdsHeartbeatcBsDeZdZd�Zejdd�Zejdd�Zd�ZRS(s�
    Periodic operation to report the IDMS's health. The signal is 'Healthy' when we have successfully called and validated
    a response in the last _IMDS_HEALTH_PERIOD.
    cCsPtt|�jtj�||_t|j��|_tdtj	�|_
dS(NRi(RR�Rt_IMDS_HEARTBEAT_PERIODRkR
tget_wireserver_endpointtimds_clientRt_IMDS_HEALTH_PERIODtimds_error_state(Rt
protocol_utilRk((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR�s	R0iic
Cs�yw|jj�\}}|r.|jj�n
|jj�|jj�tk}tjd||�|j	j
||�WnYtk
r�}djt
|��}tdtdtdtjdtd|dt��nXdS(	NsIMDS health: {0} [{1}]s%Exception sending imds heartbeat: {0}RnRoR4RpR5R(R�tvalidateR�RvRwRxRyR-RzRktreport_imds_statusROR8RRRRRt
ImdsHeartbeat(RR�tresponseR�R�R>((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR%�s$
	(	R&R'R(RR+R,R�R�R%(((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR��s
	RcBseeZdZed��Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�ZRS(
RcCstjS(N(Rt_THREAD_NAME(((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pytget_thread_name�scCsd|_t|_dS(N(tNonetmonitor_threadRNt
should_run(R((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR�s	cCs|j�dS(N(tstart(R((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pytrun�scCs&t|_|j�r"|j�ndS(N(RyR�tis_aliveRL(R((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pytstop�s	cCs|jj�dS(N(R�RL(R((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyRL�scCs|jS(N(R�(R((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pytstopped�scCs|jdk	o|jj�S(N(R�R�R�(R((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR��scCsOtjd|j�|_|jjt�|jj|j��|jj�dS(Nttarget(	t	threadingtThreadtdaemonR�t	setDaemonRNtsetNameR�R�(R((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR��scCs
y�t�}|j�}t|j��}t�t�t�t||�t||�g}t	�}t
j�r|j|�nt
jd�|j�x@|j�s�zx|D]}|j�q�WWdtj|�Xq�WWn)tk
r}t
jdt|��nXdS(Ns0Monitor.NetworkConfigurationChanges is disabled.sBAn error occurred in the monitor thread; will exit the thread.
{0}(Rtget_protocolR	tget_endpointR)R/RRhR�R?Rt)get_monitor_network_configuration_changesRIR-RKRWR�R�Rtsleep_until_next_operationROterrorR(RR�R2Rktperiodic_operationst$report_network_configuration_changesR4R�((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR�s*		


(
R&R'R�tstaticmethodR�RR�R�RLR�R�R�R�(((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyR�s							(2R+RER�tazurelinuxagent.common.conftcommonRtazurelinuxagent.common.loggerR-t(azurelinuxagent.common.utils.networkutiltutilsR^t)azurelinuxagent.common.cgroupconfiguratorRt'azurelinuxagent.common.cgroupstelemetryRt!azurelinuxagent.common.errorstateRtazurelinuxagent.common.eventRRRtazurelinuxagent.common.futureRt!azurelinuxagent.common.interfacesRtazurelinuxagent.common.osutilRt-azurelinuxagent.common.protocol.healthserviceR	t$azurelinuxagent.common.protocol.imdsR
t$azurelinuxagent.common.protocol.utilRt%azurelinuxagent.common.utils.restutilRt%azurelinuxagent.common.utils.textutilR
tazurelinuxagent.common.versionRRt%azurelinuxagent.ga.periodic_operationRRRR)R/R?RhR�R(((s>/usr/lib/python2.7/site-packages/azurelinuxagent/ga/monitor.pyt<module>s6	+5(