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__/analyzers.cpython-311.pyc

�

)�f&���ddlmZddlmZddlZddlmZddlmZdZdZ	dZ
d	Zd
eze
ze	zZdZ
ejd��ZGd
�de��ZGd�de��ZdS)�)�absolute_import)�divisionN)�LVEStat)�LveStatsPlugini)�	cpu_fault�memphy_fault�	mem_fault�io_fault�
iops_fault�	mep_fault�nproc_fault)�lcpu�lmemphy�lmem�io�liops�lep�lnproc)�	cpu_usage�memphy�	mem_usage�io_usage�iops�mep�nproc)�lve_version�time�has_changed_limits�has_changed_nproc�iseletsk�LVEUsagec��eZdZdZd�Zd�ZdS)�LVEUsageAnalyzerzO
    Calculates lve usage and updates it in lve_data, in field 'lve_usage'
    c��||_dS�N)�config)�selfr&s  ��/builddir/build/BUILDROOT/lve-stats-4.2.8-1.el8.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/plugins/generic/analyzers.py�
set_configzLVEUsageAnalyzer.set_configs
�������c��|d}|d}|d=|�dd��}|j|d<|d}|d}i}|���D]�\}}	t|d���}
|�|d��}|
�||	||r
|j|z
nd|��|d	ks.|	jd	ks#|	jd	ks|�|
�||	��r|
||<��|�d
g��}|�|��|g|d<t|�
����|d<||d
<dS)
z'
        :param dict lve_data:
        �stats�	old_stats�old_nowN�totalHz�procs�LVE_VERSION)rr�
lve_usages�
lve_usages_5s�lve_active_ids)�get�now�itemsr!�calcrr�is_lve_data_changed�append�list�keys)
r'�lve_data�	new_statsr-r.�total_hzr0�result�_id�lve_stat�u�lve_stat_oldr2s
             r(�executezLVEUsageAnalyzer.execute!sq��
�W�%�	��[�)�	��[�!��,�,�y�$�/�/��"�h�����I�&����!����&�_�_�.�.�		 �		 �M�C���X�m�%<�=�=�=�A�$�=�=��d�3�3�L�
�F�F�<��8�7�5\�T�X��5G�5G�X\�^c�d�d�d��a�x�x��~��)�)��|�a�'�'�$�0�Q�5J�5J�<�Ya�5b�5b�0���s����\�\�,��3�3�
����&�!�!�!�%+�H���!�%)�&�+�+�-�-�%8�%8��!�"�!+�����r*N)�__name__�
__module__�__qualname__�__doc__r)rE�r*r(r#r#s<����������� ,� ,� ,� ,� ,r*r#c�Z�eZdZeZd�Zdefd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
S)r!c�d�||_d|_d|_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_d|_d|_
d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_dS)NFr)rrrrrrrr	rrrrrrrr
rrrrrr
rrr)r'rs  r(�__init__zLVEUsage.__init__Gs���&�����	�"'���!&��������������������������	���	������
���
���������������
������
���	�����r*�lvestatc���|j|_|�|j|j|��|_|jtz|_|j|_|j|_|jdkr|j	|_	|S)zB
        Prepares LVEUsage obj taking limits from LVEStat
        �)
r�!convert_lcpu_to_new_kernel_format�cpurrr�KBrrr)r'rNr0s   r(�init_limits_from_lvestatz!LVEUsage.init_limits_from_lvestathsp���;����:�:�7�;�;?�;K�;@�B�B��	��*�r�/��������n�����q� � � ��D�J��r*c�"�d}d�t|��D��D]m}t||��}t|ttt
ttd��f��r%|t|���dt|���d�z
}�n|dz
}|S)N�<c3�DK�|]}|�d���|V��dS)�_N)�
startswith)�.0�ks  r(�	<genexpr>z$LVEUsage.__repr__.<locals>.<genexpr>~s3����@�@��a�l�l�3�.?�.?�@�!�@�@�@�@�@�@r*�:z, �>)�dir�getattr�
isinstance�str�int�float�bool�type)r'�representationr[�vs    r(�__repr__zLVEUsage.__repr__|s�����@�@�S��Y�Y�@�@�@�	?�	?�A���a� � �A��!�c�3��t�T�$�Z�Z�@�A�A�
?��s�1�v�v�v�v�s�1�v�v�v�v�">�>����#����r*c���t�j�j�j�jf��rdSt�fd�t
D����rdSdS)NTc3�8�K�|]}t�|��V��dSr%�r`)rZr[r's  �r(r\z2LVEUsage.has_interesting_values.<locals>.<genexpr>�s-�����1�1�Q���a� � �1�1�1�1�1�1r*F)�anyrrrr�FAULTS�r's`r(�has_interesting_valueszLVEUsage.has_interesting_values�sX�������
�D�M�4�9�E�F�F�	��4��1�1�1�1�&�1�1�1�2�2�	��4��ur*c�h�tD])}t||d��t||d��krdS�*dS)�O
        :type old: lvestat.LVEStat
        :type new: lvestat.LVEStat
        NTF)�LIMITSr`)r'�new�old�attrs    r(�_has_changed_limitszLVEUsage._has_changed_limits�sH��
�	�	�D��s�D�$�'�'�7�3��d�+C�+C�C�C��t�t�D��ur*c�"�|j|jkS)rr)r)r'rtrus   r(�_has_changed_nproczLVEUsage._has_changed_nproc�s��
�y�C�I�%�%r*c�"�|dkr|S||zdzS)z`
        New kernel format lcpu is 100 times bigger than previous. So that it's 0-10000
        rP�drJ)r'r�lve_verr0s    r(rQz*LVEUsage.convert_lcpu_to_new_kernel_format�s#���a�<�<��K��%�<�#�%�%r*c���|j|jksp|j|jks`|j|jksP|j|jks@|j|jks0|j|jks |j|jks|j|jkrdS|j|jks0|j	|j	ks |j
