Hacked By AnonymousFox

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

�

)�f����ddlZddlZddlZddlZddlmZmZmZddlmZddl	m
Z
ddlmZddl
mZddlmZddlmZmZdd	lmZmZd
Zejej���ejd��Zejd
��Ze�ejd����e� ej!��e�"e��Gd�d��Z#Gd�ded���Z$Gd�de��Z%dS)�N)�	TypedDict�
NamedTuple�Self)�ChainMap)�ProcLve)�PyLve)�LVE_DEFAULT)�LVEStat)�read_raw_config�get_boolean)�OverloadChecker�read_times_from_procz+/var/run/cloudlinux/effective-normal-limits)�level�BurstWatcherz"/var/log/lvestats-burstwatcher.logz%%(asctime)s %(levelname)s %(message)sc�H�eZdZdd�Zdd�Zd�Zdefd�Zd�Zd�Z	d	e
fd
�ZdS)�Service�returnNc�.�t��|_|j���std���t���}|j|_t|j	|j
t���|_i|_
i|_dS)Nzpylve initialization failed)�idle_time_threshold�max_samples_number�	get_stats)r�_pylve�
initialize�RuntimeError�_Config�read_from_config_file�enabled�_enabledr
r�max_samplesr�_overload_checker�_current_bursting_lves�_effective_normal_limits)�self�configs  ��/builddir/build/BUILDROOT/lve-stats-4.2.8-1.el8.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/burstwatcher/service.py�__init__zService.__init__#s����g�g����{�%�%�'�'�	>��<�=�=�=��.�.�0�0�����
�!0� &� :�%�1�*�"
�"
�"
���
')��#�(*��%�%�%�c�,�d}	tjd��|js�|���r=|���|���|���n|dzdkr|���d}|dz
}��)NrT��)�time�sleepr�_is_server_overloaded�_load_effective_normal_limits�_get_current_bursting_lves�_disable_bursting)r#�cnts  r%�runzService.run2s�����
	��J�q�M�M�M��=�
