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

�

)�f������ddlmZddlmZddlZddlZddlZddlZddlZddlZddl	m	Z	m
Z
ddlmZddl
mZddlmZddlmZdd	lmZdd
lmZmZmZddlmZddlmZmZmZmZdd
lm Z!ddl"m#Z$ddl%m&Z&m'Z'ddl(m)Z)ddl*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7m8Z8m9Z9m:Z:m;Z;ddl<m=Z=ddl>m?Z?ddl@mAZAmBZBmCZCmDZDmEZEddlFmGZGddl6mHZHddlImJZJddlKmLZL	ddlMm#Z#n#eN$rd�Z#YnwxYwdZOdZPdZQd ZRd!ZSd"ZTd#ZUd$ZVd%ZWe!��ZXd&ZYd'geCzd(gzeDzeEzZZe1d)d*e[fd+e[fg��Z\e1d,d-e]fd.e]fd/e]fd0e]fd1e]fd2e]fg��Z^e1d3d4e,e]fd5e,e]fd6e,e]fd7e,e]fd8e^fd9e\fd:e\fd;e,e_fd<e,e_fd=e_fd>e,e_fg��Z`e1d?d7e]fd5e]fd@e]fd8e^fd9e\fd:e\fg��ZaGdA�dBejbjcjd��ZeGdC�dDe3��ZfdE�ZgdS)F�)�absolute_import)�divisionN)�datetime�	timedelta)�message_from_string)�Header)�
MIMEMultipart)�MIMEText)�groupby)�cpapi�clproc�clemail)�LIMIT_LVP_ID)�get_user_login_url�get_admin_locale�cpinfo�admins)�get_admin_email)�get_notification)�PrettyTable�ALL)�NameMap)�List�Optional�Tuple�Dict�Iterable�Iterator�
NamedTuple)�LveStatsPlugin)�dateutil)�merge_dicts�deserialize_lve_id�get_hostname�serialize_lve_id�gcd)�
MailHelper��mempages_to_bytes)�get_lve_version�HistoryShowUnion�FIELD_FAULT�
FIELD_AVERAGE�FIELD_LIMIT)�NotificationsHelper)�user_should_be_notified)�map)�reducec��dS�N���resellers ��/builddir/build/BUILDROOT/lve-stats-4.2.8-1.el8.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/plugins/generic/statsnotifier.pyrr8s���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��eZdZdS)�StatsNotifierTemplateErrorN)�__name__�
__module__�__qualname__r5r9r8rVrVvs�������Dr9rVc	���eZdZdZdZdZdZdZdZd�Z	d�Z
dBd
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zed���Zed���ZdCd�Zed���Zd�Zd�Zd�Zd�Zdededeeeffd �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��iz/usr/share/lve/emails/z/etc/cl.emails.d/rzlocale_defines.jsonc��d|_d|_d|_tjd��|_|���t��|_t��|_
i|_tj
��|_t��|_	t#t%j����|_n/#t$jt*f$rt#��|_YnwxYwt-��|_dS)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 r8�__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��|���|_|���|_|jjj}|jjj}tt||tj
g��|_|���|j
�d|jj��|j
�d|jj��|j
�d|jj��|j
�d|jj��|j
�d|jjj��|j
�d|jjj��|j
�d|jjj��|j
�d|jjj��|j
�d	|jjj��|j
�d
|jjj��|j
�d|jjj��|j
�d|jjj��|j
�d
|jjj��|j
�d|jjj��|j
�d|jj��|j
�d|jj��|j
�d|jj��|j
�d|jj��|j
�d|jd��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_settingsrMr?rNr2r&r[�
MIN_PERIOD�period�_prepare_default_mail_headersrd�inforHrIrJrKrLrArBrCrDrErFr>rOrPrQrR�mail_headers)rr�notify_interval_admin�notify_interval_userss   r8rez#StatsNotifier._load_plugin_settings�s���#�7�7�9�9���*.�*M�*M�*O�*O��'�!%� 4� H� X�� $� 4� L� \����'�)>�
�@X�Y�[�[���	
�*�*�,�,�,���
�
�/��1E�1R�S�S�S���
�
�=�t�?S�?n�o�o�o���
�
�<�d�>R�>l�m�m�m���
�
�F��H\�IA�	B�	B�	B���
�
�-�t�/C�/W�/b�c�c�c���
�
�,�d�.B�.V�.`�a�a�a���
�
�.��0D�0X�0d�e�e�e���
�
�0�$�2F�2Z�2h�i�i�i���
�
�,�d�.B�.V�.`�a�a�a���
�
�/��1E�1Y�1f�g�g�g���
�
�@�$�BV�Bj�Bz�{�{�{���
�
�:�D�<P�<d�<v�w�w�w���
�
�?��AU�Am�A}�~�~�~���
�
�9�4�;O�;g�;y�z�z�z���
�
�4�d�6J�6\�]�]�]���
�
�5�t�7K�7^�_�_�_���
�
�1�4�3G�3V�W�W�W���
�
�7��9M�9b�c�c�c���
�
�T�VZ�Vg�hq�Vr�s�s�s�s�sr9Fc#�PK�|j���rv|j���D]\}|j�|��}|�|j�d|���:|�|��}||p|jfV��]|r|j	|j
fV�dSdS)NzeUnable to obtain notify settings: reseller %s exists in /proc/lve/resellers, but is absent in ve.cfg.)rj�resellers_supported�lvp_id_listrk�get_namerd�warning�get_reseller_settingsry�ADMIN_LVP_IDrw)rr�
with_admin�reseller_id�
reseller_name�reseller_settingss     r8�_get_resellers_settingsz%StatsNotifier._get_resellers_settings�s������>�-�-�/�/�	X�#�~�9�9�;�;�
X�
X�� $�� 7� 7�� D� D�
� �(��H�$�$�&X�Yd�f�f�f��$(�$>�$>�}�$M�$M�!�!�#4�#W��8W�W�W�W�W�W��	:��#�T�%9�9�9�9�9�9�9�	:�	:r9c�Z����d���}�fd�}t||��S)z�
        We do not need resellers with disabled
        NOTIFY_CUSTOMERS_ON_FAULTS notifications,
        also we do not need those resellers,
        whose customers were notified recently.
        Let's remove such resellers from check-list.
        T�r�c�f��|\}}|jo$�j�||jj��Sr4)rIrp�users_need_notificationrNr?)�reseller_notify_settingsr��notify_optionsrrs   �r8� _filter_by_enabled_notificationszWStatsNotifier._get_customers_options_filtered.<locals>._filter_by_enabled_notifications�sB���,D�)�[�.�!�<�w��&�>�>�{�?M�?e�?u�w�w�
wr9�r��filter�rr�resellers_settingsr�s`  r8�_get_customers_options_filteredz-StatsNotifier._get_customers_options_filtered�sT���"�9�9�T�9�J�J��	w�	w�	w�	w�	w��6�(�*�*�	*r9c�L�d�}t|���|��S)z�
        If some resellers have same settings
        for notify we can send notifications to
        their users using only one database request.
        For that, we must group them by customers settings
        c�(�|\}}|j|jfSr4)rNrL)�customers_notify_settings�_r�s   r8�_group_by_customers_optionszQStatsNotifier._get_customers_options_grouped.<locals>._group_by_customers_options�s��";��Q��!�9�>�;]�]�]r9)rr�)rrr�s  r8�_get_customers_options_groupedz,StatsNotifier._get_customers_options_grouped�s3��	^�	^�	^�
�t�;�;�=�=�?Z�[�[�[r9c�V������}�fd�}t||��S)z�
        We do not need resellers with disabled notifications at all
        also we do not need resellers that were notified recently.
        Let's remove such resellers from check-list.
        c�f��|\}}|jo$�j�||jj��Sr4)rTrp�reseller_need_notificationrMr?)�reseller_notify_optionsr�r�rrs   �r8r�zWStatsNotifier._get_resellers_options_filtered.<locals>._filter_by_enabled_notifications�sB���,C�)�[�.�!�A�z��*�E�E�k�FT�Fh�Fx�z�z�
zr9r�r�s`  r8�_get_resellers_options_filteredz-StatsNotifier._get_resellers_options_filtered�sO���"�9�9�;�;��	z�	z�	z�	z�	z��6�(�*�*�	*r9c�P�|���}d�}t||��S)z�
        If some resellers have same settings
        for notifywe can send them notifications
        using only one database request.
        For that, we must group them by settings
        c�(�|\}}|j|jfSr4�rMrL)�reseller_options_groupedr�r�s   r8�_group_by_self_optionszLStatsNotifier._get_resellers_options_grouped.<locals>._group_by_self_optionss��":��Q��!�5�~�7Y�Y�Yr9)r�r�rrr�r�s   r8�_get_resellers_options_groupedz,StatsNotifier._get_resellers_options_groupeds<��"�A�A�C�C��	Z�	Z�	Z�
�)�+A�B�B�Br9c�Z����d���}�fd�}t||��S)z5Get resellers with enabled NOTIFY_ON_CUSTOMERS_FAULTSTr�c�f��|\}}|jo$�j�||jj��Sr4)rKrpr�rMr?)r�r�r�rrs   �r8r�zgStatsNotifier._get_reseller_customers_faults_options_filtered.<locals>._filter_by_enabled_notificationssB���,>�)�[�.�!�E�v��&�A�A�+�BP�Bd�Bt�v�v�
vr9r�r�s`  r8�/_get_reseller_customers_faults_options_filteredz=StatsNotifier._get_reseller_customers_faults_options_filteredsT���"�9�9�T�9�J�J��	v�	v�	v�	v�	v��6�(�*�*�	*r9c�P�|���}d�}t||��S)Nc�(�|\}}|j|jfSr4r�)�reseller_customers_settingsr�r�s   r8r�z]StatsNotifier._get_resellers_customers_faults_options_grouped.<locals>._group_by_self_options(s��"=��Q��!�5�~�7Y�Y�Yr9)r�rr�s   r8�/_get_resellers_customers_faults_options_groupedz=StatsNotifier._get_resellers_customers_faults_options_grouped$s:��!�Q�Q�S�S��	Z�	Z�	Z�
�)�+A�B�B�Br9c�:�d|jjpti|_dS)Nru)rwrQ�DEFAULT_SUBJECTr~rqs r8r|z+StatsNotifier._prepare_default_mail_headers/s$��
�t�+�:�M�o�
����r9c�<�|�dd��|_dS)Nr_�	localhost)�getr_)rr�configs  r8�
set_configzStatsNotifier.set_config5s�����K��=�=����r9c�H�||_t||j��|_dSr4)r`r*r_ra)rr�engines  r8�
set_db_enginezStatsNotifier.set_db_engine8s#�����*�6�4�>�B�B����r9c�x�	t|��S#tj$rd�|���cYSwxYw)Nzhttp://{domain}/��domain)rrrn�formatr�s r8�_get_panel_login_urlz"StatsNotifier._get_panel_login_url<sP��	<�%�f�-�-�-���!�	<�	<�	<�%�,�,�F�,�;�;�;�;�;�	<���s��%9�9c�\�tj|���d��dS)N�.r)�locale�	normalize�split)�
localenames r8�get_localeszStatsNotifier.get_localesDs(����
�+�+�1�1�#�6�6�q�9�9r9Nc��tj��}|t|���z
}|�|��}|sgSt	|j|||jtd|||��	�	}|���}	g}
|	D]~}||d<|�	d�|�
��D����|�	d�|�
��D����|
�|���|
S)z2
        Get statistics for given period;
        )�secondsr<)r_�show_columns�order_by�by_fault�	threshold�uid�PERIODc�B�i|]\}}|dv�	|t|��dz��S�)�aVMem�aPMem�lVMem�lPMem�r(��.0�key�vals   r8�
<dictcomp>z1StatsNotifier.get_users_fault.<locals>.<dictcomp>asD��A�A�A���c��?�?�?��'��,�,��4�?�?�?r9c�(�i|]\}}|dv�	||dz��S))�aIO�lIOr�r5r�s   r8r�z1StatsNotifier.get_users_fault.<locals>.<dictcomp>fs6��+�+�+�h�c�3��>�)�)��c�T�k�)�)�)r9)r�utcnowr�_get_faults_keysr+r`r_�
FIELDS_ALL�proceed_dict�update�items�append)rrr{�notify_min_faults�notify_faults_types�uids�	period_to�period_from�by_fault_arg�history_show�users_fault_data�users_stats�	user_stats            r8�get_users_faultzStatsNotifier.get_users_faultIsK��
�O�%�%�	��)�F�";�";�";�;���,�,�-@�A�A���	��I�'��N�K��d�n�#�f�|�'�T�3�3�3��(�4�4�6�6����)�
	*�
	*�I�"(�I�h��
���A�A�Y�_�_�EV�EV�A�A�A�
B�
B�
B�

���+�+�)�/�/�2C�2C�+�+�+�
,�
,�
,�
���y�)�)�)�)��r9c
��tjgd�|j|j|j|j|j|j|jg��}t|��S)z�
        Get list of keys for 'by_faults';
        If reseller_settings is not None, use admin settings;
        Else - use reseller's settings;
        )�CPUf�VMemF�PMemF�EPf�NprocF�IOf�IOPSf)	�	itertools�compressrArDrErFrBrC�list)�notify_types_optionsr�s  r8r�zStatsNotifier._get_faults_keysls^��!�)�G�G�G�$�/�$�2�$�2�$�.�$�1�$�.�$�0�
2�	3�	3���L�!�!�!r9c#�hK�|D]�}t|d��\}}|j�|��|d<	tj|ddd���d}n!#tjjtf$rY�ywxYw|d|d<|�|dpd	��|d
<|V���dS)z<
        Get information about reseller's accounts;
        r;�LOGIN��mailr�F��keyls�search_sys_usersr�TOMAIL��en�LOCALEN)	r#rkr�rr�cpapiexceptionsrn�
IndexErrorr�)rr�faults_data�
reseller_datar�r��cp_userinfos      r8�_get_resellers_dataz!StatsNotifier._get_resellers_data�s�����
)�	 �	 �M�/�
�d�0C�D�D�N�K��%)�^�%<�%<�[�%I�%I�M�'�"�
�#�l�!�'�*�,�%*�,�,�,�-.�/�����)�6�
�C�
�
�
���
����'2�!�n�M�(�#�&*�&6�&6�{�1�~�7M��&N�&N�M�(�#������	 �	 s�#A!�!A?�>A?c���g}|D�]g}tt|d����\}}	tj|��}|j|d<|j�d��d|d<n#t$rY�wwxYw	tj	|dd���d}n!#ttjjf$rY��wxYw|d|d<|d	|d
<|�
|dpd��|d
<|d|d<|d|d<|j|d<|�|d	��|d<|�|d��|d<|�|����i|S)z<
        Get information about end user's accounts;
        r;r��,r�TONAME)r�dnsr�r7�rrr�DOMAIN�rr��RESSELER�RESELLER�HOSTNAME�	LOGIN_URL�FROMMAIL)r#�int�pwd�getpwuid�pw_name�pw_gecosr��KeyErrorrrr	rrnr�rfr��_get_notify_from_mailr�)rr�fault_users_data�
users_data�	user_data�user_idr��
user_pwd_datars        r8�get_users_datazStatsNotifier.get_users_data�s���
�
�)�	)�	)�I�+�C�	�$��,@�,@�A�A�J�G�Q�
� #��W� 5� 5�
�%2�%:�	�'�"�&3�&<�&B�&B�3�&G�&G��&J�	�(�#�#���
�
�
���
����
�#�l��g�&�?�A�A�A�AB�D������ 5� B�C�
�
�
���
����#.�a�.�I�h��"-�a�.�I�h��"&�"2�"2�;�q�>�3I�T�"J�"J�I�h��$/��N�I�j�!�%0��N�I�j�!�$(�M�I�j�!�%)�%>�%>�{�1�~�%N�%N�I�k�"�$(�$>�$>�y��?T�$U�$U�I�j�!����i�(�(�(�(��s$�AA0�0
A=�<A=�"B$�$C�Cc���|jj}||jvra	tj|dd���dd}n<#t
tjjf$r|j�	d|��YnwxYw|S)z�
        If reseller is admin -> send email from admin's mail
        If reseller is reseller -> send email from reseller's mail
        )rFrrz/can't obtain notify_from_mail for %s from cpapi)
rwrOrmrrr	rrnrd�	exception)rrr7�	from_mails   r8r!z#StatsNotifier._get_notify_from_mail�s����(�:�	��t�~�%�%�
`�!�L��/8�:?�A�A�A�AB�D�DE�G�	�	���� 5� B�C�
`�
`�
`���"�"�#T�V^�_�_�_�_�_�
`�����s�#;�6A4�3A4c���	|jjptj��}n#tj$rd}YnwxYw|s$t
}|j�d|z��|S)z�
        Determine server admin email;
        Priority:
        1. report_admin_email from config
        2. cpapi.get_admin_email()
        3. DEFAULT_ADMIN_MAIL
        NzQCan't obtain admin email from control panel. System admin email will be used '%s')rwrPrrrn�DEFAULT_ADMIN_MAILrdr�)rr�emails  r8�_detect_admin_emailz!StatsNotifier._detect_admin_email�s���	��(�;�V�u�?T�?V�?V�E�E���!�	�	�	��E�E�E�	�����	m�&�E��H���c�fk�k�
m�
m�
m��s�"�6�6�locale_name�templ_filename�returnc�`�tj�|j|��}tj�||��}tj�|��r||fStj�|j|��}|tj�||��fS)a�
        Detects path for specified file. Checks directories in order:
            1. self.TEMPLATE_CUSTOM_DIR = '/etc/cl.emails.d/<locale_name>'
            2. self.TEMPLATE_DIR = '/usr/share/lve/emails/<locale_name>'
        :param locale_name: locale name to check
        :param templ_filename: template filename (without path)
        :return: Tuple: (file_dir, full_path_to_file)
        )�os�path�join�TEMPLATE_CUSTOM_DIR�exists�TEMPLATE_DIR)rrr/r0�
templates_dir�
full_filenames     r8�_detect_path_for_filez#StatsNotifier._detect_path_for_file�s�������T�%=�{�K�K�
�����]�N�C�C�
�
�7�>�>�-�(�(�	0� �-�/�/�����T�%6��D�D�
��b�g�l�l�=�.�I�I�I�Ir9�
templ_data�text_templ_name�html_templ_namec
�0�|�dt��}|�||��\}}tj�|��rtj�|��s:t
jd||t��|�t|��\}}|rWtj�||��}tj�|��st
jd|��d}nd}|}|�	|��}		|	d|d|d<n#t$rYnwxYw	tj|d��\}
}	|	d|}n#t$r|}YnwxYw|
�d|��|d<n#t$rYnwxYwd}
	tj�||���\}}|r&|}tj�||���\}}
