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

�

)�f���ddlZddlmZmZddlmZddlmZddlm	Z	m
Z
ddlmZ
ddlmZddlmZGd	�d
e��ZGd�de��ZdS)
�N)�insert�select)�sessionmaker)�LveStatsPlugin)�
get_chunks�reboot_lock)�user)�history)�serversc�(�eZdZd�Zd�Zd�Zdd�ZdS)�DBSaverc�p�tjd��|_d|_d|_d|_d|_dS)Nzplugin.DBSaverr�<�	localhost)�logging�	getLogger�log�now�config�period�	server_id��selfs ��/builddir/build/BUILDROOT/lve-stats-4.2.8-1.el8.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/plugins/generic/dbsaver.py�__init__zDBSaver.__init__s5���$�%5�6�6������������$�����c��t|�d|j����|_|�d|j��|_dS)N�
db_timeoutr)�int�getrr�rrs  r�
set_configzDBSaver.set_configs<���&�*�*�\�4�;�?�?�@�@������K���@�@����rc�R�tt��}ttg���tj|jk��}tt��}tj����tj|jk��}t��5|j	�
��}|���}	|�|��}|j
r}|���}	|	�C|	d|dkr0|�|�d|di����nG|�||j|d���n#|�||j|d���g}
|�di�����D�]�\}}|
�t'did|�dt)t+|j�����d|j�d|j�d	|j�d
|j�dt)t+|j�����d|j�d
t)t+|j�����d|j�d|j�d|j �dt)t+|j!�����d|j�d|j"�dt)t+|j#�����d|j$�d|j%�dt)t+|j&�����d|j'�d|j(�d|j)�d|j*�dt)t+|j+�����������tY|
��D]?}
	|�||
���#tZ$r|�.|||
���wxYw|�/��n#|�0���xYw	|�1��n#|�1��wxYw	ddd��dS#1swxYwYdS)N�lve_version�LVE_VERSION)rr$�	lve_usage�id�cpu�	cpu_limit�	cpu_fault�mep�	mep_limit�io�io_limit�mem�	mem_limit�	mem_fault�	mep_fault�createdr�lmemphy�memphy�memphy_fault�lnproc�nproc�nproc_fault�io_fault�
iops_fault�liops�iops�)2rr
rr�wherer�	__table__�updater�engine�connect�begin�execute�returns_rows�fetchone�valuesr �items�append�dictr�round�	cpu_usage�lcpur*r+�lep�io_usager-�	mem_usage�lmemr1r2rr4r5r6r7r8r9r:r;r<r=r�
OverflowError�_try_executing_small_chunks�commit�rollback�close)r�lve_data�sql_insert_query�sql_select_servers�sql_insert_servers�sql_update_servers�conn�tx�row�res�sql_insert_list�lve_id�v�chunks              rrEzDBSaver.executes���!�'�?�?��#�W�I�.�.�4�4�W�5F�$�.�5X�Y�Y��#�G�_�_��$�.�5�5�7�7�=�=�g�>O�SW�Sa�>a�b�b��
�]�]�<	�<	��;�&�&�(�(�D������B�9
��l�l�#5�6�6���#�=��,�,�.�.�C����}�-��-�1H�H�H� �L�L�);�)B�)B�M�S[�\i�Sj�Ck�)l�)l�m�m�m�����.�&*�n�(0��(?�%�A�A�A�A�
�L�L�*�"&�.�$,�]�$;�!�=�=�=�
#%��!)���k�2�!>�!>�!D�!D�!F�!F�2�2�I�F�A�#�*�*�4�,1�,1�,1�!�6�,1���a�k� 2� 2�3�3�3�,1�#$�&�&�,1�#$�+�+�	,1�
�E�E�,1�#$�%�%�
,1��u�Q�Z�0�0�1�1�1�,1�"#���,1� ��a�k� 2� 2�3�3�3�,1�#$�&�&�,1�#$�+�+�,1�#$�+�+�,1�!$�E�$�(�O�O� 4� 4� 4�,1�#'�.�.�,1�!"�	�	�,1�  #�5���?�?�3�3�3�!,1�"&'�^�^�#,1�$ !�x�x�%,1�&"�%���.�.�1�1�1�',1�(%&�M�M�),1�*"#���+,1�,$%�<�<�-,1�. �g�g�/,1�0!��q�v���/�/�/�1,1�2�2�2�2�4(��8�8���E�����%5�u�=�=�=�=��(�����8�8��?O�QV�W�W�W�������	�	������
����
�
�
������
�
�
�������
�
���������y<	�<	�<	�<	�<	�<	�<	�<	�<	�<	�<	�<	����<	�<	�<	�<	�<	�<	sU�6.P�%J
O�3N
�	O�
#N-�-O�O5�O�O5� P�5P�P�P �#P �
c��t||��D]F}	|�||���#t$r |j�d|��YdSwxYwdS)a�Try executing smaller chunks so that it will be feasible to log the one causing error.
        In case when data contains value which is bigger than column type can handle, OveflowError is raised.

        :param sqlalchemy.engine.Connection conn: db engine
        :param sqlalchemy.sql.expression.Insert query: query to execute
        :param typing.List[typing.Dict] insert_params: list of params to insert
        :param int chunk_length: length of small chunks
        zOverflow detected in %sN)rrErSr�error)rr]�query�
insert_params�small_chunk_size�small_chunks      rrTz#DBSaver._try_executing_small_chunksds��&�m�5E�F�F�	�	�K�
����U�K�0�0�0�0�� �
�
�
�����8�+�F�F�F�����
����	�	s�+�%A�AN)re)�__name__�
__module__�__qualname__rr"rErTr>rrr
r
s\������%�%�%�A�A�A�C�C�C�J�����rr
c�&�eZdZd�Zd�Zd�Zd�ZdS)�DbUsernamesSaverc�0�d|_d|_d|_dS)NiT)rrB�enabledrs rrzDbUsernamesSaver.__init__vs������������rc�h�|�dd�����dk|_dS)N�collect_usernames�false�true)r �lowerrrr!s  rr"zDbUsernamesSaver.set_config{s-���z�z�"5�w�?�?�E�E�G�G�6�Q����rc��||_dS)N)rB)rrBs  r�
set_db_enginezDbUsernamesSaver.set_db_engine~s
������rc��|jr�t|j�����}|dD]j}t��}|\|_|_|_	|�|��|����P#|�	��Y�hxYw|�
��|���dSdS)N)�bind�users)rrrrB�
user_class�uid�	user_namer�merge�flushrVrUrW)rrX�session�	user_infor	s     rrEzDbUsernamesSaver.execute�s����<�	�4�l���4�4�4�6�6�G�%�g�.�
'�
'�	�!�|�|��;D�8���$�.�$�.�'��M�M�$�'�'�'��M�M�O�O�O�O��'��$�$�&�&�&�&�&�����N�N�����M�M�O�O�O�O�O�	�	s�)A=�=BN)rlrmrnrr"ryrEr>rrrprpusS���������
R�R�R����
�
�
�
�
rrp)r�
sqlalchemyrr�sqlalchemy.ormr�lvestats.core.pluginr�lvestats.lib.commons.funcrr�lvestats.ormr	r}�lvestats.orm.historyr
�lvestats.orm.serversrr
rpr>rr�<module>r�s������%�%�%�%�%�%�%�%�'�'�'�'�'�'�/�/�/�/�/�/�=�=�=�=�=�=�=�=�+�+�+�+�+�+�(�(�(�(�(�(�(�(�(�(�(�(�_�_�_�_�_�n�_�_�_�D�����~�����r

Hacked By AnonymousFox1.0, Coded By AnonymousFox