|j
ks|j|jkrdS|jdkr|j
|j
krdSdS)z�
        Check if LVE data is changed
        :param old: Previous data
        :param new: Current data
        :return: True - changes, false - not
        TrPF)rrr	rrrrrrrrr
rr)r'rurts   r(r9zLVEUsage.is_lve_data_changed�s����=�C�M�)�)��7�c�g�%�%��=�C�M�1�1��=�C�M�1�1��=�C�M�1�1��7�c�g�%�%��6�S�V�#�#��<�3�<�/�/��4�
�J�#�*�$�$��(8�C�<L�(L�(L��	�S�Y�&�&�#�/�S�_�*L�*L��4���q� � �S�X���%9�%9��4��ur*c�r�||_|�|j|j|��|_t|���r�|�||��|_|�||��|_	|�
Jd���|dks
Jd���|j
|j
kr:ttd|j
|j
z
z|z||zz����|_
|j
|j
kr|j
|j
z
|_
|j|jkr|j|jz
|_|j|jkr|j|jz
|_|j|jkr|j|jz
|_|j|jkr9ttt$|j|jz
z|z����|_|jdkrA|j|jkr1tt|j|jz
|z����|_|j
dkrd|_
n6|j
|jcxkrdkrnn|j|_
|xjdz
c_|j|_|j
dks|j|jcxkrdkrnn
|j|_nd|_
|j|_|j|_|jdks|j|jcxkrdkrnn
|j|_nd|_|j|_|jdkrB|j|_|j|jcxkrdkrnn|j|_|xjdz
c_t$|jz|_|jdkrd|_n6|j|jcxkrdkrnn|j|_|xjdz
c_|j|_|j|_|jdks|j|jcxkrdkrnn
|j|_nd|_|j|_|jdks|j |jcxkrdkrnn|j|_ dSd|_|j |_ dS)Nz)oldstats is not None, but time is unknownrz#oldstats is not None, but time is 0i'rP�)!rrQrRrrrerwrryrrrc�roundr	rrr
rrSrrrrrrrrrr
rrrr)r'rurt�hzrr0s      r(r8z
LVEUsage.calc�sF����	��:�:�3�7�D�DT�V[�\�\��	���9�9�	I�&*�&>�&>�s�C�&H�&H�D�#�%)�%<�%<�S�#�%F�%F�D�"�
�#�#�%P�#�#�#��1�9�9�9�C�9�9�9��}�s�}�,�,�!$�U�5�C�M�C�M�4Q�+R�UZ�+Z�^`�cg�^g�+h�%i�%i�!j�!j����}�s�}�,�,�!$����!>����}�s�}�,�,�!$����!>�����#�"2�2�2�$'�$4�s�7G�$G��!�����0�0�#&�?�S�_�#D�� ��|�c�l�*�*� #�E�"���s�|�0K�*L�t�*S�$T�$T� U� U��
���1�$�$��8�c�h�&�&� #�E�3�8�c�h�+>�$�*F�$G�$G� H� H�D�I��>�A����D�N�N�
�^�t�y�
,�
,�
,�
,�1�
,�
,�
,�
,�
,�!�Y�D�N��N�N�a��N�N��H��	��>�A�������!=�!=�!=�!=�A�!=�!=�!=�!=�!=� �X�D�N�N��D�N� �]�D�N��7����>�A�����3�7�!6�!6�!6�!6�Q�!6�!6�!6�!6�!6��w�D�H�H��D�N��w�D�H���q� � ���D�J��y�D�J�*�*�*�*��*�*�*�*�*� �J��	����1�$����s�v�+����=�1����D�M�M�
�]�d�g�
)�
)�
)�
)��
)�
)�
)�
)�
)� �G�D�M��M�M�Q��M�M��{����j�����q� � �C�J���$@�$@�$@�$@�q�$@�$@�$@�$@�$@��+�D�K�K� !�D���*�D�K���a���3�9�s�z�#=�#=�#=�#=�A�#=�#=�#=�#=�#=���D�J�J�J� �D����D�J�J�Jr*c�f�dt|j��zdzt|j��zdzS)Nz(cpu_usage=z, mep=�))rbrrros r(�__str__zLVEUsage.__str__s.���S���0�0�0��9�#�d�h�-�-�G��K�Kr*c�"�t||��Sr%rl)r'�keys  r(�__getitem__zLVEUsage.__getitem__s���t�S�!�!�!r*N)rFrGrH�
LVEUSAGESLOTS�	__slots__rMrrTrirprwryrQr9r8r�r�rJr*r(r!r!Ds��������I����B������(���������&�&�&�&�&�&����:R#�R#�R#�hL�L�L�"�"�"�"�"r*)�
__future__rr�loggingrNr�lvestats.core.pluginrrSrnrs�STATSr��
__author__�	getLogger�logr#�objectr!rJr*r(�<module>r�s��'�&�&�&�&�&�����������������/�/�/�/�/�/�	��	i��	D��P��R�UZ�Z�]c�c�fl�l�
�
�
��g��
�#�#��(,�(,�(,�(,�(,�~�(,�(,�(,�VX"�X"�X"�X"�X"�v�X"�X"�X"�X"�X"r*

Hacked By AnonymousFox1.0, Coded By AnonymousFox