관리-도구
편집 파일: statsnotifier.cpython-311.pyc
� �Cg#� � �� � d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZmZ d dlm Z d dl mZ d dlm Z d dlmZ d dlmZ d dl mZ d d lmZmZmZmZmZmZmZ d d lmZmZ d dlmZm Z m!Z! d dl"m#Z# d d l$m%Z%m&Z&m'Z'm(Z( d dl)m*Z+ d dl,m-Z- d dl.m/Z0 d dl1m2Z2 d dl3m4Z4 d dl5m6Z6 d dl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z= d dl>m?Z? d dl@mAZAmBZBmCZCmDZDmEZE d dlFmGZG d dlHm/Z/ n# eI$ r d� Z/Y nw xY wdZJdZKdZLdZMdZNdZOdZPd ZQd!ZR e+� � ZSd"ZTd#geBz d$gz eAz eCz ZU ed%d&eVfd'eVfg� � ZW ed(d)eXfd*eXfd+eXfd,eXfd-eXfd.eXfg� � ZY ed/d0eeX fd1eeX fd2eeX fd3eeX fd4eYfd5eWfd6eWfd7eeZ fd8eeZ fd9eZfd:eeZ fg� � Z[ ed;d3eXfd1eXfd<eXfd4eYfd5eWfd6eWfg� � Z\ G d=� d>ej] j^ j_ � � Z` G d?� d@e4� � ZadA� ZbdS )B� N)�datetime� timedelta)�message_from_string)�Header)� MIMEMultipart)�MIMEText)�reduce)�groupby)�Dict�Iterable�Iterator�List� NamedTuple�Optional�Tuple)�ALL�PrettyTable)�clemail�clproc�cpapi)�LIMIT_LVP_ID)�admins�cpinfo�get_admin_locale�get_user_login_url)�get_admin_email)� MailHelper)�get_notification)�NameMap)�LveStatsPlugin)�dateutil)�deserialize_lve_id�gcd�get_hostname�merge_dicts�serialize_lve_id�user_should_be_notified��mempages_to_bytes)� FIELD_AVERAGE�FIELD_FAULT�FIELD_LIMIT�HistoryShowUnion�get_lve_version)�NotificationsHelperc � � d S �N� ��resellers ��/builddir/build/BUILDROOT/lve-stats-4.2.10-1.el8.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/plugins/generic/statsnotifier.pyr r ; s � ��t� �en_USzadmin_notify.txtzadmin_notify.htmlzuser_notify.txtzuser_notify.htmlzreseller_faults_notify.txtzreseller_faults_notify.htmlzreseller_notify.txtzreseller_notify.htmlz"Hosting account resources exceeded�ID�anyF�NotifySettings�NOTIFY_MIN_FAULTS�NOTIFY_INTERVAL�NotifyFaultsOptions� NOTIFY_CPU� NOTIFY_IO�NOTIFY_IOPS� NOTIFY_MEMORY� NOTIFY_EP�NOTIFY_NPROC� AdminSettings�NOTIFY_ADMIN�NOTIFY_CUSTOMERS_ON_FAULTS�NOTIFY_RESELLER_CUSTOMERS�#NOTIFY_RESELLER_ON_CUSTOMERS_FAULTS�NOTIFY_FAULTS_TYPES�NOTIFY_OPTIONS_SELF�NOTIFY_OPTIONS_CUSTOMER�NOTIFY_FROM_EMAIL�REPORT_ADMIN_EMAIL�NOTIFY_SUBJECT�NOTIFY_CHARSET_EMAIL�ResellerSettings�NOTIFY_RESELLER_ON_TOTAL_FAULTSc � � e Zd ZdS )�StatsNotifierTemplateErrorN)�__name__� __module__�__qualname__r2 r6 r5 rS rS � s � � � � � ��Dr6 rS c �� � e Zd ZdZdZdZdZdZdZd� Z d� Z dBd �Zd� Zd� Z d � Zd� Zd� Zd� Zd� Zd� Zd� Zed� � � Zed� � � ZdCd�Zed� � � Zd� Zd� Zd� Zd� Zdededeeef fd �Z dCd!e!d"ed#efd$�Z"dCd!e!d"ed#ede#fd%�Z$d&� Z%dCd!e!d"ed#efd'�Z&d(� Z'd)� Z(d*� Z)d+� Z*d,� Z+d-� Z,d.� Z-d/� Z.d0ede/fd1�Z0ed2� � � Z1d3� Z2d4� Z3dDd6�Z4d7� Z5d8� Z6d9� Z7d:� Z8d;� Z9d<� Z:d=� Z;d>� Z<d?� Z=d@� Z>dA� Z?dS )E� StatsNotifieri�� i z/usr/share/lve/emails/z/etc/cl.emails.d/r zlocale_defines.jsonc � � d | _ d | _ d| _ t j d� � | _ | � � � t � � | _ t � � | _ i | _ t j � � | _ t � � | _ t# t% j � � � � | _ n/# t$ j t* f$ r t# � � | _ Y nw xY wt- � � | _ d S )N� � statsnotifier)� server_id� db_engine�lve_version�logging� getLogger�log�_load_plugin_settingsr$ �hostnamer �_mail_helper�_reseller_settings_cacher �ProcLve� _proc_lver � _name_map�setr � resellers�NotSupported�AttributeErrorr/ �_notifications��selfs r5 �__init__zStatsNotifier.__init__� s� � �����������$�_�5�5����"�"�$�$�$�$���� �&�L�L���(*��%���)�)��� ����� #� ���!2�!2�3�3�D�N�N���"�N�3� #� #� #� �U�U�D�N�N�N� #����1�3�3����s �%C �)C.�-C.c � � | � � � | _ | � � � | _ | j j j }| j j j }t t ||t j g� � | _ | � � � | j � d| j j � � | j � d| j j � � | j � d| j j � � | j � d| j j � � | j � d| j j j � � | j � d| j j j � � | j � d| j j j � � | j � d| j j j � � | j � d | j j j � � | j � d | j j j � � | j � d| j j j � � | j � d| j j j � � | j � d | j j j � � | j � d| j j j � � | j � d| j j � � | j � d| j j � � | j � d| j j � � | j � d| j j � � | j � d| j d � � dS )z[Re]load all plugin settingszConfig: NOTIFY_ADMIN=%sz%Config: NOTIFY_CUSTOMERS_ON_FAULTS=%sz$Config: NOTIFY_RESELLER_CUSTOMERS=%sz.Config: NOTIFY_RESELLER_ON_CUSTOMERS_FAULTS=%szConfig: NOTIFY_CPU=%szConfig: NOTIFY_IO=%szConfig: NOTIFY_IOPS=%szConfig: NOTIFY_MEMORY=%szConfig: NOTIFY_EP=%szConfig: NOTIFY_NPROC=%sz(Config: NOTIFY_INTERVAL_ADMIN=%s secondsz"Config: NOTIFY_MIN_FAULTS_ADMIN=%sz'Config: NOTIFY_INTERVAL_USER=%s secondsz!Config: NOTIFY_MIN_FAULTS_USER=%szConfig: NOTIFY_FROM_EMAIL=%szConfig: REPORT_ADMIN_EMAIL=%szConfig: NOTIFY_SUBJECT=%szConfig: NOTIFY_CHARSET_EMAIL=%sz<Config: Email subject used if locale_defines.json absent: %s�SubjectN) �get_admin_settings�_admin_settings�get_default_reseller_settings�_default_reseller_settingsrJ r<