관리-도구
편집 파일: stat_sender.cpython-311.pyc
� 9�1g� � �� � d Z dZddlZddlZddlZddlmZ ddlmZ ddl m Z mZ ddlm Z ddlmZ dd lmZmZ dd lmZ ddlmZ ddlmZ d dlmZ d dlmZ ddlmZ ddlm Z ddl!m"Z"m#Z# ddl$m%Z%m&Z&m'Z'm(Z( G d� de� � Z)e*dk rc e&� � ej+ dej, �� � e)� � �- � � dS # e $ rZ. e/e.� � e0d � � �dZ.[.ww xY wdS )zd This module contains SSA classes for sending e-mails with report and sending reports to ClickHouse zssa.modules� N)�EmailMessage)�partial)�Optional�Any)�gethostname)�get_admin_email)�Session�Response)�HTTPAdapter)�RequestException)�Retry� )�Common)� DecisionMaker� )�stat_server)�SSAError)�Mailer�render_report_table)�read_sys_id�sentry_init� duration_cast�format_datec �� � � e Zd ZdZde� d�fdef� fd� Zddeddfd �Zd ede e fd�Zde e fd�Zde e fd �Z d edefd�Zededefd�� � Zdedefd�Zdedefd�Z� xZS )�StatisticsSenderz4 Send report to ClickHouse and over e-mails �https://z /api/clos-ssa�ch_endpointc �: �� t � � � � � t j d� � | _ | j � dt � � t � � | _ || _ t � � | _ t dt dg� � t g d�� � d�� � }t |�� � }t � � | _ | j � d|� � t% | j j d � � � | j _ d S )N�stat_senderzStatisticsSender enabled: %s� �POST)i� i� i� )�total�allowed_methods�status_forcelist�backoff_factor)�max_retriesr � )�timeout)�super�__init__�logging� getLogger�logger�info�__package__r �sys_idr r �mail_senderr � frozensetr r �session�mountr �request)�selfr � retry_conf�adapter� __class__s ��N/opt/cloudlinux/venv/lib64/python3.11/site-packages/ssa/modules/stat_sender.pyr* zStatisticsSender.__init__* s� �� � ���������'� �6�6�������7��E�E�E�!�m�m���&���!�8�8�����+4�f�X�+>�+>�,5�o�o�o�,F�,F�*+�-� -� -� � �*�5�5�5���y�y�������:�w�/�/�/�&�t�|�';�R�H�H�H������ N�report�returnc � � |� t � � � � � }| j r| � |� � | � |� � dS )zi Send given report over e-mail If no report given, get it from DecisionMaker API N)r �get_json_report�summary_notification_enabled�email_report�clickhouse_report)r6 r<