���)�)�+�+�
��2�2�4�4�4��/�/�1�1�1��&�&�(�(�(�(��r��Q����2�2�4�4�4����1�H�C�
	r'c���	ttdd���5}tj|�����}t|��dkr||_ddd��n#1swxYwYnB#tttj	f$r#t�dt��YnwxYwt�dt|j����dS)N�rzUTF-8)�encodingrz7Can`t load cached effective normal limits from file: %sz*Loaded effective normal limits for %s lves)
�open�EFFECTIVE_NORMAL_LIMITS_PATH�json�loads�read�lenr"�OSError�IOError�JSONDecodeError�logger�	exception�debug)r#�f�loaded_effective_normal_limitss   r%r.z%Service._load_effective_normal_limitsCs$��	v��2�C�'�J�J�J�
S�a�15��A�F�F�H�H�1E�1E�.��5�6�6��:�:�4R�D�1�
S�
S�
S�
S�
S�
S�
S�
S�
S�
S�
S����
S�
S�
S�
S�����$�"6�7�	v�	v�	v����V�Xt�u�u�u�u�u�	v�������A�3�t�Gd�Ce�Ce�f�f�f�f�fs5�A2�AA&�A2�&A*�*A2�-A*�.A2�2<B1�0B1c�x�|���}t�d|j��|jS)NzCurent server load: %s)r r?rA�server_load�
is_overloaded)r#�checker_results  r%r-zService._is_server_overloadedMs4���/�/�1�1�����-�~�/I�J�J�J��+�+r'c�����t����fd���d���D��}�fd�|D���_t�d�j��dS)Nc�T��g|]$}t|��������%S�)r
�version)�.0�line�proc_lves  �r%�
<listcomp>z6Service._get_current_bursting_lves.<locals>.<listcomp>Ts/���g�g�g�4�W�T�8�#3�#3�#5�#5�6�6�g�g�gr'T)�without_limitsc����h|]j}|j�j�t|j��i���d��k�K|jdk�Vt|j����kS)�cpur)rRr"�get�str�id)rL�statr#s  �r%�	<setcomp>z5Service._get_current_bursting_lves.<locals>.<setcomp>Vsq���'
�'
�'
�!��x�4�8�<�<�S���\�\�2�N�N�R�R�SX�Y�Y�Y�Y�^b�^e�ij�^j�^j�
���L�L�^j�^j�^jr'zCurrent bursting lves: %s)r�linesr!r?rA)r#�	lve_statsrNs` @r%r/z"Service._get_current_bursting_lvesRs������9�9��g�g�g�g�8�>�>�ae�>�Cf�Cf�g�g�g�	�'
�'
�'
�'
�%.�'
�'
�'
��#�	���0�$�2M�N�N�N�N�Nr'c��|jD]8}|dkrt�d���#|�|���9t�d��dS)N�0zSkipping lve_id=0zDisabled bursting server-wide)r!r?rA�_disable_bursting_for_lve)r#�_ids  r%r0zService._disable_bursting\sc���.�	0�	0�C��c�z�z����0�1�1�1���*�*�3�/�/�/�/����4�5�5�5�5�5r'�id_c
��t�d|��|j�|i��}|j�di��}	|j���}t
|�d|�dtd������|_t
|�d|�dtd������|_	t
|�d|�dtd������|_
t
|�d|�dtd������|_t
|�d|�dtd������|_t
|�d|�dtd������|_
t
|�d	|�d	td	������|_t
|�d
|�d
td
������|_|j�t
|��|d�|�����dS#t$$r}t'j|��Yd}~dSd}~wwxYw)
NzDisabling bursting for LVE %sr[�iorR�ncpu�mem�ep�pmem�nproc�iopsz/Can`t setup lve with id {}; error code {{code}})�err_msg)r?rAr"rSr�liblve_settings�intr	�ls_io�ls_cpu�ls_cpus�	ls_memory�	ls_enters�
ls_memory_phy�ls_nproc�ls_iops�	lve_setup�format�RuntimeWarning�loggingr@)r#r^�
lve_limits�default_limits�lve_settings�rws      r%r\z!Service._disable_bursting_for_lvefs������4�c�:�:�:��2�6�6�s�B�?�?�
��6�:�:�3��C�C��	"��;�6�6�8�8�L�!$�Z�^�^�D�.�:L�:L�T�S^�_c�Sd�:e�:e�%f�%f�!g�!g�L��"%�j�n�n�U�N�<N�<N�u�Va�bg�Vh�<i�<i�&j�&j�"k�"k�L��#&�z�~�~�f�n�>P�>P�QW�Yd�ek�Yl�>m�>m�'n�'n�#o�#o�L� �%(�����~�?Q�?Q�RW�Yd�ej�Yk�?l�?l�)m�)m�%n�%n�L�"�%(�����n�>P�>P�QU�Wb�cg�Wh�>i�>i�)j�)j�%k�%k�L�"�),�Z�^�^�F�N�DV�DV�W]�_j�kq�_r�Ds�Ds�-t�-t�)u�)u�L�&�$'�
���w��@R�@R�SZ�\g�ho�\p�@q�@q�(r�(r�$s�$s�L�!�#&�z�~�~�f�n�>P�>P�QW�Yd�ek�Yl�>m�>m�'n�'n�#o�#o�L� ��K�!�!��C���,�0a�0h�0h�il�0m�0m�
"�
�
�
�
�
���	"�	"�	"���b�!�!�!�!�!�!�!�!�!�����	"���s�JK#�#
L�-L�L)rN)�__name__�
__module__�__qualname__r&r2r.�boolr-r/r0rTr\rJr'r%rr"s�������
+�
+�
+�
+�����"g�g�g�,�t�,�,�,�,�
O�O�O�6�6�6�"�S�"�"�"�"�"�"r'rc�.�eZdZUeed<eed<eed<dS)�
_RawConfig�bursting_enabled� bursting_critical_load_threshold�"bursting_critical_load_samples_numN)rzr{r|r}�__annotations__rTrJr'r%rrs6�����������&)�)�)�)�(+�+�+�+�+�+r'rF)�totalc�J�eZdZUedefd���Zeed<eed<e	ed<dS)rrc�~�	tjttt�����}n8#t
$r+t�d��t��}YnwxYwtddd���}t��}t��}dtdfd	td
fdtdffD][\}}}	||}n#t$rY�wxYw	||��}	n)#t$r}
t|
��||<Yd}
~
�Nd}
~
wwxYw|	||<�\|rLt�d
d�d�|���D����z��t!dit#||����}|���|���z
x}rt�d|��|S)N)r?zConfig file not found!Fg�������?r*)rrrr�rr�rr�rz#Failed to parse some config keys: 
�
c3�,K�|]\}}d|�d|��V��dS)z* z: NrJ)rL�k�es   r%�	<genexpr>z0_Config.read_from_config_file.<locals>.<genexpr>�sK����N�N�"&�!�Q�
�Q�
�
�!�
�
�N�N�N�N�N�Nr'zUsing default values for: %srJ)�typing�castrrr?�FileNotFoundError�warning�dictr�floatri�KeyError�
ValueErrorrT�join�itemsrr�keys�info)
�cls�
raw_config�default_params�external_params�error_by_raw_key�raw_key�	extractor�param�	raw_value�valuer�r#�
defaults_useds
             r%rz_Config.read_from_config_file�s%��	 ���Z���1O�1O�1O�P�P�J�J�� �	 �	 �	 ��N�N�3�4�4�4����J�J�J�	 ������ $��
�
�
��
�&�&���6�6��
��i�8�
/��8M�N�
1�3�
�F�*
�	+�	+�%�G�Y��

�&�w�/�	�	���
�
�
���
����
�!�	�)�,�,�����
�
�
�,/��F�F� ��)����������
����&+�O�E�"�"��	��N�N�A�D�I�I�N�N�*:�*@�*@�*B�*B�N�N�N�E�E��
�
�
��C�C��/�>�B�B�C�C��+�0�0�2�2�_�5I�5I�5K�5K�K�K�M�	G��K�K�6�
�F�F�F��s9�-0�2A%�$A%�:C�
C�C�C � 
D�*D�DrrrN)
rzr{r|�classmethodrrr}r�r�rirJr'r%rr�s[��������+�d�+�+�+��[�+�Z�M�M�M����������r'r)&rur8r+r�rrr�collectionsr�clcommon.clprocr�lveapir�	lvectllibr	�lvestatr
�'lvestats.plugins.generic.burster.configrr�)lvestats.plugins.generic.burster.overloadr
rr7�basicConfig�INFO�	getLoggerr?�FileHandler�handler�setFormatter�	Formatter�setLevel�DEBUG�
addHandlerrrrrJr'r%�<module>r�s���������������
�
�
�
�.�.�.�.�.�.�.�.�.�.� � � � � � �#�#�#�#�#�#�������!�!�!�!�!�!�������P�P�P�P�P�P�P�P�[�[�[�[�[�[�[�[�L�����'�,�'�'�'�'�	��	�>�	*�	*���'�
�B�
C�
C�����&�W�&�'N�O�O�P�P�P������������'����Z"�Z"�Z"�Z"�Z"�Z"�Z"�Z"�z,�,�,�,�,��%�,�,�,�,�1�1�1�1�1�j�1�1�1�1�1r'

Hacked By AnonymousFox1.0, Coded By AnonymousFox