AlkantarClanX12

Your IP : 18.119.28.213


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

�

 tf�����ddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZmZmZmZmZd�Zd�Zejded	efd
���Zd�Zd�Zd
�Zd�Zd�Zdd�ZdS)�N)�cpapi)�get_rhn_systemid_value)�parse)�CLICKHOUSE_WMT_ENDPOINT�UNKNOWN_RHN_ID�SERVICE_BIN�
CHKCONFIG_BIN�
SYSTEMCTL_BINc�T�t��}tjtjkr d�tjd���D��}ntj��}|s|S	tj��}n&#t$rtj	d��g}YnwxYwtjdkr"t��tjj_
|D]X}||vrtjd|���tj|��D]'\}}|�t#|�����(�Y|S)Nc��g|]
}|d��S)r�)�.0�_cpinfos  ��/builddir/build/BUILDROOT/cl-web-monitoring-tool-3.1.3-1.el8.cloudlinux.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/wmt/common/utils.py�
<listcomp>zget_domains.<locals>.<listcomp>"s��L�L�L�����L�L�L�)�cplogin)�keylsz%Cannot obtain list of suspended users�cPanelz<User: %s is will not be pinged, because account is suspended)�setr�CP_NAME�
PLESK_NAME�cpinfo�cpusers�suspended_users_list�	Exception�logging�	exception�dict�plugins�cpanel�_user_to_domains_map_cpanel�warning�userdomains�addr)�domains�users�suspended_users�user�domain�_s      r�get_domainsr,s4���e�e�G��}��(�(�(�L�L�5�<�l�+K�+K�+K�L�L�L����
����������4�6�6����������A�B�B�B���������
�}�� � �;?�6�6��
��8��'�'���?�"�"��O�Z�\`�a�a�a���*�4�0�0�	'�	'�I�F�A��K�K��f�
�
�&�&�&�&�	'��Ns�!A5�5 B�Bc��tj|��}|�tj��	tjd��}tjd��|_|�|��n#t$rYnwxYw|S)Nz/var/log/cl_wmt.logz*[%(levelname)s | %(asctime)s]: %(message)s)	r�	getLogger�setLevel�DEBUG�FileHandler�	Formatter�	formatter�
addHandler�IOError)�logger_name�
app_logger�fhs   r�setup_loggerr9;s����"�;�/�/�J�����
�&�&�&�"�
�
 �!6�
7�
7���(�)U�V�V������b�!�!�!�!��	�
�
�
���
����
�s�A8�8
B�B�file�pidc#�"K�tj�|��sdnd}t||��}	t	j|���tjtjz��n #t$rtd|z���wxYw	|�
|��|���tj|��dV�t	j|���tj
��|���tj|��dS#t	j|���tj
��|���tj|��wxYw)Nzw+zr+zProcess %s already running!)�os�path�exists�open�fcntl�flock�fileno�LOCK_EX�LOCK_NB�OSError�write�flush�fsync�LOCK_UN�close�remove)r:r;�mode�fs    r�save_pid_and_lockrOHs:�����w�~�~�d�+�+�5�4�4��D��T�4���A�;�
��A�H�H�J�J��
��
� =�>�>�>�>���;�;�;��3�c�9�:�:�:�;�����	�������	���	�	�	�
������
����
��A�H�H�J�J��
�.�.�.�	���	�	�	�
�	�$�������	��A�H�H�J�J��
�.�.�.�	���	�	�	�
�	�$�������s�>A6�6B�AD3�3AFc�B�i}|D]}||vr||||f||<�|S)Nr
)�d1�d2�result�keys    r�	intersectrU[s;��
�F��+�+���"�9�9��S�'�2�c�7�*�F�3�K���Mrc��tjd��}td��D]e}	tj||d���}|���dS#tj$r#}|}tjd|z��Yd}~�^d}~wwxYw|�)Nz(Error while sending report to ClickHouse��<)�json�timeout�)�requests�RequestException�range�post�raise_for_status�time�sleep)�url�report�error�i�response�errs      r�send_reportrics����%�&P�Q�Q�E�
�1�X�X�
�
��	��}�S�v�r�B�B�B�H��%�%�'�'�'�

�E�E��	�(�	�	�	��E��J�q�A�v�������������	�����s�+A�B�$B�Bc��td��pt}|�dd��|d<|�d��}t	t
i|�|���dS)N�	system_idzID-��	server_id�summary_report)rr�replace�poprir)rd�
systemd_id�summarys   r�send_report_to_clickhousersrsb��'��4�4�F��J�$�,�,�U�B�7�7�F�;���j�j�)�*�*�G��'�)>�F�)>�g�)>�?�?�?�?�?rc��|rdtjd�t|��ddd���tjd�t|��ddd���d	Stjd�t
��ddd���tjd�t
|��ddd���tjd�t
|��ddd���d	S)
z'
    Enable cl_wmt_scanner service
    z{} {} start >/dev/null 2>&1T�	/bin/bash��shell�
executable�capture_outputz{} --add {} >/dev/null 2>&1z{} daemon-reloadz{} enable {}z{} start {}N��
subprocess�run�formatrr	r
��daemon_name�is_cl6s  r�enable_wmt_daemonr�ys:���P�	��4�;�;�K��U�U�!�k�$�	P�	P�	P�	P���4�;�;�M�;�W�W�!�k�$�	P�	P�	P�	P�	P�	P�	��)�0�0��?�?�!�k�$�	P�	P�	P�	P�	��~�,�,�]�K�H�H�!�k�$�	P�	P�	P�	P���}�+�+�M�;�G�G�!�k�$�	P�	P�	P�	P�	P�	Prc��|rdtjd�t|��ddd���tjd�t|��ddd���dStjd�t
|��ddd���tjd�t
|��ddd���dS)	z)
    Disable WMT daemon
    :return:
    z{} {} stop >/dev/null 2>&1Trurvz{} --del {} >/dev/null 2>&1z{} kill {} >/dev/null 2>&1z{} disable {} >/dev/null 2>&1Nrzr~s  r�disable_wmt_daemonr��s��
�P���3�:�:�;��T�T�!�k�$�	P�	P�	P�	P���4�;�;�M�;�W�W�!�k�$�	P�	P�	P�	P�	P�	P�	��3�:�:�=�+�V�V�!�k�$�	P�	P�	P�	P���6�=�=�m�[�Y�Y�!�k�$�	P�	P�	P�	P�	P�	PrTc�N�d}|r|dg}n|dg}tj|dd���dS)Nz./usr/share/web-monitoring-tool/cron_control.pyz-iz-dT)ry�text)r{r|)�status�	cron_tool�commands   r�manage_cronsr��sB��@�I�
�$��d�#����d�#���N�7�4�d�;�;�;�;�;�;r)T)�
contextlibrrAr=rar\r{�clcommonr�clcommon.utilsr�wmt.common.url_parserr�wmt.common.constrrrr	r
r,r9�contextmanager�strrOrUrirsr�r�r�r
rr�<module>r�s���������������	�	�	�	�������������������1�1�1�1�1�1�'�'�'�'�'�'������������������8
�
�
����C��c�������$������@�@�@�P�P�P�,P�P�P�$<�<�<�<�<�<r