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

�

)�f�����ddlmZddlmZddlmZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
ddlmZdd	lmZmZdd
lmZmZmZmZddlZdZGd�d
e��ZdS)�)�absolute_import)�division)�rangeN)�sessionmaker)�OperationalError)�func)�reboot_lock)�LveStatsPlugin�LveStatsPluginTerminated)�history�history_x60�history_gov�incident�shamanc�H�eZdZd�Zd�Zd�Zd�Zed���Zd�Z	d�Z
dS)	�HistoryCleanerc��d|_d|_d|_d|_d|_tjd��|_d|_d|_	dS)N�i`T��r�sqlite)
�period�batch�execute_timeout�keep_history_days�	db_engine�logging�	getLogger�log�db_type�	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/cleaners.py�__init__zHistoryCleaner.__init__sL����� ��
�!���!#�������$�%5�6�6�����������c��||_dS)N)r)r#�engines  r$�
set_db_enginezHistoryCleaner.set_db_engine's
������r&c�,�t|�d|j����|_t|�dd����dz|_|�d|j��|_|�dd��|_dS)Nrr�<r r!�	localhost)�int�getrrr r!)r#�configs  r$�
set_configzHistoryCleaner.set_config*s���!$�V�Z�Z�0C�04�0F�&H�&H�"I�"I����&�*�*�X�r�2�2�3�3�b�8����z�z�)�T�\�:�:������K��=�=����r&c�L�t|j|jdzdzdzz
��S)N�r+)r-�nowrr"s r$�time_thresholdzHistoryCleaner.time_threshold1s)���4�8�d�4�R�7��:�2�=�=�>�>�>r&c���tjtjjj��D]=}tjj�d|i��}|�|���>dS)N�uid)�os�listdir�lvestats�lib�snapshot�
SNAPSHOT_PATH�Snapshot�
delete_old)�ts_tor6�snaps   r$�clean_old_snapshotsz"HistoryCleaner.clean_old_snapshots4s^���:�h�l�3�A�B�B�	#�	#�C��<�(�1�1�5�#�,�?�?�D��O�O�E�"�"�"�"�	#�	#r&c	�f�|���}|j�d|z��tj�tjjj	��r|�
|��|j�d��t��5t|j
�����}tj��}	|�|t"t"j|��|�|t&t&j|��|�|t*t*j|��|���|�t3jt6j�����t6j|jk�����dp|}t?tAtC|��|j"ztC|��|j"����D]�\}}|�|t6t6j|��|���tj��|z
|j#kr$|j�d|||z
dz��n<��|�|t6t6j|��|���n�#tH$rE}|�%��|j�&tO|����Yd}~nad}~wtP$rQ|j�d��|�%��|�)��tQ���wxYwtj��|z
dz}	|j�d	|	z��|�)��nO#tj��|z
dz}	|j�d	|	z��|�)��wxYw	ddd��dS#1swxYwYdS)
Nz2Records with timestamp less then %d will be erasedz"Deleting old records from database)�bindrzIterations: %s. Deleted: %shrz&Cleaner terminated. Trying to rollbacki�zExecution time: %d)*r4r�debugr7�path�existsr9r:r;r<rAr	rr�timeit�
default_timer�deleter
�createdr�tsr�incident_end_time�commit�queryr�minr�filterr!�one�	enumeraterr-rrr�rollback�warning�strr�close)
r#�lve_data�t_min�session�
start_time�
first_created�	iteration�	timestamp�e�elapseds
          r$�executezHistoryCleaner.execute:s����#�#�%�%������K�e�S�T�T�T�
�7�>�>�(�,�/�=�>�>�	,��$�$�U�+�+�+�����;�<�<�<�
�]�]�!	 �!	 �7�l���7�7�7�9�9�G��-�/�/�J�
 ����G�[�+�2E�u�M�M�M����G�[�+�.�%�H�H�H����G�X�x�/I�5�Q�Q�Q���� � � � '�
�
�d�h�w��.G�.G� H� H� O� O�PW�Pa�ei�es�Ps� t� t� x� x� z� z�{|� }�!G�BG�
�,5�e�C�
�<N�<N�QU�Q[�<[�]`�af�]g�]g�im�is�6t�6t�,u�,u�%�%�(�I�y��K�K���'�/�9�M�M�M��N�N�$�$�$��+�-�-�
�:�T�=Q�Q�Q�����:�%�&��6�7�C�E�E�E���R��K�K���'�/�5�I�I�I��N�N�$�$�$���#�
)�
)�
)�� � �"�"�"��� � ��Q���(�(�(�(�(�(�(�(�����+�
1�
1�
1�����G�H�H�H�� � �"�"�"��
�
����.�0�0�0�	
1����"�/�1�1�J�>�$�F������3�g�=�>�>�>��
�
������"�/�1�1�J�>�$�F������3�g�=�>�>�>��
�
���������C!	 �!	 �!	 �!	 �!	 �!	 �!	 �!	 �!	 �!	 �!	 �!	 ����!	 �!	 �!	 �!	 �!	 �!	 sR�"1P&�G>K�O	�
M;�;L�O	�AM;�;O	�>AP&�	AP�P&�&P*�-P*c��|�|���||k|j|jk���d���dS)NF)�synchronize_session)rNrPr!rI)r#rY�table�	ts_column�limits     r$rIzHistoryCleaner.deletedsF���
�
�e���
�V�I��%�u��$�.�'H�
I�
I�
�V��V�
.�
.�
.�
.�
.r&N)�__name__�
__module__�__qualname__r%r)r0r4�staticmethodrAr`rI�r&r$rrs���������� � � �>�>�>�?�?�?��#�#��\�#�
( �( �( �T/�/�/�/�/r&r)�
__future__rr�builtinsrr7rrG�sqlalchemy.ormr�sqlalchemy.excr�
sqlalchemyr�lvestats.lib.commons.funcr	�lvestats.core.pluginr
r�lvestats.ormrr
rr�lvestats.lib.snapshotr9�
__author__rrjr&r$�<module>rus+��'�&�&�&�&�&�������������	�	�	�	�����
�
�
�
�'�'�'�'�'�'�+�+�+�+�+�+�������1�1�1�1�1�1�I�I�I�I�I�I�I�I�D�D�D�D�D�D�D�D�D�D�D�D�����
�
�N/�N/�N/�N/�N/�^�N/�N/�N/�N/�N/r&

Hacked By AnonymousFox1.0, Coded By AnonymousFox