n�#tjjjt&f$rg}t)d	�|�d
��tj�||��t-|�������d}~wwxYw|	�d|��}|||
fS)Nra"Unable to find templates for locale '%s': file '%s' does not exist. Statsnotifier will use default templates with locale %s. See https://docs.cloudlinux.com/cloudlinux_os_components/#customize-lve-stats2-notifications in order to find how to create localized template and hide this warning.aUnable to find optional HTML message template '%s'. Sending email with only TEXT part.You can safely ignore this message if you do not want to use HTML email templates.See https://docs.cloudlinux.com/cloudlinux_os_components/#customize-lve-stats2-notificationsr�	user_typer�� )r<zACan not generate message for user "{}"; template "{}". Jinja2: {}r��NOTIFY_FROM_SUBJECT)r��DEFAULT_LOCALEr;r3r4r7rbr}r5�_load_locales_datar r!�seconds_to_human_viewr�ClEmail�generate_mail_jinja2�jinja2�
exceptions�
TemplateError�IOErrorrVr��str)rrr<r=r>r/r9�text_templ_path�html_templ_path�_templ_name�locale_defines�number�english_name�localized_period_name�	html_body�subject�	text_bodyr��e�	s_subjects                   r8�generate_msg_bodyzStatsNotifier.generate_msg_body�s��� �n�n�X�~�>�>��)-�)C�)C�K�Q`�)a�)a�&�
���w�~�~�m�,�,�	i�B�G�N�N�?�4S�4S�	i��L�\��_�n�
>�
>�
>�.2�-G�-G��Xg�-h�-h�*�M�?��	#� �g�l�l�=�/�J�J�O��7�>�>�/�2�2�
'���s�
$�
%�%�%�#'���"�O�%���0�0��?�?��	�#1�(�#;�J�{�<S�#T�J�x� � ���	�	�	��D�	����	�#+�#A�*�X�BV�#W�#W� �F�L�
5�(6�x�(@��(N�%�%���
5�
5�
5�(4�%�%�%�
5����&,�#F�#F�/D�#F�#F�J�x� � ���	�	�	��D�	�����	�	E�!(��!E�!E�o�bl�!E�!m�!m��G�Y��
l�-��&��C�C�O�`j�C�k�k���9�����)�7��A�	E�	E�	E�,��#�V��N�N�7�+�+��G�L�L��k�:�:�C��F�F�D�D�E�E�
E�����	E����#�&�&�'<�g�F�F�	��)�Y�.�.sb� D8�8
E�E�	F�'E6�5F�6F�F�F�
F�
F �F �&AG3�3 I:�A"I5�5I:c���|�|||��\}}}|r�|�|jjd���|jj��}|�|jjd���|jj��}td��}|�t|d|jj����|�t|d|jj����n�|�|jjd���|jj��}t|��}|�	dd|jjz��|�	dd��t|p|jd	d
�����|d	<|�d��p|jj
|d<|d
|d<|S)N�xmlcharrefreplace�alternative�plain�htmlzContent-Typeztext/plain; charset="%s"zContent-Transfer-Encoding�8bitruzutf-8r�Fromr�To)rY�encoderwrR�decoder	�attachr
r�
add_headerrr~r�rO)rrr<r=r>rUrVrT�msgs        r8�generate_msgzStatsNotifier.generate_msg7s���(,�(>�(>�z�?�\k�(l�(l�%���I��	@�!����,�A�CV�W�W����,�A�B�B�
�"����,�A�CV�W�W����,�A�B�B�
� �
�.�.�C��J�J�x�	�7�D�4H�4]�^�^�_�_�_��J�J�x�	�6�4�3G�3\�]�]�^�^�^�^�!�(�(��)=�)R�Tg�h�h����,�A�B�B�
�%�i�0�0�C��N�N�>�+E��H\�Hq�+q�r�r�r��N�N�6��?�?�?� �� G�4�+<�Y�+G��Q�Q�X�X�Z�Z��I�� �n�n�Z�0�0�Z�D�4H�4Z��F���x�(��D�	��
r9c��d�|d�d��D��}|j�|d|||jj���dS)Nc�6�g|]}|�����Sr5)�strip)r�r�s  r8�
<listcomp>z*StatsNotifier.send_msg.<locals>.<listcomp>Ws ��<�<�<�!�A�G�G�I�I�<�<�<r9rarr`)�
encoding_name)r�rg�sendmailrwrR)rrrf�to_addrss   r8�send_msgzStatsNotifier.send_msgVsU��<�<�s�4�y���s�';�';�<�<�<����"�"�3�v�;��#�T�Ma�Mv�"�w�w�w�w�wr9c���	|�|||��}|�|��dS#t$r2}|j�t|����Yd}~dSd}~wwxYwr4)rgrorVrdr�rL)rrr<r=r>rfrWs      r8�send_notificationzStatsNotifier.send_notificationZs���	%��#�#�J���Q�Q�C��M�M�#�������)�	%�	%�	%��H���S��V�V�$�$�$�$�$�$�$�$�$�����	%���s�,0�
A,�'A'�'A,c�:��t�fd�|D����S)Nc3�0�K�|]}|�dkV��dS)rNr5)r��user�column_names  �r8�	<genexpr>z+StatsNotifier._has_fault.<locals>.<genexpr>bs-�����<�<�T�4��$�q�(�<�<�<�<�<�<r9)�any)rrru�faultss ` r8�
_has_faultzStatsNotifier._has_faultas&����<�<�<�<�V�<�<�<�<�<�<r9c����	�gd��	tjddgddgddgdd	gd
dgdd
gg|jo|�d���|jo|�d���|jo|�d���|jo|�d���|jo|�d���|jo|�d���g��}�	�t|g����|j
dkr4|jr-|�d���r�	�ddg��d��	D��}t���dkrdS�	�fd�}t|��}d|_d|_t!t#|j|������|���}|�ddt*t*���}||fS)z,Generate summary table with info about users))�Usernamer�)�Domainr)�Name�FROMNAME)zCPU Limit, %�lCPU)z
CPU Faultsr�)zVMem Limit, KBr�)zVMem Faultsr�)zPMem Limit, KBr�)zPMem Faultsr�)zEP Limit�lEP)z	EP Faultsr�)zNPROC Limit�lNproc)zNPROC Faultsr�)zIO Limit, KB/sr�)z	IO Faultsr�r�r�r�r�r�r�r]r�)z
IOPS Limit�lIOPS)zIOPS Faultsr�c��g|]\}}|��Sr5r5)r��headerr�s   r8rkz6StatsNotifier._generate_table_data.<locals>.<listcomp>~s��9�9�9�i�f�a�6�9�9�9r9r)NNc����t��}�D]Y}g}�D]=\}}t|�|d����}|�|���>|�|���Z|S)Nz---)r�rLr�r�)�table_b�data�
table_liner��
user_data_key�cell�
table_columnsr#s      ��r8�gen_table_bodyz:StatsNotifier._generate_table_data.<locals>.gen_table_body�s�����f�f�G�"�
+�
+���
�(5�,�,�$�A�}��t�x�x�
�u�=�=�>�>�D��%�%�d�+�+�+�+����z�*�*�*�*��Nr9�=T)r��border�hrules�vrules)r�r�rAryrDrErFrB�extend�sumrarC�lenr�horizontal_char�
junction_charr�r1�add_row�
get_string�get_html_stringr)
rrr#r��additional_columns�columnsr��table�s_table�s_html_tabler�s
 `       @r8�_generate_table_dataz"StatsNotifier._generate_table_datads7����\�[�[�
�&�/�)�+A�B�,�.F�G�,�.F�G�$�&:�;�*�,F�G�*�,@�A�

�%�/�W�D�O�O�F�J�4W�4W�$�2�[�t���w�PZ�7[�7[�$�2�[�t���w�PZ�7[�7[�$�.�U�4�?�?�5�*�3U�3U�$�1�[�d�o�o�h�PZ�6[�6[�$�.�U�4�?�?�5�*�3U�3U�

�
�
��$	���S�!3�R�8�8�9�9�9���a���#�/�
Z�D�O�O�G�Z�4X�4X�
Z��$�$�&=�?W�%X�Y�Y�Y�9�9�=�9�9�9���z�?�?�a����:�	�	�	�	�	�	��G�$�$�� #���!����S����� 0� 0�
1�
1�2�2�2��"�"�$�$���,�,�D�48�47�47�-�9�9����$�$r9c��t|d�|���D����}|�d�|���D����|S)z�
        Extend keys in new mode register ('aCPU' => 'acpu'),
        correct 'aVMem', 'aPMem', 'lVMem', 'lPMem'
        for backward compatibility with old templates
        c�>�i|]\}}|���|��Sr5)�lower)r��k�vs   r8r�z8StatsNotifier._prepare_template_data.<locals>.<dictcomp>�s&��C�C�C���A����	�	�1�C�C�Cr9c�(�i|]\}}|dv�	||dz��Sr�r5)r�r��vars   r8r�z8StatsNotifier._prepare_template_data.<locals>.<dictcomp>�s7��
=�
=�
=���c��;�;�;��#��*�;�;�;r9)r"r�r�)rrr$�templ_data_dicts   r8�_prepare_template_dataz$StatsNotifier._prepare_template_data�s|��&��C�C����1B�1B�C�C�C�E�E��
	���
=�
=�_�-B�-B�-D�-D�
=�
=�
=�	>�	>�	>��r9c���|D]h}d|d<|�d��stjd���1|�|��}|�|t
t����idS)z�
        Send email to each user in 'users_data',
        with given template path in 'templ_name'
        :type users_data: collections.Iterable[dict]
        :return: Nothing
        �customerr@rz,User %s has not set email, skip notification�r<r=r>N)r�rb�debugr�rq�
USER_TEMPL�USER_TEMPL_HTML)rrr#r<�user_template_datas    r8�
_notify_userszStatsNotifier._notify_users�s���%�		D�		D�J�&0�J�{�#��>�>�(�+�+�
��
�L�M�M�M��!%�!<�!<�Z�!H�!H���"�"�.@�3=�3B�
#�
D�
D�
D�
D�		D�		Dr9c
�>�|jjrt|jj��sdS|j�|jjj��sdS|j���|jjj}|�	||jjj
|jjt|j�
d�������}|�|���}|sdS|�||jj��\}}|s|j�d��dS|||jj|�t)����|���|dd|jd�	}|�|t0t2���d	S)
Nr�r{r�r�r��r"z6During admin check, no users faults found. Skipping...�
Administrator�admin)	�STATS�
STATS_HTMLrrrr�rr@rr�T)rwrHrwrLrp�admin_need_notificationrMr?�mark_admin_notifiedr�r>r�rj�lve_id_listr'r�rdr�rOr�rr.rfrq�ADMIN_TEMPL�ADMIN_TEMPL_HTML)rrr{r�r#�s_text_tabler��admin_template_datas       r8�_check_adminzStatsNotifier._check_admin�s����$�1�	�c�$�:N�:b�6c�6c�	��F��"�:�:�4�;O�;c�;s�t�t�	��F���/�/�1�1�1��%�9�I���/�/�v�BF�BV�Bj�B|�DH�DX�Dl�59�$�.�:T�:T�UV�:W�:W�5X�5X�0�Z�Z���(�(�:J�(�K�K�
��	��F�%)�%>�%>���,�@�&B�&B�"��l��	��H�N�N�S�T�T�T��F�"�&��,�>��&�&�'7�'9�'9�:�:��.�.�0�0��%� ��
�	'�	'��	
���*=�/:�/?�	�	A�	A�	A��tr9c��	tj|dd���d}n5#tttjjf$rt
��cYSwxYw|d|�|dpd��|d�S)Nr�Frrrr)rr�RESELLER_USERNAME)rrrKr	rrn�dictr�)rr�reseller_login�panel_user_datas   r8�get_panel_reseller_dataz%StatsNotifier.get_panel_reseller_data�s���	�#�l��&8�5�R�R�R�RS�U�O�O����U�%:�%G�I�	�	�	��6�6�M�M�M�	����)�!�,��*�*�?�1�+=�+E��F�F�%3�5�5�	5s� �/A�Ac���
�t��}|D]�}|�d��}|r	||jvr�#|t|�����vrO|�|��}|�d��s�qt
|dg|dd�|��||<��||d�|d����g}|���D]|\}�
|�
d<|�	|��p|j
}|��
fd�|D��|j��\}}	|s�S|�
d<|	�
d	<|j
�
d
<|��
���}|S)Nrrr�r�)�USERSr�r�c�4��g|]}|d�dv�|��S)r�r�r5)r��ur�s  �r8rkz8StatsNotifier.prepare_resellers_data.<locals>.<listcomp>s+���F�F�F�q�!�G�*��W�
�*E�*E��*E�*E�*Er9r�r�r)r�r�rmr��keysr�r"r�r�r�ryr�rLrf)rrr#�resellers_datar$r�r�resultr�r�r�r�s          @r8�prepare_resellers_dataz$StatsNotifier.prepare_resellers_data�s��������#�	(�	(�I�&�]�]�:�6�6�N�!�
�^�4�>�%I�%I���T�.�*=�*=�*?�*?�%@�%@�@�@� $� <� <�^� L� L�
�$�(�(��2�2���1<�(��1�2�(��2�4�4�5B�2D�2D��~�.�.��~�.�w�7�>�>��g�&�(�(�(�(���$2�$8�$8�$:�$:�	 �	 � �N�D�*�D��M� $� :� :�>� J� J� m�d�Nm��)-�)B�)B�F�F�F�F�J�F�F�F�!�5�*7�*7�&�L�,� �
��(�D��M�!-�D���#�}�D����M�M�$������
r9c#��K�|D]_}|�d��}|s�|�|��}|�d��s�Etd|ji||��V��`dS)z�
        With enabled second-level of resellers's limits
        we have information about reseller's faults;
        Here we prepare information about such resellers;
        :type resellers_data: collections.Iterable[dict]
        :return: dict
        r�rrN)r�r�r"rf)rrr�rr��
panel_datas     r8�_prepare_resellers_summary_dataz-StatsNotifier._prepare_resellers_summary_datas�����,�
	V�
	V�M�*�.�.�w�7�7�N�!�
���5�5�n�E�E�J��>�>�(�+�+�
���z�4�=�9�=�*�U�U�U�U�U�U�
	V�
	Vr9r9c�J�tj�||j��}	t	|��5}tj|��cddd��S#1swxYwYn@#t$r3}|j�	d|t|����Yd}~nd}~wwxYwiS)z�
        Load locales data from specified directory (file /usr/share/lve/emails/<locale_name>/locale_defines.json)
        :param templates_dir: Directory name to search json file
        :return: Dictionary loaded from JSON file
        Nz/Can't read/parse email localization file %s: %s)r3r4r5�LOCALE_DEFINES_FILE�open�json�load�	Exceptionrdr�rL)rrr9�locale_defines_file�	json_filerWs     r8rDz StatsNotifier._load_locales_data#s���!�g�l�l�=�$�:R�S�S��	m��)�*�*�
,�i��y��+�+�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,����
,�
,�
,�
,�
,���	m�	m�	m��H���N�Pc�eh�ij�ek�ek�l�l�l�l�l�l�l�l�����	m�����	s:�A#�A�
A#�A�A#�A�A#�#
B �-)B�B c#�PK�|D] }|�|��p|||<|V��!dSr4)r�)�	data_listr�r�r�s    r8�add_default_datazStatsNotifier.add_default_data3sB�����	�	�D�����
�
�,��D��I��J�J�J�J�	�	r9c�^�t��}|d}|d}|d}|d}	tj|d��}tj|d��}nT#ttf$r@}|j}|j}|j�dt|����Yd}~nd}~wwxYw|d	}	t|d
|d|d|d
t|d|d|d|d|d|d���t|d|���t|d|���|	�d��pt|	�d��pd|	�d��pd|	�d��pd���}
|
S)z�
        Read admin settings config (using shared code in
        lve-utils) and map it into our namedtuple structure
        :rtype: AdminSettings
        �faultsNotification�faultsToInclude�minimumNumberOfFaultsToNotify�notifyr�rtz:Can't set interval to admin. Period value is incorrect: %sNr-�notifyAdmin�notifyCustomers�notifyResellers�notifyResellerCustomers�cpu�io�iops�mem�concurrentConnections�nproc�rArBrCrDrErF�r>r?�notifyFromEmail�reportAdminMail��
notifySubject�
notifyCharsetzus-ascii)rHrIrKrJrLrMrNrOrPrQrR)�get_admin_notificationr!�time_dict_to_seconds�
ValueError�	TypeError�DEFAULT_PERIODrdr�rLrGr@r=r�r,)rr�raw_data�notification_data�faults_to_include�
min_to_notify�periodsr�notify_interval_userrW�email_settings�settingss           r8rvz!StatsNotifier._get_admin_settings9s��*�+�+��$�%9�:��-�.?�@��)�*I�J�
�#�H�-��	c�$,�$A�'�'�BR�$S�$S�!�#+�#@����#Q�#Q� � ���I�&�	c�	c�	c�#'�#6� �$(�$7�!��H���Y�[^�_`�[a�[a�b�b�b�b�b�b�b�b�����	c����+�7�3�� �*�=�9�'8�9J�'K�0A�BS�0T�&7�)�'+�!4�,�U�3�+�D�1�-�f�5�/��6�+�,C�D�.�w�7�
!9�!9�!9�!/�"/��"8� 5�!7�!7�!7�%3�"/��"7� 4�%6�%6�%6�-�0�0�1B�C�C�Y�GY�-�1�1�2C�D�D�J��)�-�-�o�>�>�D�"�!/�!3�!3�O�!D�!D�!R�
�1U�U�U��2�s�4A%�%B6�66B1�1B6c��t|jj|jj|jj|jj|jj|jj���S)N�rKrIrTrLrMrN)rSrwrKrJrLrMrNrqs r8rxz,StatsNotifier._get_default_reseller_settingsisS���04�0D�0h�'+�';�'U�,0�,@�,d� $� 4� H� $� 4� H�$(�$8�$P�
R�R�R�	Rr9Tc��|r||jvr
|j|St|��}|rd|vr|r
d|j|<dS|d}|d}|d}|d}	tj|d��}tj|d��}	nU#tt
f$rA}
|j}	|j}|j�d|t|
����Yd}
~
nd}
~
wwxYwt|d|d	|d
t|d|d|d
|d|d|d���t|d|���t|d|	������}|r
||j|<|S)Nr�r�r�r�r7r�z@Can't set interval to reseller %s. Period value is incorrect: %s�notifyResellerOnCustomersr��notifyResellerr�r�r�r�r�r�r�r�r�)
rhrr!r�r�r�r�rdr�rLrSr@r=)rrr7�	use_cacher�r�r�r�r��notify_interval_reseller�notify_interval_customerrW�ress            r8r�z#StatsNotifier.get_reseller_settingsss���	;��T�%B�B�B��0��:�:�#�H�-�-���	�/�x�?�?��
?�:>��-�h�7��F�$�%9�:��-�.?�@��)�*I�J�
�#�H�-��	s�'/�'D�W�Z�EX�'Y�'Y�$�'/�'D�W�Z�EX�'Y�'Y�$�$���I�&�	s�	s�	s�'+�':�$�'+�':�$��H���_�ai�kn�op�kq�kq�r�r�r�r�r�r�r�r�����	s�����0A�+�1-�(9�9J�'K�,=�>N�,O� 3�,�U�3�+�D�1�-�f�5�/��6�+�,C�D�.�w�7�
!9�!9�!9�!/�"/�
�";� 8�!:�!:�!:�%3�"/�
�";� 8�%:�%:�%:�#;�;�;��(�	:�69�D�)�(�3��
s�4B�C$�#7C�C$c���|�|��}|sdS|�|dd��}|D]?}d|d<|�d��s�|�|tt
����@dS)z�
        Decide and send mails to resellers as resellers (doesn't include
        notification to reseller about it's personal account as a customer)
        :return: Nothing
        Nr�Resellerr7r@rr�)r�r�r�rq�RESELLER_TEMPL�RESELLER_TEMPL_HTML)rr�users_data_resellerr��
reseller_infos    r8�_process_resellers_mailsz&StatsNotifier._process_resellers_mails�s����4�4�5H�I�I���	��F��.�.�~�x��T�T��+�	H�	H�M�)3�M�+�&� �$�$�X�.�.�
���"�"�m�3A�3F�
#�
H�
H�
H�
H�	H�	Hr9c��|�|��}|�|dd��}|D]}d|d<|�|���dS)z�
        When second level of reseller limits is enabled
        we collect summary info about reseller;
        When total load makes fault, we notify reseller about it;
        rrr7r@N)r�r��_notify_reseller_summary_faults)rrr��resellers_faults_datars    r8�%_process_resellers_summary_info_mailsz3StatsNotifier._process_resellers_summary_info_mails�sp��!%� D� D�^� T� T�� $� 5� 5�6K�X�Wa� b� b��2�	@�	@�M�)3�M�+�&��0�0��?�?�?�?�	@�	@r9c�t�|�|��}|�|tt���dS)z0Prepare data for reseller_faults_notify templater�N)r�rq�RESELLER_FAULTS_TEMPL�RESELLER_FAULTS_TEMPL_HTML)rrrs  r8rz-StatsNotifier._notify_reseller_summary_faults�sK���3�3�M�B�B�
����-�/D�/I�	�	K�	K�	K�	K�	Kr9c�V�|dd�D]s}|d}t|d��}|jjo|}||jvr%|�|��p|j}|jo|}|s|�|���s�t|�|�|dd����dS)z�
        Decide and send mails to customers(including resellers personal account
        notification as a customer)
        :return: Nothing
        Nrr�r�Customer)	r0rwrIrmr�ry�remover�r�)rrr#�	user_info�
account_owner�user_notification_enabled�	do_notifyr�s       r8�_process_users_mailsz"StatsNotifier._process_users_mails�s���$�A�A�A��
	�
	�I�%�j�1�M�(?�	�'�@R�(S�(S�%��,�G�e�Le�I����.�.�$(�$>�$>�}�$M�$M�$p�QU�Qp�!�-�H�f�Mf�	��
��!�!�)�,�,�,��	
�	
���4�0�0��X�z�R�R�S�S�S�S�Sr9c#��K�����D]c\\}}}d�|D��}�j�|��t�fd�|D��g��}��|||��V��ddS)z�
        Find all customers that might cause faults
        from /proc/lve/list, get additional data from
        control panel and return it
        c��g|]\}}|��Sr5r5�r�r�r�s   r8rkz=StatsNotifier._iter_customers_faults_data.<locals>.<listcomp>����!N�!N�!N�.�+�q�+�!N�!N�!Nr9c3�f�K�|]+}t�j�|����V��,dSr4)r�rjr�)r�r�rrs  �r8rvz<StatsNotifier._iter_customers_faults_data.<locals>.<genexpr>�s<�����!v�!v�T_�$�t�~�'A�'A�+�'N�'N�"O�"O�!v�!v�!v�!v�!v�!vr9N)r�rp�mark_users_notifiedr��)_StatsNotifier__get_customers_faults_data)rr�notify_settingsr�rm�notified_resellers�users_to_checks`     r8�_iter_customers_faults_dataz)StatsNotifier._iter_customers_faults_data�s������BF�Ad�Ad�Af�Af�	i�	i�=�2�_�1�I�!N�!N�I�!N�!N�!N����3�3�4F�G�G�G�!�!v�!v�!v�!v�cu�!v�!v�!v�xz�{�{�N��2�2�>�CV�Xg�h�h�h�h�h�h�	i�	ir9c�x�|�|j|j||���}|�|���}|S)Nr�r�)r�r?r>r')rrr&r�r$r�r#s      r8�__get_customers_faults_dataz)StatsNotifier.__get_customers_faults_data�sQ�� �/�/��7V�BQ�Bc�DW�5C�0�E�E���(�(�:J�(�K�K�
��r9c�^�|���D]}|�|���dSr4)r'r)rrr#s  r8�_check_userszStatsNotifier._check_users�s>���:�:�<�<�	2�	2�J��%�%�j�1�1�1�1�	2�	2r9c#��K�|���D]_\\}}}d�|D��}d�|D��}|�|j|j||���}|�|���}||fV��`dS)z�
        Find all resellers that might cause faults
        from /proc/lve/resellers, get additional data from
        control panel and return it
        c��g|]\}}|��Sr5r5rs   r8rkz=StatsNotifier._iter_resellers_faults_data.<locals>.<listcomp>s��J�J�J�n�k�1�k�J�J�Jr9c�8�g|]}tt|����Sr5)r%r)r�r�s  r8rkz=StatsNotifier._iter_resellers_faults_data.<locals>.<listcomp>s$��!p�!p�!p�R]�"2�<��"M�"M�!p�!p�!pr9r�)r
