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: //usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyc
�
d�bc@s&ddlmZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZdZed	d
ddd
g�Zdefd��YZdefd��YZejd�Zdefd��YZdefd��YZdefd��YZdS(i����(t
namedtupleN(tlogger(tCGroupsException(tustr(t
get_osutil(tfileutilswalinuxagent.servicetMetrictcategorytcountertinstancetvaluetMetricsCategorycBseZdZdZRS(tMemorytCPU(t__name__t
__module__tMEMORY_CATEGORYtCPU_CATEGORY(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyR!stMetricsCountercBs eZdZdZdZdZRS(s% Processor TimesTotal Memory UsagesMax Memory UsagesThrottled Time(RRtPROCESSOR_PERCENT_TIMEtTOTAL_MEM_USAGEt
MAX_MEM_USAGEtTHROTTLED_TIME(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyR&ssuser (\d+)\nsystem (\d+)\ntCGroupcBsJeZd�Zd�Zd�Zd�Zed�Zd�Zd�Z	RS(cCs||_||_dS(s�
        Initialize _data collection for the Memory controller
        :param: name: Name of the CGroup
        :param: cgroup_path: Path of the controller
        :return:
        N(tnametpath(tselfRtcgroup_path((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyt__init__1s	cCsdj|j|j�S(Ns	{0} [{1}](tformatRR(R((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyt__str__;scCstjj|j|�S(N(tosRtjoin(Rt	file_name((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyt_get_cgroup_file>scCs|j|�}tj|�S(s�
        Retrieve the contents to file.

        :param str file_name: Name of file within that metric controller
        :return: Entire contents of the file
        :rtype: str
        (R"Rt	read_file(RR!tparameter_file((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyt_get_file_contentsAscCs�g}y/|j|�j�}|r.|dn|}Wn�tk
r�|j|�}tjdj|��tdj|���njtk
r�}t	|t
tf�r�|jtj
kr�|�n|j|�}tdj|�|��nX|S(s[
        Retrieve the values of a parameter from a controller.
        Returns a list of values in the file.

        :param first_line_only: return only the first line.
        :param str parameter_name: Name of file within that metric controller
        :return: The first line of the file, without line terminator
        :rtype: [str]
        is#File {0} is empty but should not bes&Exception while attempting to read {0}(R%t
splitlinest
IndexErrorR"RterrorRRt	Exceptiont
isinstancetIOErrortOSErrorterrnotENOENT(Rtparameter_nametfirst_line_onlytresulttvaluestparameter_filenamete((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyt_get_parametersMs

'	cCs�y)|jd�}|r(t|�dkSWn�ttfk
r�}|jtjkrVq�tjtjdj	|j
t|���n;tk
r�}tjtjdj	|j
t|���nXt
S(NttasksisUCould not get list of tasks from "tasks" file in the cgroup: {0}. Internal error: {1}(R5tlenR+R,R-R.Rt
periodic_warntEVERY_HALF_HOURRRRRtFalse(RR6R4((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyt	is_activefscKs
t��dS(sq
        Retrieves the current value of the metrics tracked for this cgroup and returns them as an array
        N(tNotImplementedError(Rt_((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pytget_tracked_metricsys(
RRRRR"R%R:R5R;R>(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyR0s	
				t	CpuCgroupcBsSeZd�Zed�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(cCs_tt|�j||�t�|_d|_d|_d|_d|_	d|_
d|_dS(N(tsuperR?RRt_osutiltNonet_previous_cgroup_cput_previous_system_cput_current_cgroup_cput_current_system_cput_previous_throttled_timet_current_throttled_time(RRR((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyR�s					cCsy|jd�}Wnntk
r�}t|ttf�sM|jtjkrktdjt	|����n|sz|�nd}nXd}|dk	r�tj|�}|s�tdj|j
d�|���nt|j�d�t|j�d�}n|S(s:
        Returns the number of USER_HZ of CPU time (user and system) consumed by this cgroup.

        If allow_no_such_file_or_directory_error is set to True and cpuacct.stat does not exist the function
        returns 0; this is useful when the function can be called before the cgroup has been created.
        scpuacct.stats Failed to read cpuacct.stat: {0}is$The contents of {0} are invalid: {1}iN(R%R)R*R+R,R-R.RRRRBtre_user_system_timestmatchR"tinttgroups(Rt%allow_no_such_file_or_directory_errortcpuacct_statR4t	cpu_ticksRJ((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyt_get_cpu_ticks�s(	
$-cCs�yzttjj|jd���V}x@|D]8}tjd|�}|dk	r+t|j�d�Sq+Wt	d��WdQXWnwt
tfk
r�}|jtj
kr�dStdjt|����n.t	k
r�}tdjt|����nXdS(Nscpu.statsthrottled_time\s+(\d+)isCannot find throttled_timesFailed to read cpu.stat: {0}(topenRRR treRJRBRKRLR)R+R,R-R.RRR(Rtcpu_stattlineRJR4((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyt_get_throttled_time�s!	
cCs|jdk	o|jdk	S(N(RERBRF(R((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyt_cpu_usage_initialized�scCsU|j�rtd��n|jdt�|_|jj�|_|j�|_	dS(su
        Sets the initial values of CPU usage. This function must be invoked before calling get_cpu_usage().
        s2initialize_cpu_usage() should be invoked only onceRMN(
RVRRPtTrueRERAtget_total_cpu_ticks_since_bootRFRURH(R((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pytinitialize_cpu_usage�s
cCs�|j�std��n|j|_|j|_|j�|_|jj�|_|j|j}t	d|j|j�}t
d|jj�t|�t|�d�S(sg
        Computes the CPU used by the cgroup since the last call to this function.

        The usage is measured as a percentage of utilization of 1 core in the system. For example,
        using 1 core all of the time on a 4-core system would be reported as 100%.

        NOTE: initialize_cpu_usage() must be invoked before calling get_cpu_usage()
        sOinitialize_cpu_usage() must be invoked before the first call to get_cpu_usage()igY@i(
RVRRERCRFRDRPRARXtmaxtroundtget_processor_corestfloat(Rtcgroup_deltatsystem_delta((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyt
get_cpu_usage�s	cCsN|j�std��n|j|_|j�|_t|j|j�dS(s�
        Computes the throttled time (in seconds) since the last call to this function.
        NOTE: initialize_cpu_usage() must be invoked before calling this function
        sTinitialize_cpu_usage() must be invoked before the first call to get_throttled_time()ge��A(RVRRHRGRUR](R((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pytget_throttled_time�s
cKsottjtj|j|j��g}d|krk|drk|jttjtj|j|j	���n|S(Nttrack_throttled_time(
tMetricValueRRRRRR`tappendRRa(Rtkwargsttracked((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyR>�s'.(RRRR:RPRURVRYR`RaR>(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyR?�s	 			
		
tMemoryCgroupcBs#eZd�Zd�Zd�ZRS(cCs�d}y|jddt�}WnXtk
ry}t|ttf�r^|jtjkr^�nt	dj
d�|��nXt|�S(s|
        Collect memory.usage_in_bytes from the cgroup.

        :return: Memory usage in bytes
        :rtype: int
        smemory.usage_in_bytesR0s&Exception while attempting to read {0}N(RBR5RWR)R*R+R,R-R.RRRK(RtusageR4((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pytget_memory_usage�s'cCs�d}y|jddt�}WnXtk
ry}t|ttf�r^|jtjkr^�nt	dj
d�|��nXt|�S(s|
        Collect memory.usage_in_bytes from the cgroup.

        :return: Memory usage in bytes
        :rtype: int
        smemory.max_usage_in_bytesR0s&Exception while attempting to read {0}smemory.usage_in_bytesN(RBR5RWR)R*R+R,R-R.RRRK(RRhR4((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pytget_max_memory_usages'cKsFttjtj|j|j��ttjtj|j|j��gS(N(	RcRRRRRRiRRj(RR=((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyR>s!(RRRiRjR>(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyRg�s		(tcollectionsRR-RRRtazurelinuxagent.commonRt azurelinuxagent.common.exceptionRtazurelinuxagent.common.futureRtazurelinuxagent.common.osutilRtazurelinuxagent.common.utilsRtAGENT_NAME_TELEMETRYRctobjectRRtcompileRIRR?Rg(((sA/usr/lib/python2.7/site-packages/azurelinuxagent/common/cgroup.pyt<module>s P|