Your IP : 18.220.145.1


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

�

7�gq��"�ddlZddlZddlZddlZddlZddlZddlZddlmZddl	m	Z	m
Z
ddlmZm
Z
mZmZddlmZmZddlmZddlmZddlmZmZdd	lmZdd
lmZddlmZm Z dd
�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'e(dkre'��dSdS)�N)�ArgumentParser)�datetime�	timedelta)�WMT_SCANNER_SERVICE�
WMT_LOCK_FILE�CONFIG_PATH�WMT_DB)�generate_report�report_dict)�setup_database)�set_service_state)�Notifier�SupportedNotificationTypes)�cfg)�CloudlinuxLicenseLib)�send_report_to_clickhouse�manage_crons�successc���|tj��d�}|�|��ttj|dd�����tj|��dS)N)�result�	timestamp�T)�indent�	sort_keys)�time�update�print�json�dumps�sys�exit)r�	exit_code�extra�messages    ��/builddir/build/BUILDROOT/cl-web-monitoring-tool-3.1.4-1.el8.cloudlinux.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/wmt/wmt-api.py�print_result_and_exitr&ss����Y�[�[���G��N�N�5����	�$�*�W��#�%�%�%�&�&�&��H�Y������c�d�tj�t��sdSt	t��5}	tj|���t
jt
j	z��n#t$rYddd��dSwxYw	ddd��n#1swxYwYdS)N�stopped�started)�os�path�existsr�open�fcntl�flock�fileno�LOCK_EX�LOCK_NB�OSError)�fs r%�
get_statusr6*s���
�7�>�>�-�(�(���y�	
�m�	�	���	��K����
�
�E�M�E�M�$A�B�B�B�B���	�	�	����������	����
C��������������������9s4�B%�>A<�;B%�<
B�B%�B�B%�%B)�,B)c�<�tj�t��sdSt	t��5}t|��������}ddd��n#1swxYwYtj	|��r|ndS�N)
r+r,r-rr.�int�read�strip�psutil�
pid_exists)r5�pids  r%�get_scanner_pidr?6s���
�7�>�>�-�(�(����	
�m�	�	�$���!�&�&�(�(�.�.�"�"�#�#��$�$�$�$�$�$�$�$�$�$�$����$�$�$�$��#�C�(�(�2�3�3�d�2s�4A;�;A?�A?c�(�tj��Sr8)r�to_dict�r'r%�
get_configrC>s���;�=�=�r'c��tj|��}t��}|�tj|t
j��|Sr8)r�modifyr?r+�kill�signal�SIGUSR1)�new_json_config�config�scanner_pids   r%�
change_configrLBs;��
�Z��
(�
(�F�!�#�#�K���
���V�^�,�,�,��Mr'c	�
�t��}|�dd���|�dt���|�dd���|�dd���|�dd���|�d	d���|�d
d���|�dd���|���}|jrqt��}tj|d<|�d
��r-d�	|�d
����}||d
<t|���dS|jr5t|j��}tj|d<t|���dS|j
r�ttj�t$�����}t'j��t+d���z
t'j��}}t-t/|||����}t|t'j���d�����dS|jr�td���}t'j�����t+d���z
t'j�����}}t7t-t/|||������t��dS|j�rHt;��dk}|�rtjjr�t?��� ��stdd���t��}t'j�����t+d���z
t'j�����}}t/|||��}tCtj"tj#|tHj%����&��t��dStdtN�dtP�d�d���dS|j)r t;��}	t|	���dS|j*r5tWtNd��tYd���t��dS|j-r5tWtNd��tYd ���t��dS|�.��dS)!Nz--config-get�
store_true)�actionz--config-change)�typez--report-getz--send-clickhousez--send-emailz--statusz--startz--stop�default_report_email�ignore_list�,)rJ)�readonly�)�daysz%Y-%m-%d %H:%M)�report�dateTr*ziCloudLinux license is expired. You may buy new license here: https://lp.cloudlinux.com/cloudlinux-os-solo)r")�target_email�
from_emailrW�notification_typez7Summary report email will not be sent! Please, ensure "z<" service is running and alert_notifications is enabled in "�")�status�start�stopF)/r�add_argument�str�
parse_args�
config_getrCrrQ�get�joinr&�
config_changerL�
report_getrr+r,r-r	r�nowrrr
�strftime�send_clickhouserXr�
send_emailr6�summary_notification_enabledr�get_license_statusrrYrZr�REPORT�notifyrrr]r^r
rr_�
print_help)
�args�optsrJ�tmp_val�enginer^�endrW�is_scanner_runningr]s
          r%�runrwJs������D����n�\��:�:�:����'�c��2�2�2����n�\��:�:�:����)�,��?�?�?����n�\��:�:�:����j���6�6�6����i���5�5�5����h�|��4�4�4��?�?���D���:�����),�)A��%�&��:�:�m�$�$�	,��h�h�v�z�z�-�8�8�9�9�G�$+�F�=�!��V�,�,�,�,�,�,�	
�	�1��t�1�2�2��),�)A��%�&��V�,�,�,�,�,�,�	
��,�������)?�)?�@�@�@���\�^�^�i�Q�&7�&7�&7�7�����s���_�V�U�C�@�@�A�A���V�(�,�.�.�2I�2I�JZ�2[�2[�\�\�\�\�\�\�	
�	�&���.�.�.���\�^�^�(�(�*�*�Y�A�->�->�->�>�����@S�@S�@U�@U�s��!�+�o�f�e�S�.Q�.Q�"R�"R�S�S�S�������	
�� �'�\�\�Y�6���	e�#�'�"F�	e�'�)�)�<�<�>�>�
3�%�'s�01�3�3�3�3�$�%�%�F�!����,�,�.�.���1B�1B�1B�B�H�L�N�N�DW�DW�DY�DY�3�E�$�V�U�C�8�8�F�� �-��>��1K�1R�
�
�
��f�h�h�h�!�#�#�#�#�#�!�#W�5H�#W�#W�HS�#W�#W�#W�bc�
e�
e�
e�
e�
e�
e�
��������V�,�,�,�,�,�,�	
��	��-�w�7�7�7��D�!�!�!�!�������	
����-�v�6�6�6��E�"�"�"�"��������������r'c��	t��dS#t$r*}tddt|�����Yd}~dSd}~wwxYw)N�errorrU)rr"�context)rw�	Exceptionr&ra)�es r%�mainr}�se��K���������K�K�K��W��3�q�6�6�J�J�J�J�J�J�J�J�J�J�����K���s��
A�A�A�__main__)rr))rr/r+rr r<rG�argparserrr�wmt.common.constrrrr	�wmt.common.reportr
r�wmt.dbr�wmt.common.servicer
�wmt.common.notificationrr�
wmt.commonr�	cllicenser�wmt.common.utilsrrr&r6r?rCrLrwr}�__name__rBr'r%�<module>r�s�����������	�	�	�	�����
�
�
�
�
�
�
�
�
�
�
�
�#�#�#�#�#�#�(�(�(�(�(�(�(�(�������������;�:�:�:�:�:�:�:�!�!�!�!�!�!�0�0�0�0�0�0�H�H�H�H�H�H�H�H�������*�*�*�*�*�*�D�D�D�D�D�D�D�D�	�	�	�	�	�	�	�3�3�3�������J�J�J�ZK�K�K��z����D�F�F�F�F�F��r'

?>