N)r�r�r?r>r
)rrr$r�rm�resellers_uids�resellers_to_checkr
r�s        r8�_iter_resellers_faults_dataz)StatsNotifier._iter_resellers_faults_datas�����BF�Ad�Ad�Af�Af�
	1�
	1�=�2�_�1�I�J�J�	�J�J�J�N�!p�!p�ao�!p�!p�!p���.�.�o�6U�AP�Ab�CV�4F�/�H�H�K�"�5�5�+�5�N�N�N� �.�0�0�0�0�0�
	1�
	1r9c#�K�|���D]e\\}}}d�|D��}g}|D]/}|�|j�|�����0|�|||��}||fV��fdS)Nc��g|]\}}|��Sr5r5rs   r8rkzGStatsNotifier._iter_reseller_users_list_faults_data.<locals>.<listcomp>r r9)r�r�rjr�r#)rrr$r�rmr%r&r��customers_faultss        r8�%_iter_reseller_users_list_faults_dataz3StatsNotifier._iter_reseller_users_list_faults_datas������D�D�F�F�	7�	7�=�2�_�1�I�"O�!N�I�!N�!N�!N�� �N�1�
O�
O���%�%�d�n�&@�&@��&M�&M�N�N�N�N�#�?�?�� 3�_� F� F��"�$6�6�6�6�6�6�	7�	7r9c�f�t��}|���D]/\}}|�|��|�|���0|���D]/\}}|�|��|�|���0|j�|��dSr4)rlr1rr�r5r
rp�mark_resellers_notified)rrr%r��reseller_idsr#s     r8�_check_resellerszStatsNotifier._check_resellers*s��� �U�U��,0�,L�,L�,N�,N�	4�	4�(�N�L�
�6�6�~�F�F�F��%�%�l�3�3�3�3�(,�(R�(R�(T�(T�	4�	4�$�J��
�)�)�*�5�5�5��%�%�l�3�3�3�3���3�3�4F�G�G�G�G�Gr9c���i|_|j�d���|���|���|���|j���dS)NF)r)rhrk�
link_xml_noder+r9r�rp�save_to_persistent_storage)rr�lve_datas  r8�executezStatsNotifier.execute;sv��)+��%���$�$�u�$�5�5�5���������������������6�6�8�8�8�8�8r9)Fr4)T)@rWrXrYr�rzr8r6r�r�rsrer�r�r�r�r�r�r�r|r�r��staticmethodr�r�r�r�r
r'r!r.rLrr;r�rYr	rgrorqryr�r�r�r�r�r�r�rrDr�rvrxr�r
rrrr'r#r+r1r5r9r>r5r9r8r[r[zs7������!�N��J�+�L�-���L�/��4�4�4�*!t�!t�!t�F:�:�:�:�"*�*�*�.
\�
\�
\�*�*�*�&C�C�C�"*�*�*�	C�	C�	C�
�
�
�>�>�>�C�C�C��<�<��\�<��:�:��\�:�!�!�!�!�F�"�"��\�"�& � � �,#�#�#�J���$���&J��J�c�J�e�TW�Y\�T\�o�J�J�J�J�$C/�C/�D�C/�3�C/�Y\�C/�C/�C/�C/�J��t��c��TW��cp�����>x�x�x�%�%�D�%�3�%�Y\�%�%�%�%�=�=�=�3%�3%�3%�j���"D�D�D�$&�&�&�P5�5�5����BV�V�V�(�������� ����\��
.�.�.�`R�R�R�,�,�,�,�\H�H�H�&@�@�@�K�K�K�T�T�T�.i�i�i�$���2�2�2�1�1�1�.7�7�7� H�H�H�"
9�
9�
9�
9�
9r9r[c��d}t|d���}|r|dd}t��}|t��vr*|�|��p|���}n|���}|jS)z!
    Gets parameter for user
    �rootr6rr)rr[rr�rxrvrI)rt�default_resellerr7�
stat_notifierr�s     r8�get_stats_notifier_parametersrDKs������d�-�0�0�0�H��*�#�A�;�q�>��!�O�O�M��v�x�x�'�'� �6�6�7G�H�H�B� �?�?�A�A�	��!�4�4�6�6���.�.r9)h�
__future__rrr�r�rbr3rr�rrr-r�email.headerr�email.mime.multipartr	�email.mime.textr
r�clcommonrr
r�clcommon.clprocr�clcommon.cpapirrrr� clcommon.cpapi.plugins.universalr�system_admin_email�clconfig.lve_stats2_librr��prettytablerr�lveapir�typingrrrrrrr�lvestats.core.pluginr �lvestats.lib.commonsr!�lvestats.lib.commons.funcr"r#r$r%r&�clcommon.mail_helperr'�lvestats.lib.commons.sizeutilr)�lvestats.lib.lveinfolibr*r+r,r-r.�!lvestats.lib.notifications_helperr/r0�builtinsr1�	functoolsr2� clconfig.lve_stats2_reseller_lib�ImportErrorrCr�r�r�r�rrr	r
r,r�r�rr=�boolr@rLrGrSrHrIrJrVr[rDr5r9r8�<module>r^s�� '�&�&�&�&�&�����������
�
�
�
�����	�	�	�	�
�
�
�
�����(�(�(�(�(�(�(�(�%�%�%�%�%�%�������.�.�.�.�.�.�$�$�$�$�$�$�������+�+�+�+�+�+�+�+�+�+�(�(�(�(�(�(�O�O�O�O�O�O�O�O�O�O�O�O�R�R�R�R�R�R�N�N�N�N�N�N�(�(�(�(�(�(�(�(�������N�N�N�N�N�N�N�N�N�N�N�N�N�N�N�N�N�N�/�/�/�/�/�/�)�)�)�)�)�)�j�j�j�j�j�j�j�j�j�j�j�j�j�j�+�+�+�+�+�+�;�;�;�;�;�;�n�n�n�n�n�n�n�n�n�n�n�n�n�n�A�A�A�A�A�A�=�=�=�=�=�=��������������A�A�A�A�A�A�A����������������� ��&��
�
�$��4��:��&��,��'�'�)�)��6���V�k�
!�V�H�
,�}�
<�{�
J�
���,��#�����/����
!�j�!6��4���$���D���d���$���T��
9�����
�?��X�d�^�$�!�8�D�>�2� �(�4�.�1�*�H�T�N�;��/�0��N�+���/��(�3�-�(��8�C�=�)��s���X�c�]�+�-���
� �:�0�*�D�1�!�4�(�&��-��/�0��N�+���/�	3�	�	��	�	�	�	�	���!:�!H�	�	�	�N9�N9�N9�N9�N9�N�N9�N9�N9�b/�/�/�/�/s� C'�'C2�1C2

Hacked By AnonymousFox1.0, Coded By AnonymousFox