Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/lvestats/plugins/generic/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/lvestats/plugins/generic/__pycache__/collectors.cpython-311.pyc

�

)�fP
���ddlmZddlmZddlmZddlmZmZddl	m
Z
ddlmZdZ
dZd	ZGd
�de
��ZGd�d
e
��ZGd�de
��ZdS)�)�absolute_import)�clpwd)�LVEStat)�ProcLve�LIMIT_LVP_ID)�LveStatsPlugin)�serialize_lve_idi@Biʚ;�iseletskc�&�eZdZdZd�Zdd�Zd�ZdS)�LVECollectorzl
    Collects data about LVE and LVP usage;
    Uses /proc/lve/list and /proc/lve/resellers/lvpXXX/list
    c��tj���d��|_t	��|_dS)Ni�)r�ClPwd�get_sys_min_uid�min_uidr�	_proc_lve��selfs ��/builddir/build/BUILDROOT/lve-stats-4.2.8-1.el8.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/plugins/generic/collectors.py�__init__zLVECollector.__init__s,���{�}�}�4�4�S�9�9��� �������rc�
�i}|j�|d���D]c}t||j�����}|jdks|j|jkrt
|j|j��}|||<�d|S)z�
        Get information about LVE usage for given lvp_id (container id);
        :type lvp_id: int
        :rtype: dict[int, LVEStat]
        F)�without_limitsr)r�linesr�version�idrr	�reseller_id)r�lvp_id�stats�line�stat�
serialized_ids      r�
__parse_statszLVECollector.__parse_statss������N�(�(���(�F�F�	,�	,�D��4���!7�!7�!9�!9�:�:�D��w�!�|�|�t�w�$�,�6�6� 0���$�:J� K� K�
�'+��m�$���rc��|j���|d<i}|j���rE|j���D]+}|�|�|������,|�|�����|�td��|�di��|d<||d<dS)N�LVE_VERSION)rr�	old_stats)	rr�resellers_supported�lvp_id_list�update�_LVECollector__parse_stats�popr�get)r�lve_datarrs    r�executezLVECollector.execute-s���"&�.�"8�"8�":�":�������>�-�-�/�/�	@��.�4�4�6�6�
@�
@�����T�/�/�v�/�>�>�?�?�?�?�
���T�'�'�)�)�*�*�*�
�	�	�,��%�%�%� (���W�b� 9� 9����!�����rN)r)�__name__�
__module__�__qualname__�__doc__rr)r-�rrrrsP��������#�#�#�����	"�	"�	"�	"�	"rrc� �eZdZd�Zd�Zd�ZdS)�LVEUsernamesCollectorc�0�d|_d|_d|_dS)N�	localhostiT)�	server_id�period�enabledrs rrzLVEUsernamesCollector.__init__:s��$����������rc��|�dd�����dk|_|�d|j��|_dS)N�collect_usernames�false�truer7)r+�lowerr9r7)r�configs  r�
set_configz LVEUsernamesCollector.set_config?sD���z�z�"5�w�?�?�E�E�G�G�6�Q������K���@�@����rc�����jrYtj��}|���}�fd�t	|�����D��|d<dSdS)Nc�8��g|]}|j|j�jf��Sr2)�pw_uid�pw_namer7)�.0�urs  �r�
<listcomp>z1LVEUsernamesCollector.execute.<locals>.<listcomp>Gs&��� e� e� e�1�!�(�A�I�t�~�!F� e� e� er�users)r9rr�
get_user_dict�list�values)rr,�dbrHs`   rr-zLVEUsernamesCollector.executeCsp����<�	f�����B��$�$�&�&�E� e� e� e� e�PT�UZ�Ua�Ua�Uc�Uc�Pd�Pd� e� e� e�H�W����	f�	frN)r.r/r0rr@r-r2rrr4r49sI���������
A�A�A�f�f�f�f�frr4c�4�eZdZdZd�Zed���Zd�ZdS)�CPUInfoCollectorzD
    Collects information on number of cores, and total # of Hz
    c�"�tdd��S)zB
        This should make it trivial to mock up that file
        z
/proc/cpuinfo�r)�openrs r�get_cpuinfo_filez!CPUInfoCollector.get_cpuinfo_fileNs���O�S�)�)�)rc���d}|���}|rF|����d��dkr|dz
}|���}|�Ft|z}||fS)a
        Method that counts number of cores and cpu herz for version > 4.

        In modern lve, cpu usage is always calculated as number of virtual ticks
        on a processor that has 1Ghz frequency on each core.

        :return: procs, total_hz
        r�	processor�)�readliner>�find�GIGAHERZ)�f�procsr�total_hzs    r�countzCPUInfoCollector.countTsu�����z�z�|�|���	 ��z�z�|�|� � ��-�-��2�2���
���:�:�<�<�D�	�	 �
�e�#���h��rc��|���}|�|��\|d<|d<|���dS)NrZ�totalHz)rRr\�close)rr,rYs   rr-zCPUInfoCollector.executejsB���!�!�#�#��15���A���.����8�I�.�	���	�	�	�	�	rN)r.r/r0r1rR�staticmethodr\r-r2rrrNrNJsW��������*�*�*�����\��*����rrNN)�
__future__r�clcommonr�lvestatr�clcommon.clprocrr�lvestats.core.pluginr�lvestats.lib.commons.funcr	�MEGAHERZrX�
__author__rr4rNr2rr�<module>ris��'�&�&�&�&�&�������������1�1�1�1�1�1�1�1�/�/�/�/�/�/�6�6�6�6�6�6�����
�
� "� "� "� "� "�>� "� "� "�Ff�f�f�f�f�N�f�f�f�"#�#�#�#�#�~�#�#�#�#�#r

Hacked By AnonymousFox1.0, Coded By AnonymousFox