????

Your IP : 3.16.130.230


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

�

xޘf�4��J�ddlmZddlmZddlZddlZddlmZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlmZmZddlmZmZddlmZddlmZdd	lmZdd
lmZddl m!Z!ddl"m#Z#ddl$Z$ddl%Z&ddl'Z'dd
l(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/m0Z0m1Z1m2Z2m3Z3ddl4m5Z5m6Z6ddl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@ddlAmBZBmCZCmDZDddlEmFZFddlGmHZHddlImJZJddlKmLZLmMZMmNZNddlOmPZPmQZQddlRmSZSmTZTddlUmVZVddlWmXZXddlYmZZZddl[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcddldmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZudd lvmwZwdd!lxmyZymzZzm{Z{dd"l|m}Z}dd#l~mZ�dd$l�m�Z�m�Z�dd%l�m�Z�dd&l�m�Z�	dd'l�m�Z�m�Z�m�Z�m�Z�m�Z�m�Z�dd(l�m�Z�dd)l�m�Z�dd#l�mZ�dd*l�m�Z�n#e�$reoZ�eoZ�eoZ�eoZ�eoZ�eoZ�eoZ�dZ�dZ�dZ�YnwxYw	dd+l�m�Z�n#e�$rd,�Z�YnwxYwd-Z�e	j�d.��Z�d/Z�d0Z�d1Z�d2Z�d3Z�d4Z�d5Z�d6Z�Gd7�d8e���Z�d9e�d:e�fd;�Z�Gd<�d=e���Z�d>�Z�dS)?�)�absolute_import)�divisionN)�range)�	lru_cache�partial)�Counter�defaultdict)�groupby��	iteritems)�
attrgetter)�	cpu_count)�getfqdn)�Path)�cpapi)�Feature)�
MySQLGovernor)�is_cl_solo_edition�is_cl_shared_edition�
CLEditions�	is_ubuntu�is_secureboot_enabled)�is_panel_feature_supported�is_wp2_environment)	�get_rhn_systemid_value�run_command�ExternalProgramFailed�is_testing_enabled_repo�is_litespeed_running�get_cl_version�
get_virt_type�grep�is_nginx_running)�
find_wp_paths�get_wp_cache_plugin� get_wp_paths_with_enabled_module)�ACCELERATE_WP_INSTALLED_FROM_CM)�client_activation_data)�
SysCtlConf)�cagefs_statistics_config�db_governor_lib�clconfig_utils)�print_dictionary�replace_params)�LimitsDataStorage�DEFAULTS)�EMPTY_LIMITS)�LvpMap�)�parse_cloudlinux_summary_opts)�Dict�Optional�Callable�Union�List�Any�Tuple�AnyStr)�is_statistic_enabled�is_statistic_rpm_enabled� set_statistic_collection_enabled�$set_statistic_rpm_collection_enabled�$write_statistics_send_status_to_file�
SummaryStatus�is_python_selector_installed�is_ruby_selector_installed�is_nodejs_selector_installed�is_php_selector_installed�dummy_none_function� get_packages_with_lve_extensions�is_sending_process_running�$get_statistics_send_status_from_file�get_client_data_from_jwt_token�get_cl_plus_sender_status�is_active_cloudlinux_license)�get_rpm_packages_info)�get_cpu_metrics�get_memory_metrics�NotSupported)�ALL_MODULES)�PKG_VERSION)�CONFIG_PATH�_read_config_file)�is_email_notification_enabled)�get_hidepid_typing_from_mounts)�get_versions_statistics�get_native_version_safe�get_php_selector_usage�iter_server_applications�get_default_php_version�get_mode_of_php_selector)�CloudlinuxSelectorLib)�get_default_version)�PKG_RELEASE)�list_flags_infoc��t��S�N)�list���H/opt/cloudlinux/venv/lib64/python3.11/site-packages/clsummary/summary.py�<lambda>rh�s
��d�f�f�rfz/var/log/cloudlinux-summary.logzcloudlinux-summary�unknown�	installed�
not_installed�not_initialized�not_selected�enabled�disabled�-42c
�J�eZdZdZddddgdgddiddiddigd�	Zd
d�Zd
d�Zd	S)�StatisticsDictz>
    Special class to store all metrics before sending it
    rp����gE�)	�str�int�float�str_list�int_list�int_dict�
float_dict�str_dict�
rpm_stat_listTc��|j|}	|��}n7#t$r*}|rt�d||��|}Yd}~nd}~wwxYw|S)a
        Method for catching any exceptions while calling passed function,
        logging them and return default result in case if exception is present or
        return formatted result in case if exception is absent
        :param log_exception: True - exception will been logged, False - exception won't been logged
               This flag must be used if param `func` is function, which processes intermediate value, which can equal
               to -42 (it means that exception was logged in previous moment) and
               doesn't call external functions or doesn't process another values. In other cases
               log_exception should be equal True, because in calling of external function or processing of another
               value can be raised exception, which should be logged.
               Example: functions `lambda: intermediate_value[0].property` or
               [len(value) for value intermediate_value.values()] should be used with log_exception equal False,
               because they only process intermediate value. But function:

               def some_function(intermediate_value):
                    result = external_function()
                    return len(intermediate_value), result

               should be used with log_exception equal True
        z%s. Exception: "%s"N)�DEFAULT_RESULTS�	Exception�
app_logger�	exception)�self�func�type_of_result�log_message�
log_exception�default_result�result�errs        rg�run_safe_or_log_errorsz%StatisticsDict.run_safe_or_log_errors�s���.�-�n�=��		$��T�V�V�F�F���	$�	$�	$��
��$�$�)������
$�F�F�F�F�F�F�����	$�����
s�
�
A� A	�	Ac�B�|�||||���}|||<dS)z�
        Method which call `run_safe_or_log_errors` and save result from it
        :param log_exception: True - exception will been logged, False - exception won't been logged
               See method `run_safe_or_log_errors`
        �r�N)r�)r�r�r��name_of_metricr�r�r�s       rg�
format_metriczStatisticsDict.format_metric�s<���,�,����'�	-�
�
�� &��^���rfN)T)�__name__�
__module__�__qualname__�__doc__r~r�r�rerfrgrrrr�s�������������G��E��3�
�
�5�
�
�5�
�
�#��O�($�$�$�$�L&�&�&�&�&�&rfrr�	site_dict�returnc�n�ttd�|d�������S)zB
    Checks if wordpress site has at least one enabled module
    c��|dS)Nrnre)�modules rgrhz*site_has_enabled_modules.<locals>.<lambda>�s��6�)�,�rf�modules)�any�map�values)r�s rg�site_has_enabled_modulesr��s=����,�,��i� �'�'�)�)�	
�	
���rfc�	�eZdZdZdZejgd�eje	j
��eje	j��eje	j��g��Z
dZdZdZd�Zed���Zed	���Zed
���Zed���Zed���Zed
���Zd�Zed���Zd�Zd�Zed���Zed���Zed���Z d�Z!d�Z"ed���Z#d�Z$ed�d���Z%d�Z&ed���Z'ed���Z(ede)e*e*fde+fd ���Z,d!�Z-d"�Z.ed#e/d$e0ddfd%���Z1d&e)e0e/fd'e0d(e+ddfd)�Z2d*�Z3ed+���Z4d,�Z5d-�Z6ed.���Z7d/�Z8d�d0�Z9ed1���Z:ed2���Z;d3�Z<ed4���Z=d5�Z>d6�Z?d7�Z@ed8���ZAd9�ZBd:�ZCd;�ZDd<�ZEd=�ZFd>�ZGd?�ZHd@�ZIdA�ZJdB�ZKedCeLdDeMfdE���ZNdeOeMePeMePe)eLe/fffdF�ZQdeOeReLeReLffdG�ZSdHeLdIeLdJe)eLeLfde)eLeTeMeLfffdK�ZUdLeLdeLfdM�ZVeeWd�N��dO�����ZXdP�ZYdQ�ZZedR���Z[edS���Z\edT���Z]edU���Z^edV���Z_edW���Z`dX�ZaedY���ZbedZ���Zcd[�Zded\���Zeed]���Zfd^�Zged_���Zhd`�Zieda���Zjdb�Zkedc���Zledd���Zmede���Znede+fdf���Zoede+fdg���Zpede/fdh���ZqedeLfdi���Zredj���Zsdk�Ztdl�Zudme0deve/fdn�Zwdo�Zxdp�Zydq�Zzdr�Z{ede)fds���Z|dt�Z}du�Z~deOe/e/e/ffdv�ZedeOe/eLffdw���Z�dx�Z�dy�Z�dz�Z�d{�Z�d|�Z�d}�Z�d~�Z�d�Z�d��Z�ed����Z�d��Z�deve/fd��Z�deve/fd��Z�e�d����Z�ed����Z�ed����Z�d��Z�d��Z�d��Z�ed�d����Z�ed�d����Z�ed����Z�ed����Z�ed����Z�ed����Z�ed����Z�ed����Z�ed����Z�ed�eLde/fd����Z�ed����Z�d��Z�ed����Z�ed����Z�dS)��CloudlinuxSummaryz/var/lve/dashboard_certificatez/etc/cl_plus/.disabled)�python�ruby�nodejsz/https://amazeservice.net/api/stat-api/clos-statz-https://stat-api.cloudlinux.com/api/rpm-statsz6https://repo.cloudlinux.com/static/cl-settings-v1.jsonc���t��|_d|_t��|_d|_d|_|���|_d|_	t��|_dSrc)�dict�_opts�_security_tokenrr�
statistics�_lvpmap�
_system_id�_is_process_not_limited�is_process_not_limited�packages_by_lenr)�sysctl�r�s rg�__init__zCloudlinuxSummary.__init__	s[���V�V��
�#���(�*�*���������&*�&B�&B�&D�&D��#�#��� �l�l����rfc��ttj�d����}ttj�d����}|o|S)zm
        Return true if process is running outside LVE or it's not running by
        utility `nice`
        �RUNNING_BY_NICE�RUNNING_IN_LVE)�bool�os�environ�get)�is_running_by_nice�is_running_in_lves  rgr�z)CloudlinuxSummary._is_process_not_limitedsP��"�"�*�.�.�1B�"C�"C�D�D�� �����0@�!A�!A�B�B��%�%�?�.?�*?�?rfc�D�|j�t��|_|jS)z.
        Load lvpmap only when needed
        )r��_get_lvpmapr�s rg�lvpmapzCloudlinuxSummary.lvpmaps��
�<��&�=�=�D�L��|�rfc�F�|j�td��|_|jS)N�	system_id)r�rr�s rgr�zCloudlinuxSummary.system_id's#���?�"�4�[�A�A�D�O���rfc�&�t��rdndS)N�ubuntu�	rhel_like)rrerfrg�
_get_platformzCloudlinuxSummary._get_platform/s��$�;�;�7�x�x�K�7rfc�:�t��rtntSrc)r�ENABLED�DISABLEDrerfrg�_detect_securebootz$CloudlinuxSummary._detect_secureboot3s��/�1�1�?�w�w�x�?rfc���tjtjz�d��fd�t	d��D����}|S)N�c3�@�K�|]}tj���V��dSrc)�random�choice)�.0�_�range_for_random_choices  �rg�	<genexpr>z=CloudlinuxSummary._generate_security_token.<locals>.<genexpr>:s.����� [� [�A���/F�!G�!G� [� [� [� [� [� [rf�@)�string�
ascii_letters�digits�joinr)�security_tokenr�s @rg�_generate_security_tokenz*CloudlinuxSummary._generate_security_token7sI���"(�"6���"F����� [� [� [� [�QV�WY�QZ�QZ� [� [� [�[�[���rfc��i}|j�3d}t�|��|�d|i��d|jz}t�|��|j|jd�}d}	tj|j|d���}n\#tj	$rJ}t|��}t�|��|�d|i��Yd}~nd}~wwxYw|jsQd�|j
|j��}t�|��|�d|i��t�d��	|���d}t!|dt"��r-|d�|�����t�d	��n�#t(t*f$r6d
}t�|��|�d|i��Ynct,$rW}t�dt|��|j��|�ddt0zi��Yd}~nd}~wwxYw|S)
NzSecurity token is emptyr�z!Getting statistics from server %s)r�r��<)�params�timeout�*Server answer is: HTTP code {}; Reason: {}z!Received response from the serverz,SUCCESS: received statistics from the serverz Can't parse api response to jsonz=Invalid json response from server, field %s not found in "%s"z1Invalid response from server. See %s for details.)r�r��error�_error_and_exit�SUMMARY_URL�infor��requestsr��RequestExceptionrt�ok�format�status_code�reason�json�
isinstancer��update�_get_smart_advice_statistics�	TypeError�
ValueError�KeyError�text�LOG_FILE)r��	stat_data�messager��response�es      rg�_get_remote_dataz"CloudlinuxSummary._get_remote_data=s����	���&�/�G����W�%�%�%�� � �(�G�!4�5�5�5�5��8H�H������ � � ���"�1�
�
����	6��|�D�$4�V�R�P�P�P�H�H���(�	6�	6�	6��!�f�f�G����W�%�%�%�� � �(�G�!4�5�5�5�5�5�5�5�5�����	6����
�{�	6�B�I�I��$�����G�
�O�O�G�$�$�$�� � �(�G�!4�5�5�5����;�<�<�<�	L� �
�
����1�I��)�H�-�t�4�4�
P��(�#�*�*�4�+L�+L�+N�+N�O�O�O�
�O�O�J�K�K�K�K���:�&�	6�	6�	6�8�G����W�%�%�%�� � �(�G�!4�5�5�5�5�5��	=�	=�	=����/�03�A����
�
G�
G�
G�
� � ��0�2:�;�"<�
=�
=�
=�
=�
=�
=�
=�
=�����		=�����s:�3B�C)�AC$�$C)�A"G�AJ�"	J�+A
I=�=Jc��|j�|jStj�|j��r|���|_n2|���}|�|��r|nd|_|jSrc)r�r��path�isfile�DASHBOARD_CERTIFICATE�_read_token_from_filer��_write_token_to_file)r��tokens  rgr�z CloudlinuxSummary.security_tokents�����+��'�'�
�7�>�>�$�4�5�5�	W�#'�#=�#=�#?�#?�D� � ��1�1�3�3�E�,0�,E�,E�e�,L�,L�#V�5�5�RV�D� ��#�#rfc�N�	t|jd��5}|�|��ddd��n#1swxYwYtj|jd��dS#t
tf$r3}t�dt|����Yd}~dSd}~wwxYw)z�
        Write security token to file and return success/fail status
        :param token: generated security token
        :return: T/F status
        �wNi�Tz,Error while writing secure token to file: %sF)
�openr��writer��chmod�IOError�OSErrorr�r�rt)r�r��fr�s    rgr�z&CloudlinuxSummary._write_token_to_file�s���	��d�0�#�6�6�
�!��������
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��H�T�/��7�7�7��4����!�	�	�	����K�S�QR�V�V�T�T�T��5�5�5�5�5�����	���s4�A �9�A �=�A �=�A � B$�1(B�B$c�>�	t|j��5}|������pdcddd��S#1swxYwYdS#tt
f$r3}t�dt|����Yd}~dSd}~wwxYw)Nz.Error while reading file with secure token: %s)	r�r��read�stripr�r�r�r�rt)r�rr�s   rgr�z'CloudlinuxSummary._read_token_from_file�s���	��d�0�1�1�
0�Q��v�v�x�x�~�~�'�'�/�4�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0����
0�
0�
0�
0�
0�
0����!�	�	�	����M�s�ST�v�v�V�V�V��4�4�4�4�4�����	���s9�A�(A�A�A�A�A�A�B�)(B�Bc�F�tjtjddd���S)z�
        Detect old LVE limits integration presence according to
        https://docs.cloudlinux.com/index.html?lve_limits_with_packages.html
        :return: True/False - present/absent
        �CUSTOM_GETPACKAGE_SCRIPT�=F)�	file_name�
param_name�	separator�default_val)�detect�get_boolean_param�CL_CONFIG_FILErerfrg�_detect_old_lve_integrationz-CloudlinuxSummary._detect_old_lve_integration�s-���'��+�1���	
�
�
�	
rfc�@�tj�d��S)zO
        Detects presence/absence of lsapi
        :return: True/False
        �/usr/bin/switch_mod_lsapi�r�r��existsrerfrg�_is_lsapi_presentz#CloudlinuxSummary._is_lsapi_present�s���w�~�~�9�:�:�:rfc�8�|dkrt��stSnY|dkrt��rtntS|dkrt	��stSn|dkrt��stSt
|��}|�tS|dvr@	|���drtntS#t$r
tcYSwxYw|dkr"|�
��rtntStd�|�����)	zP
        Get selector status for nodejs, python, ruby and php selectors
        r�r�r��phpN)r�r��selector_enabledzUnknown interpreter: {})
rC�
NOT_INSTALLEDrDr�rErFr^�get_selector_statusr�r��php_selector_is_disabledr�r�)�interpreter�libs  rg�_get_status_of_selectorz)CloudlinuxSummary._get_status_of_selector�s>���(�"�"�/�1�1�
%�$�$�
%�
�F�
"�
"�8�:�:�M�7�7�
�M�
�H�
$�
$�/�1�1�
%�$�$�
%�
�E�
!�
!�*C�*E�*E�
!� � �#�K�0�0���;� � ��.�.�.�
%�"%�"9�"9�";�";�<N�"O�]�w�w�U]�]���
%�
%�
%�$�$�$�$�
%����
�E�
!�
!�"�;�;�=�=�J�8�8�7�J��2�9�9�+�F�F�G�G�Gs�'B;�;C�Cc��	tj|�����}|S#tj$rW}t�dt
|����|�dt
|��i��Yd}~dSd}~wttf$r3}t�dt
|����Yd}~dSd}~wwxYw)Nz3Request exception while getting remote settings: %sr�z'Error while parsing remote settings: %s)
r�r�r�r�r�r�rtr�r�r�)r��settings_url�settingsr�s    rg�_get_remote_settingsz&CloudlinuxSummary._get_remote_settings�s���	��|�L�1�1�6�6�8�8�H��O���(�	5�	5�	5����R�TW�XY�TZ�TZ�[�[�[�� � �(�C��F�F�!3�4�4�4�4�4�4�4�4�4������I�&�	�	�	����F��A���O�O�O��4�4�4�4�4�����	���s!�'*�C�AB�C�(C
�
Cc��|j�d��rdSttj�d����}|rdS|�|j��}|�dS	|dd}|ddo|�|��S#t$rW}t�
d	t|����|�d
t|��i��Yd}~dSd}~wwxYw)z-
        Return cl-statistics status
        �--force-collectT�CL_TEST_SYSTEMNFz
cl-statisticsz
rollout-grouprnz4Error occurred while trying to get rollout group: %sr�)
r�r�r�r�r�r �SETTINGS_URL�
_match_serverr�r�r�rtr�)r��is_test_environmentr�
rollout_groupr�s     rg�_is_statistics_enabledz(CloudlinuxSummary._is_statistics_enabled�s���:�>�>�+�,�,�	��4�"�2�:�>�>�2B�#C�#C�D�D���	��4��,�,�T�->�?�?�����5�	5�$�_�5�o�F�M��O�,�Y�7�]�D�<N�<N�}�<]�<]�]���	5�	5�	5����S�UX�YZ�U[�U[�\�\�\�� � �(�C��F�F�!3�4�4�4�4�4�4�4�4�4�����	5���s�,0B�
C>�'AC9�9C>c�"�t|d��S)N��ru)�hash_servers rg�
_to_numberzCloudlinuxSummary._to_number�s���;��#�#�#rfc���|j�dStj|j��������dd�}|�|��d|zzdkS)NT��r)r��hashlib�sha256�encode�	hexdigestr-)r��url_numr,s   rgr%zCloudlinuxSummary._match_server�sa���>�!��4��n�T�^�%:�%:�%<�%<�=�=�G�G�I�I�#�2�#�N������,�,�q�G�|�;��A�Arfr�Nc��d}|r9t��s/|dz}tjd��|rt���)dSdSdSdS)zC
        Wait for running background process of cl-summary
        �2r3g�������?N)rI�time�sleep)�retriess rg�_wait_for_background_processz.CloudlinuxSummary._wait_for_background_process�su��
���	�8�:�:�	��q�L�G��J�s�O�O�O��	�8�:�:�	�	�	�	�	�	�	�	�	rfc�*
�|jds
|jdrBt|jd��tj��dd�}t|d��dS|jds
|jdrBt	|jd��tj��dd�}t|d��dS|jdrkt��rd	nd
}tj��|dd�}|�dt��i��t|d��td
��|j�	d��r7|�
��}|�|t�����|j�	d��r�t��s3|j�	d��s|�ddid
���|���|j�	d��r=|�|j|jd���t&�d��nt|jd��dS|���sIt,jdtj��d�}t1|��|�ddid
���|j�	d��r�|j�	d��sWt��sIt,jdtj��d�}t1|��|�ddid
���|j�kd}t&�|��t,jdt6ztj��d�}t1|��|�d|i��|j�	d ��r�t��rtj��d	dd�}not1t,jtj��dd!���t;jd"dd#�$��|���tj��dd�}t|d��td
��|jdr|j rHtd�%��r8tj��d	dd�}t|d��td
��dSt1t,jtj��dd!���dSdS)&N�enable�disable�success��	timestampr�T�
enable-rpm�disable-rpm�status�
collecting�ready)rArDr��sending_statusr�
get-remote)�datar=�rpm-packagesr"r�z\Sending RPM statistics is disabled by admin. Use --force-collect to ignore admin`s settings.)�
error_code�--sendF��summary�url�save_statuszRPM statistics sentzkStatistics collection is disabled globally. Please, try again later or contact support if it happens again.)r�r�rAzYCollecting statistics is disabled globally. Use --force-collect to ignore global settingsz_Statistics collection is disabled by admin. Run `cloudlinux-summary enable` and then try again.zXSending statistics is disabled by admin. Use --force-collect to ignore admin`s settings.z8Statistics was not sent, because security token is emptyz�We are not able to collect statistics because we are not able to make a security token. Check %s for details or contact support.�--async)r�rAr�z9/usr/sbin/cloudlinux-summary --send --json &> /dev/null &�	/bin/bash)�shell�
executable)�acquire_lock)!r�r?r8r-r@rIr�rJ�exitr�r��_print_result_and_exitr=r>r��_get_rpm_packages_summary� _send_statistics_and_save_statusr��RPM_PACKAGES_URLr�r�r(rB�FAILEDrAr�r�r��IN_PROGRESS�
subprocess�runr;r�)r�rIrDr��status_dictr�s      rg�&_actions_before_run_process_as_limitedz8CloudlinuxSummary._actions_before_run_process_as_limitedso���:�h��	�4�:�i�#8�	�,�T�Z��-A�B�B�B�!%����	�B�B�D��T�4�(�(�(��F��:�l�#�	�t�z�-�'@�	�0���L�1I�J�J�J�!%����	�B�B�D��T�4�(�(�(��F��:�h��		�%?�%A�%A�N�\�\�w�F�!%�����)�T�T�D��K�K� �"F�"H�"H��
�
�
�
�T�4�(�(�(���G�G�G��:�>�>�,�'�'�	b��*�*�,�,�F��'�'�V�J^�J`�J`�'�a�a�a��:�>�>�.�)�)�	�+�-�-�
3�d�j�n�n�EV�6W�6W�
3��$�$�h�1b�&c�01�%�3�3�3�
�*�*�,�,�,��z�~�~�h�'�'�
8��5�5� �O��-� %�6����
��� 5�6�6�6�6� ���$�7�7�7��F��*�*�,�,�	/�%2�%9�&g�(,�	���5�5�K�
1��=�=�=�� � �(�-\�"]�,-�
!�
/�
/�
/�
�:�>�>�(�#�#�	:��:�>�>�"3�4�4�
3�=Q�=S�=S�
3�)6�)=�*_�,0�I�K�K�9�9��5�[�A�A�A��$�$�h�1b�&c�01�%�3�3�3��"�*�T��� � ��)�)�)�)6�)=�*K�MU�*V�-1�I�K�K�	9�9��
5�[�A�A�A��$�$�h��%8�9�9�9��:�>�>�)�$�$�	�)�+�+�
G�&*�Y�[�[�L�T]�^�^���5�"/�";�%)�Y�[�[�"&��������Z�%)�k�C�C�C�C��1�1�3�3�3�%)�Y�[�[�I�F�F���T�4�(�(�(���G�G�G��:�h��	��*�
�/I�W[�/\�/\�/\�
�&*�Y�[�[�L�T]�^�^�� ��t�,�,�,��Q������5�"/�";�%)�Y�[�[�"&��������	�	rfc��tjddd���}tj|��5}|�dt	|��g��tjddt	|��dg|zttj	d	tjtj���
�����cddd��S#1swxYwYdS)
z�
        Run same command in lve and set environ RUNNING_IN_LVE=1
        in order to check it in child process.
        :return:
        �ri@)�ls_cpu�ls_cpus�
ls_memory_phy�--lve-idz/bin/lve_suwrapper�-n�/usr/sbin/cloudlinux-summary�1)r��CPU_DATA��envN)
�	lvectllib�make_liblve_settings�
temporary_lve�extendrtr]�callr�r�r�r��dumps�CPUINFO_DATA)�argsr�lve_ids   rg�_run_self_in_lvez"CloudlinuxSummary._run_self_in_lve�s���1���*�
�
�
��
�
$�X�
.�
.�	�&��K�K��S��[�[�1�2�2�2��?�%�t�S��[�[�/�1�37�8���J�s�"�Z�	�(>�?�?�A�A�A�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�BB=�=C�Cc�j�tjgd�|zttjd������S)z�
        Run same command using utility `nice` and set environ RUNNING_BY_NICE=1
        in order to check it in child process.
        :return:
        )z
/usr/bin/nicerg�19rhri)r�rk)r]rqr�r�r�)rts rg�_run_self_by_nicez#CloudlinuxSummary._run_self_by_nice�sN����
-�
-�
-�/3�
4���
� #����
�
�
�	
rf�optsc�|��t�fd�dD����rdSt�fd�dD����rdSdS)zK
        Check that passed command should run as unlimited process
        c3�(�K�|]}�|V��
dSrcre�r��optionrzs  �rgr�zECloudlinuxSummary._should_run_as_unlimited_process.<locals>.<genexpr>�s7��������t�F�|������rf)rJrDrHr=r>rBrCTc3�(�K�|]}�|V��
dSrcrer}s  �rgr�zECloudlinuxSummary._should_run_as_unlimited_process.<locals>.<genexpr>�s7��������t�F�|������rf)rLrQ�--jsonr"F)r�)rzs`rg� _should_run_as_unlimited_processz2CloudlinuxSummary._should_run_as_unlimited_process�s����
�����+
������		��4������+
������	��5��urfc��|�|��|_|j�r|���|�|j��rtd��dSt
tj��s&|�	|��}t|��dS	|�
|��}t|��dS#tj$r^}d|z}t|��tjt ��}|�|d���td��Yd}~dSd}~wwxYw|�|j��rXd}t%j��|d�}t&�||j���t+|d��td	��|���dS)
Nrz$failed to run task in lve, error: %sT)�exc_info���z|You shouldn't use env var "RUNNING_IN_LVE" or "RUNNING_BY_NICE" for run of any command except collection of main statistics.r@)�extrar3)�_parse_argsr�r�r`r�rVrr�LVEryrvrm�
PyLveError�print�logging�	getLoggerr�r�r8r�r�r-�run_get_summary)r��argv�rcr��	error_msg�log�err_msgrIs        rgr^zCloudlinuxSummary.run�s����%�%�d�+�+��
��&�&	#�
�7�7�9�9�9��4�4�T�Z�@�@�
��Q������/���<�<�
��+�+�D�1�1���R��������.�.�t�4�4�B���H�H�H�H�H�� �+���� F�� J�I��)�$�$�$�!�+�H�5�5�C��M�M�)�d�M�;�;�;���H�H�H�H�H�H�H�H�H����������4�4�T�Z�@�@�
�0��
"&����%����� � ���
� �;�;�;� ��t�,�,�,��Q����� � �"�"�"�"�"s�"$C�D5�AD0�0D5c���tj��}|���tj��|z
}||jd<|jdr0|j�t|j|��ddd��|j�d��r>|�|j|j	d���t�d	��dSt|jd��dS)
N�cl_summary_execution_timerfrt�cl_summary_max_mem_usedz,Can't get memory usage by cloudlinux-summaryrLTrMzMain statistics sent)
r8�_get_summaryr�r�r�r�_get_max_memoryr�rYr�r�r�r-)r��
start_time�running_times   rgr�z!CloudlinuxSummary.run_get_summary�s����Y�[�[�
��������	���j�0��7C���3�4��:�j�!�	��O�)�)���,�l�;�;��)�?�	
�
�
��:�>�>�(�#�#�	4��1�1����$� �
2�
�
�
�

�O�O�2�3�3�3�3�3��T�_�d�3�3�3�3�3rfrA�summary_resultc�v�tj|d�}|dkr||d<tj|d<t|��dS)z@
        Save status of sending statistics to json file
        �r�rAr?r�r�N)rB�SUCCESSr[rA)rAr�r_s   rg�_save_statuszCloudlinuxSummary._save_status
sJ��"/�!6�Y�O�O���Y�&�&�$2�K��!�$1�$8�K��!�,�[�9�9�9�9�9rfrNrOrPc���ttj����}||d<|�||���}||d�}t|d��|r|�||��dSdS)zH
        Send statistics data to server and save status to file
        rA)rOr�TN)rur8�_send_statisticsr-r�)r�rNrOrPrA�s_resultr�s       rgrYz2CloudlinuxSummary._send_statistics_and_save_statuss�����	���$�$�	�(�����(�(��c�(�:�:��$�9�=�=�����&�&�&��	������
�
�
�
�
�	�	rfc�8�|dz}|dkrdSdddt|jd��ddd	d
�tt	j|������g}	t
|d���\}}}n3#t$r&}t�	d
|��Yd}~dSd}~wwxYw|dkrLtj|��}	td�|dD����S#ttf$rYdSwxYwt�d||��dS)Nr�r3z/usr/sbin/lveinfor�z--idrfz--show-columns�mPMemz--periodz{}mT��return_full_outputz Unable to run lveinfo, error: %src��g|]
}|d��S)r�re�r��xs  rg�
<listcomp>z5CloudlinuxSummary._get_max_memory.<locals>.<listcomp>7s��D�D�D�1�A�g�J�D�D�DrfrIz-lveinfo failed with exit code: %i, output: %s)rtr�r�ru�math�ceilrrr��warningr��loads�maxr�r�r�)	r�r��time_minutes�cmdr��json_strr�r��parsed_datas	         rgr�z!CloudlinuxSummary._get_max_memory&sY��#�b�(���!����4�"�H��s�4�:�j�1�2�2����5�<�<��D�I�l�,C�,C�(D�(D�E�E�G��	�)�#�$�G�G�G�O�B��!�!��$�	�	�	����A�1�E�E�E��4�4�4�4�4�����	������7�7��*�X�.�.�K�
��D�D��F�0C�D�D�D�E�E�E����)�
�
�
��t�t�
�������6�79�8�	E�	E�	E��ts*�#A9�9
B)�B$�$B)�C&�&C;�:C;c��d}	d|z}t�|��tjd��}t	d��D]P}	tj||d���}n7#tj$r#}|}tjd|z��Yd}~�Id}~wwxYw|�|j	d	krt�d
��n:d�
|j	|j��}t�|��nE#tj$r3}t|��}t�
|��Yd}~nd}~wwxYw|S)z�
        Sends statistics to server
        :param data: Statistics data dict
        :return: string - message for JSON 'result' key
        r?zSending statictics to server %sz*Unknown exception while sending statistics�r�)r�r��N��zSending statictics OKr�)r�r�r�r�r�post�ConnectionErrorr8r9r�r�r�rtr�)rIrO�out_messager��expected_err�ir�r�s        rgr�z"CloudlinuxSummary._send_statistics>s}�� ��	*�7�#�=�G��O�O�G�$�$�$�#�4�<���L��1�X�X�	
#�	
#���'�}�S�t�R�H�H�H�H�
�E��	 �/�'�'�'�#&�L��J�q�A�v�&�&�&�&�&�&�&�&�����'����#�"��#�s�*�*���� 7�8�8�8�8�J�Q�Q��(��O��������,�,�,����(�	*�	*�	*��c�(�(�K����[�)�)�)�)�)�)�)�)�����	*�����sC�AC:�	A"� C:�"B�1B�
C:�B�A%C:�:D<�	)D7�7D<c��dtj��d�}|���|j�|��|S�Nr3)�versionrA)r8�_prepare_cl_normal_statisticsr�r��r�r�s  rgr�zCloudlinuxSummary._get_summaryfsI�������&�&��	
�*�*�,�,�,�����v�&�&�&��
rfc��dtj��d�}|���|j�|��|Sr�)r8�'_fill_dict_with_rpm_packages_statisticsr�r�r�s  rgrXz+CloudlinuxSummary._get_rpm_packages_summarynsI�������&�&��	
�4�4�6�6�6�����v�&�&�&��
rfc�@�tj��tjS)z/
         Get version of control panel
        )r�getCP�
CP_VERSIONrerfrg�_get_panel_versionz$CloudlinuxSummary._get_panel_versionvs��	������ � rfc��|j�tjdd��}|�H||jd<|j�d�ddd��|j�d�dd	d
��dSt
|jd	<dS)zN
        Fill dict with statistics by statistics about MySQL governor
        rtzCan't get MySQL governor modeN�mysql_governor_modec�B�t�����Src)r�get_governor_versionrerfrgrhzCCloudlinuxSummary._fill_mysql_governor_statistics.<locals>.<lambda>�s��
���<�<�>�>�rf�mysql_governor_versionz Can't get MySQL governor versionc�N�t�����dS�Nr)r�get_governor_statusrerfrgrhzCCloudlinuxSummary._fill_mysql_governor_statistics.<locals>.<lambda>�s��
���;�;�=�=�a�@�rf�mysql_governor_statuszCan't get MySQL governor status)r�r�r+�get_gov_mode_operationr�r)r��mysql_gov_modes  rg�_fill_mysql_governor_statisticsz1CloudlinuxSummary._fill_mysql_governor_statistics�s�����?�?��2��,�
�
��
�%�5C�D�O�1�2��O�)�)�>�>��(�3�	
�
�
�
�O�)�)�@�@��'�2�	
�
�
�
�
�8E�D�O�3�4�4�4rfc��|j�tjddd��|j�d�ddd��|j�|jddd	��|j�|jdd
d��|j�tdd
d��|j�d�ddd��tj��tjkr"|j�|j	ddd��|j�|j
ddd��|j�tddd��dS)zM
        Fill dict with statistics by statistics about control panel
        rt�control_panel_namezCan't get control panel namec�`�d�tj�����D��S)Nc��g|]	\}}|�|��
Srere)r��name�is_supporteds   rgr�zVCloudlinuxSummary._fill_control_panel_statistics.<locals>.<lambda>.<locals>.<listcomp>�s#��n�n�n�0�d�L�am�n�T�n�n�nrf)r�get_supported_cl_features�itemsrerfrgrhzBCloudlinuxSummary._fill_control_panel_statistics.<locals>.<lambda>�s*��n�n�E�4S�4U�4U�4[�4[�4]�4]�n�n�n�rfrw�supported_cl_featuresz8Can't get list of supported cl features by control panel�control_panel_versionzCan't get control panel version�control_panel_apachezCan't get control panel apacheru�
nginx_runningzCan't get control panel nginxc�B�ttj����Src)�lenr�cpusersrerfrgrhzBCloudlinuxSummary._fill_control_panel_statistics.<locals>.<lambda>�s��C��
���(�(�rf�users_totalzCan't get amount of users�installed_via_plesk_extz8Can't determine if CL was installed from Plesk Extension�login_via_whmcs_in_usez)Can't determine if Login via WHMCS in userz Can't if that is WP2 environmentN)r�r�r�	getCPNamer��_get_control_panel_apacher#r�
PLESK_NAME�_is_installed_via_plesk_ext�_is_login_via_whmcs_in_userr�s rg�_fill_control_panel_statisticsz0CloudlinuxSummary._fill_control_panel_statistics�s���
	
��%�%���� �+�		
�	
�	
�	
��%�%�n�n��#�G�		
�	
�	
�	
��%�%��#��#�.�		
�	
�	
�	
��%�%��*��"�-�		
�	
�	
�	
��%�%����,�		
�	
�	
�	
��%�%�(�(���(�		
�	
�	
������!1�1�1��O�)�)��0��)�K�	
�
�
�	
��%�%��+��$�8�		
�	
�	
�	
��%�%��� �/�		
�	
�	
�	
�	
rfc	��d}tj��tjkr|Sgd�}t	j|ddd���}t
j|j��}d|vr{d|dvrq|ddD]b}|ddkrTd	}t|�
d
d��|�
dd��|�
d
d��g��rd}n�c|S)zA
        Determine whether the login method is via WHMCS
        r�)z/usr/local/cpanel/bin/whmapi1�&get_available_authentication_providersz--output=jsonprettyT)�capture_outputr��checkrI�	providers�
provider_name�whmcsr�whostmgrd_enabledF�cpaneld_enabled�webmaild_enabledr3)rr�r�CPANEL_NAMEr]r^r�r��stdoutr�r�)rD�commandr�rI�providers     rgr�z,CloudlinuxSummary._is_login_via_whmcs_in_use�s��
�������!2�2�2��M�
�
�
��
����4�t�T�T�T���z�&�-�(�(���T�>�>�k�T�&�\�9�9� ��L��5�
�
���O�,��7�7��F�� ���%8�%�@�@� ���%6��>�>� ���%7��?�?����#�
"#���E�8��
rfc�P�d}d}tj�|��rd}|S)aV
        cldeploy-plesk-ext.log is always created by cldeploy-precheck when it downloads cldeploy script,
        if it exists it means there was an attempt to launch a cldeploy from Plesk Extension.
        Since this function is in package lve-utils, which depends from lve, it means that current os is CloudLinux,
        therefore conversion was successful.
        Possible false positives:
            - if there was failed attempt to convert os from Plesk Ext, and then it was successfully converted after manual run of cldeploy, it will be considered as CLOS installed via Plesk extension
            - if user has CL already installed and goes to CLOS Plesk Ext and tries to run conversion from there
        Possible false negatives:
            - if /var/log/cldeploy-plesk-ext.log was deleted or renamed/archived (e.g. via logrotate)
        Fz/var/log/cldeploy-plesk-ext.logTr)r��ext_logs  rgr�z-CloudlinuxSummary._is_installed_via_plesk_ext�s.����3��
�7�>�>�'�"�"�	��F��
rfc���t��r/tj��rd}nDtj��rd}n.d}n+|jddkrtj��rdnd}nd}|S)	z�
        Wrapper to retrieve control panel Apache version:
        EA3 or EA4 for cPanel, native otherwise
        :return: EA3|EA4|native
        �	litespeed�
openlitespeed�unknown_litespeedr��cPanel�EA4�EA3�native)rr�detect_enterprise_litespeed�detect_open_litespeedr��is_ea4r�s  rgr�z+CloudlinuxSummary._get_control_panel_apaches~�� �!�!�	��1�3�3�
-�$����-�/�/�
-�(���-���
�_�1�
2�h�
>�
>�$�m�o�o�8�U�U�5�F�F��F��
rfc��tj��}|�|Stjttjt
dtdti}|�|d��S)z�
        Wrapper to convert internal values from cagefs_statistics_config.get_cagefs_status function to values
         for statistics
        :return:
        N�Enabled�Disabled�Unknown)	r*�get_cagefs_status�CAGEFS_STATUS_NOT_INSTALLEDr�CAGEFS_STATUS_NOT_INITIALIZED�NOT_INITIALIZEDr�r�r�)�
cagefs_status�cagefs_status_maps  rg�_cagefs_status_wrapperz(CloudlinuxSummary._cagefs_status_wrapper$sX��1�B�D�D�
�� � � �$�@�-�$�B�O��w���	
��!�$�$�]�I�>�>�>rfc��|j�|jddd��|jdttfvrd|jd<n'|j�t
jddd��|j�tt
jd��ddd	��|j�tt
jd
��ddd��dS)
zF
        Fill dict with statistics by statistics about CageFS
        rtr
zCan't get CageFS statusN�cagefs_user_modezCan't get CageFS user modeT�cagefs_enabled_quantityz/Can't get quantity of users with enabled CageFSF�cagefs_disabled_quantityz0Can't get quantity of users with disabled CageFS)	r�r�rrrr*�get_cagefs_user_moder�get_quantityr�s rg�_fill_cagefs_statisticsz)CloudlinuxSummary._fill_cagefs_statistics6s���	
��%�%��'���&�		
�	
�	
��?�?�+�
��/O�O�O�26�D�O�.�/�/��O�)�)�(�=��"�-�	
�
�
�	
��%�%��,�9�4�@�@��%�>�		
�	
�	
�	
��%�%��,�9�5�A�A��&�?�		
�	
�	
�	
�	
rfc�D��	td�|j���D����}n#tj$rYdSwxYwt|jj������t�fd�|�	��D����S)zJ
        Get amount of end-users which belong to active resellers
        c3�,K�|]\}}|dk�|V��dS�rNre�r�r��lvps   rgr�zLCloudlinuxSummary._get_amount_of_endusers_under_resellers.<locals>.<genexpr>^�2����Y�Y���3�QT�WX�QX�QX��QX�QX�QX�QX�Y�YrfNc3� �K�|]}|�vV��	dSrcre)r��lvp_id�enabled_lvp_ids  �rgr�zLCloudlinuxSummary._get_amount_of_endusers_under_resellers.<locals>.<genexpr>bs(�����O�O��6�^�+�O�O�O�O�O�Orf)
rr��
lve_lvp_pairsrrQ�set�name_map�id_list�sum�elements)r��	lvp_countrs  @rg�'_get_amount_of_endusers_under_resellersz9CloudlinuxSummary._get_amount_of_endusers_under_resellersXs����
	��Y�Y�$�+�2K�2K�2M�2M�Y�Y�Y�Y�Y�I�I���!�	�	�	��4�4�	�����T�[�1�9�9�;�;�<�<���O�O�O�O�)�:L�:L�:N�:N�O�O�O�O�O�Os�04�A�Ac���	td�|j���D����}n#tj$rYdSwxYwt|�����S)z/
        Get total amount of end-users
        c3�,K�|]\}}|dk�|V��dSrrers   rgr�zBCloudlinuxSummary._get_total_amount_of_endusers.<locals>.<genexpr>jrrfN)rr�r rrQr$r�)r�r&s  rg�_get_total_amount_of_endusersz/CloudlinuxSummary._get_total_amount_of_endusersdsr��
	��Y�Y�$�+�2K�2K�2M�2M�Y�Y�Y�Y�Y�I�I���!�	�	�	��4�4�	�����9�#�#�%�%�&�&�&s�03�A�Ac�p�	ttj����S#tj$rYdSwxYw)z)
        Get amount of resellers
        N)r�r�	resellersrQrerfrg�_get_amount_of_resellersz*CloudlinuxSummary._get_amount_of_resellersosB��	��u��(�(�)�)�)���!�	�	�	��D�D�	���s�"�5�5c����j�tjjddd���j�tjjddd���j�tjjddd���j��jddd	���j��jdd
d���j��j	ddd
���j��fd�ddd���jdr �j�d�ddd��dSd�jd<d�jd
<d�jd<dS)zP
        Fill dict with statistics by varied statistics about resellers
        ru� reseller_limits_supported_kernelz8Can't detect status of support reseller limits by kernel�'reseller_limits_supported_control_panelz?Can't detect status of support reseller limits by control panel�reseller_limits_enabledz1Can't detect status of support of reseller limits�resellers_totalz#Can't get total amount of resellers�(resellers_endusers_under_reseller_limitsz>Can't get amount of end-users which belong to active resellers�resellers_endusers_totalz#Can't get total amount of end-usersc�,������Src)�_get_resellers_with_faultsr�s�rgrhz>CloudlinuxSummary._fill_resellers_statistics.<locals>.<lambda>�s���D�3�3�5�5�rf�resellers_with_faultsz:Can't get amount of resellers with faults for the past 24hc�\�tttj������Src)r�rdrm�lvp_listrerfrgrhz>CloudlinuxSummary._fill_resellers_statistics.<locals>.<lambda>�s���D��!3�!5�!5�6�6�7�7�rf�resellers_activez$Can't get amount of active resellersN)
r�r�rm�lve�is_lve10�is_panel_supported�reseller_limit_supportedr-r'r*r�s`rg�_fill_resellers_statisticsz,CloudlinuxSummary._fill_resellers_statisticszs����	
��%�%��M�"��.�G�		
�	
�	
�	
��%�%��M�,��5�N�		
�	
�	
�	
��%�%��M�2��
&�@�
	
�	
�	
�	
��%�%��)���2�		
�	
�	
�	
��%�%��8��6�M�		
�	
�	
�	
��%�%��.��&�2�		
�	
�	
�	
��%�%�5�5�5�5��#�I�		
�	
�	
��?�4�5�
	<��O�)�)�7�7��"�7�	
�
�
�
�
�37�D�O�.�/�JN�D�O�F�G�7;�D�O�3�4�4�4rfc���|j�t|j�jt
j�jt
j��ddd��|j�t|j�jt
j��ddd��|j��fd�ddd	��|j��fd
�ddd��|j��fd
�ddd��|j��fd�ddd��|j��fd�ddd��|j�t|j	�jt
j
��ddd��|j�t|j	�jt
j��ddd��dS)zN
        Fill dict with statistics by statistics about default limits
        ru�default_limit_speedzCan't get default speed limitrt�default_limit_cpu_origin_unitsz+Can't get cpu origin units of default limitc�2���jtjSrc)�defaultsr0�ncpu��xml_cfg_providers�rgrhzCCloudlinuxSummary._fill_default_limits_statistics.<locals>.<lambda>�����$�-�h�7�<�rf�default_limit_ncpuzCan't get default ncpu limitc�2���jtjSrc)rDr0�iorFs�rgrhzCCloudlinuxSummary._fill_default_limits_statistics.<locals>.<lambda>�����$�-�h�7�:�rf�default_limit_iozCan't get default io limitc�2���jtjSrc)rDr0�nprocrFs�rgrhzCCloudlinuxSummary._fill_default_limits_statistics.<locals>.<lambda>�s���$�-�h�7�=�rf�default_limit_nproczCan't get default nproc limitc�2���jtjSrc)rDr0�eprFs�rgrhzCCloudlinuxSummary._fill_default_limits_statistics.<locals>.<lambda>�rLrf�default_limit_epzCan't get default ep limitc�2���jtjSrc)rDr0�iopsrFs�rgrhzCCloudlinuxSummary._fill_default_limits_statistics.<locals>.<lambda>�rHrf�default_limit_iopszCan't get default iops limit�default_limit_vmem_mbzCan't get default vmem limit�default_limit_pmem_mbzCan't get default pmem limitN)r�r�r�_cpu_limit_to_percentsrDr0�cpurE�_get_cpu_limit_units�_mempages_to_mb�vmem�pmem�r�rGs `rg�_fill_default_limits_statisticsz1CloudlinuxSummary._fill_default_limits_statistics�s���	
��%�%���+� �)�(�3�7� �)�(�3�8�
�
�

�!�,�		
�		
�		
�	
��%�%��D�-�/?�/H��/R�/V�W�W��,�:�		
�	
�	
�	
��%�%�<�<�<�<�� �+�		
�	
�	
�	
��%�%�:�:�:�:���)�		
�	
�	
�	
��%�%�=�=�=�=��!�,�		
�	
�	
�	
��%�%�:�:�:�:���)�		
�	
�	
�	
��%�%�<�<�<�<�� �+�		
�	
�	
�	
��%�%��D�(�*:�*C�H�*M�*R�S�S��#�+�		
�	
�	
�	
��%�%��D�(�*:�*C�H�*M�*R�S�S��#�+�		
�	
�	
�	
�	
rfc���|j��fd�ddd��|j��fd�ddd��|j��fd�dd	d
��|j�|jddd��d
S)z�
        Fill dict with statistics by other statistics about limits:
        packages_total, users_total, amount users/packages with custom limits
        c�,��t�j��Src)r��packagesrFs�rgrhzACloudlinuxSummary._fill_other_limits_statistics.<locals>.<lambda>s���C�(�1�2�2�rfru�packages_totalz"Can't get total amount of packagesc�F��t������Src)r��get_packages_with_custom_limitsrFs�rgrhzACloudlinuxSummary._fill_other_limits_statistics.<locals>.<lambda>s���C�(�H�H�J�J�K�K�rf�packages_with_custom_limitsz/Can't get amount of packages with custom limitsc�F��t������Src)r��get_users_with_custom_limitsrFs�rgrhzACloudlinuxSummary._fill_other_limits_statistics.<locals>.<lambda>
s���C�(�E�E�G�G�H�H�rf�users_with_custom_limitsz,Can't get amount of users with custom limits�users_with_faultsz6Can't get amount of users with faults for the past 24hN)r�r��_get_users_with_faultsr_s `rg�_fill_other_limits_statisticsz/CloudlinuxSummary._fill_other_limits_statistics�s����	
��%�%�2�2�2�2���1�		
�	
�	
�	
��%�%�K�K�K�K��)�>�		
�	
�	
�	
��%�%�H�H�H�H��&�;�		
�	
�	
�	
��%�%��'���E�		
�	
�	
�	
�	
rfc����tdd��D�]�}�j�t�j||��dd|z�����dS�j��fd�dd|zd|zd	�
���j��fd�dd
|zd|zd	�
���j���fd�dd|zd|zd	�
���j���fd�dd|zd|zd	�
���j��fd�dd|zd|zd	�
���j��fd�dd|zd|zd	�
���j��fd�dd|zd|zd	�
���j��fd�dd|zd |zd	�
���j��fd!�dd"|zd#|zd	�
���j���fd$�dd%|zd&|zd	�
���j���fd'�dd(|zd)|zd	�
�����dS)*zV
        Fill dict with statistics by statistics about top packages on server
        r3r�rtz!Can't get top %s package by usersNc����djS�Nr3�r���
top_results�rgrhzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>-s���
�1�
�*�rfztop_%s_package_namez1Can't get package name of top %s package by usersFr�c�.��t�d��Sr�r+rrs�rgrhzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>4s����J�q�M�*�*�rfruztop_%s_package_users_numz4Can't get amount of users in top %s package by usersc������djptj�djptj��Srp)rY�limitsr1rZrE�r�rss��rgrhzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda><s;����3�3���]�)�9�\�>���]�)�9�\�?���rfztop_%s_package_limit_speedz0Can't get speed limit of top %s package by usersc�\�����djptj��Srp)r[rvr1rZrws��rgrhzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>Gs)����1�1���]�)�9�\�>���rfz%top_%s_package_limit_cpu_origin_unitsz>Can't get cpu origin units of limit of top %s package by usersc�6���djptjSrp)rvr1rErrs�rgrhzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>P�����A��-�=��C�rfztop_%s_package_limit_ncpuz/Can't get ncpu limit of top %s package by usersc�6���djptjSrp)rvr1rKrrs�rgrhzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>W�����A��-�=��A�rfztop_%s_package_limit_ioz-Can't get io limit of top %s package by usersc�6���djptjSrp)rvr1rOrrs�rgrhzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>^s����A��-�=��D�rfztop_%s_package_limit_nprocz0Can't get nproc limit of top %s package by usersc�6���djptjSrp)rvr1rRrrs�rgrhzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>er|rfztop_%s_package_limit_epz-Can't get ep limit of top %s package by usersc�6���djptjSrp)rvr1rUrrs�rgrhzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>lrzrfztop_%s_package_limit_iopsz/Can't get iops limit of top %s package by usersc�\�����djptj��Srp)r\rvr1r]rws��rgrhzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>s�$����,�,�j��m�.B�.R�l�-X�Y�Y�rfztop_%s_package_limit_vmem_mbz/Can't get vmem limit of top %s package by usersc�\�����djptj��Srp)r\rvr1r^rws��rgrhzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>{r�rfztop_%s_package_limit_pmem_mbz/Can't get pmem limit of top %s package by users)rr�r�r�#_get_top_package_by_number_of_usersr�)r�rGr�rss`  @rg�_fill_top_packages_statisticsz/CloudlinuxSummary._fill_top_packages_statisticss{�����q�!���b	�b	�A���?�?���@�!�EU�V�V��4�q�8���J��!����
�O�)�)�*�*�*�*��%��)�D�q�H�#�
*�
�
�
�
�O�)�)�*�*�*�*��*�Q�.�G�!�K�#�
*�
�
�
�
�O�)�)�������,�q�0�C�a�G�#�
*�

�

�

�
�O�)�)�������7�!�;�Q�TU�U�#�
*�	
�	
�	
�
�O�)�)�C�C�C�C��+�a�/�B�Q�F�#�
*�
�
�
�
�O�)�)�A�A�A�A��)�A�-�@�1�D�#�
*�
�
�
�
�O�)�)�D�D�D�D��,�q�0�C�a�G�#�
*�
�
�
�
�O�)�)�A�A�A�A��)�A�-�@�1�D�#�
*�
�
�
�
�O�)�)�C�C�C�C��+�a�/�B�Q�F�#�
*�
�
�
�
�O�)�)�Y�Y�Y�Y�Y��.��2�B�Q�F�#�

*�
�
�
�
�O�)�)�Y�Y�Y�Y�Y��.��2�B�Q�F�#�

*�
�
�
�
�wb	�b	rfc��t��}|�|��|�|��|�|��dS)zN
        Fill dict with statistiscs by varied statistics about limits
        N)r/r`rmr�r_s  rg�_fill_limits_statisticsz)CloudlinuxSummary._fill_limits_statistics�sU��
-�.�.���,�,�-=�>�>�>��*�*�+;�<�<�<��*�*�+;�<�<�<�<�<rfc���|j�|jdd������V|j��fd�dddd���|j��fd	�dd
dd���|j��fd�dd
dd���|j��fd�dddd���|j��fd�dddd���|j��fd�dddd���|j��fd�dddd���|j��fd�dddd���|j��fd�d d!d"d���|j��fd#�dd$d%d���dSt|jd<dS)&zI
        Fill dict with statistics by statistics about mod_lsapi
        rtzCan't get raw mod_lsapi infoNc� ���ddS)N�criurDre��raw_lsapi_infos�rgrhz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>�s����v�.�x�8�rf�lsapi_criu_service_statusz Can't get status of criu serviceFr�c� ���ddS)Nr�r�rer�s�rgrhz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>�s����v�.�y�9�rf�lsapi_criu_service_versionz!Can't get version of criu servicec� ���ddS)N�	lsapiConf�
lsapi_criurer�s�rgrhz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>�s����{�3�L�A�rf�lsapi_option_criuzCan't get state of criuc� ���ddS)Nr��lsapi_with_connection_poolrer�s�rgrhz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>�s����{�3�4P�Q�rf�lsapi_option_connection_poolz,Can't get state of mod_lsapi connection poolc����dS)N�
libVersionrer�s�rgrhz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>������|�4�rf�lsapi_lib_versionz"Can't get version of mod_lsapi libc����dS)N�	modStatusrer�s�rgrhz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>�s����{�3�rf�lsapi_mod_statuszCan't get mod_lsapi statusc����dS)N�
modVersionrer�s�rgrhz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>�r�rf�lsapi_mod_versionzCan't get mod_lsapi versionc����dS)N�totalDomainrer�s�rgrhz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>�s����}�5�rfru�lsapi_total_domain_countz5Can't get total amount of domains which use mod_lsapic����dS)N�
domainStatrer�s�rgrhz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>�r�rfry�lsapi_domain_statz.Can't get statistics of domains with mod_lsapic����dS)N�controlPanelrer�s�rgrhz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>�s����~�6�rf�lsapi_apache_environmentzCan't get apache environment)r�r��get_raw_lsapi_infor�r)r�r�s @rg�_fill_lsapi_statisticsz(CloudlinuxSummary._fill_lsapi_statistics�s����
��?�?��#��+�
�
��
�%��O�)�)�8�8�8�8��+�3�#�
*�
�
�
�
�O�)�)�9�9�9�9��,�4�#�
*�
�
�
�
�O�)�)�A�A�A�A��#�*�#�
*�
�
�
�
�O�)�)�Q�Q�Q�Q��.�?�#�
*�
�
�
�
�O�)�)�4�4�4�4��#�5�#�
*�
�
�
�
�O�)�)�3�3�3�3��"�-�#�
*�
�
�
�
�O�)�)�4�4�4�4��#�.�#�
*�
�
�
�
�O�)�)�5�5�5�5��*�H�#�
*�
�
�
�
�O�)�)�4�4�4�4��#�A�#�
*�
�
�
�
�O�)�)�6�6�6�6��*�/�#�
*�
�
�
�
�
�3@�D�O�.�/�/�/rfc�J�|j�|jddd��dS)Nr{�
wmt_configz!Cant get status of wmt_api_config)r�r��_get_wmt_api_configr�s rg�_fill_wmt_settings_statisticsz/CloudlinuxSummary._fill_wmt_settings_statistics�s5����%�%��$���/�		
�	
�	
�	
�	
rfc������	|���\�}�nF#t$r9}t�dt	|����ggic�}�Yd}~nd}~wwxYwtt
���t
|��z
��}	|�|��\��nD#t$r7}t�dt	|����iic��Yd}~nd}~wwxYw|r$��dt|��i��|j
��fd�ddd��|j
��fd�d	d
d��|j
��fd�d	d
d��|j
��fd�ddd��|j
��fd�ddd��|j
��fd�d	dd��dS)Nz+Error while getting WordPress statistics %sz3Error while getting WordPress plugins statistics %s�cloudlinux_wpos_object_cachec�"��t���Src�r�)�all_wp_pathss�rgrhz7CloudlinuxSummary._fill_wp_statistics.<locals>.<lambda>�s���C��%�%�rfru�wordpress_installed_totalz,Can't get total count of installed wordpressc����Srcre��object_cache_pluginss�rgrhz7CloudlinuxSummary._fill_wp_statistics.<locals>.<lambda>s���(�rfry�wordpress_object_cache_pluginsz&Can't get WP object cache plugins infoc����Srcre��advanced_cache_pluginss�rgrhz7CloudlinuxSummary._fill_wp_statistics.<locals>.<lambda>s���*�rf� wordpress_advanced_cache_pluginsz(Can't get WP advanced cache plugins infoc�F��t������Src�r$r�r�s�rgrhz7CloudlinuxSummary._fill_wp_statistics.<locals>.<lambda>s���C�,�3�3�5�5�6�6�rf�$wordpress_object_cache_plugins_totalz,Can't get WP object cache total plugins infoc�F��t������Srcr�r�s�rgrhz7CloudlinuxSummary._fill_wp_statistics.<locals>.<lambda>s���C�.�5�5�7�7�8�8�rf�&wordpress_advanced_cache_plugins_totalz.Can't get WP advanced cache total plugins infoc����Srcre)�wp_php_versionss�rgrhz7CloudlinuxSummary._fill_wp_statistics.<locals>.<lambda>s���O�rf�wordpress_php_versionszCan't get WP php version info)�_prepare_wp_statisticsrr�r�rtrdr!�_prepare_wp_plugins_statisticsr�r�r�r�)r��paths_with_wpos_object_cacher��without_wpos_object_cacher�r�r�r�s    @@@@rg�_fill_wp_statisticsz%CloudlinuxSummary._fill_wp_statistics�s�������	U�JN�Je�Je�Jg�Jg�G�L�6�����	U�	U�	U����J�C�PQ�F�F�S�S�S�JL�b�RT�G�L�6�����������	U����%)��\�):�):�S�A]�=^�=^�)^�$_�$_�!�	B��3�3�4M�N�N�
9� �"8�"8���	B�	B�	B����R�TW�XY�TZ�TZ�[�[�[�;=�r�8� �"8�"8�"8�"8�"8�"8�����	B����(�	� �'�'�.��4P�0Q�0Q�)�
�
�
�	
��%�%�%�%�%�%��'�;�		
�	
�	
�	
��%�%�(�(�(�(��,�5�		
�	
�	
�	
��%�%�*�*�*�*��.�7�		
�	
�	
�	
��%�%�6�6�6�6��2�;�		
�	
�	
�	
��%�%�8�8�8�8��4�=�		
�	
�	
�	
��%�%�#�#�#�#��$�,�		
�	
�	
�	
�	
s,��
A"�/A�A"�B+�+
C,�5-C'�'C,c�B���	|���\��nC#t$r6}t�dt	|����g�g�Yd}~nd}~wwxYw|j��fd�ddd��|j��fd�ddd��dS)	Nz4Error while getting per-user WordPress statistics %sc�"��t���Srcr�)�
users_with_wps�rgrhz@CloudlinuxSummary._fill_per_user_wp_statistics.<locals>.<lambda>,s���C�
�&�&�rfru�$users_count_with_wordpress_installedz7Can't get total count of users with wordpress installedc�"��t���Srcr�)�users_with_wp_and_litespeeds�rgrhz@CloudlinuxSummary._fill_per_user_wp_statistics.<locals>.<lambda>2s���C�3�4�4�rf�0users_count_with_wordpress_and_lscache_installedzECan't get total count of users with wordpress and LiteSpeed installed)�_prepare_per_user_wp_statisticsrr�r�rtr�r�)r�r�r�r�s  @@rg�_fill_per_user_wp_statisticsz.CloudlinuxSummary._fill_per_user_wp_statistics#s�����	-�9=�9]�9]�9_�9_�6�M�6�6���	-�	-�	-����S�UX�YZ�U[�U[�\�\�\��M�*,�'�'�'�'�'�'�����	-����
	
��%�%�&�&�&�&��2�F�		
�	
�	
�	
��%�%�4�4�4�4��>�T�		
�	
�	
�	
�	
s��
A�,A�Ac�b�|�d|��}|�d|��}||fS)zq
        Prepares dict with plugin-counter pairs
        e.g: {'w3-total-cache': 4, 'redis': 1, 'ls': 2}
        �object-cache�advanced-cache)�_get_plugin_info)r��wp_pathsr�r�s    rgr�z0CloudlinuxSummary._prepare_wp_plugins_statistics8s=��
 $�4�4�^�X�N�N��!%�!6�!6�7G��!R�!R��#�%;�;�;rf�plugin_typer�c���ttd�fd�|D������}tt��}|D]}||xxdz
cc<�|S)Nc�0��g|]}t|�����Sre)r%)r�r�r�s  �rgr�z6CloudlinuxSummary._get_plugin_info.<locals>.<listcomp>Cs:���2H�2H�2H�6:�3F�d�K�2X�2X�2H�2H�2Hrfr3)rd�filterr	ru)r�r�r��object_plugin_counter_pairs�plugins`    rgr�z"CloudlinuxSummary._get_plugin_infoAs����#�F�4�2H�2H�2H�2H�>F�2H�2H�2H�%I�%I� J� J��&1�#�&6�&6�#�*�	5�	5�F�'��/�/�/�1�4�/�/�/�/�*�*rfc�j�gg}}tt��}tj��}|D�]}	tj|��}n#t
$rY�%wxYwtt��}|D]?\}}	tj�	|	��r||	�
|���@|D]~}	|�||	|��}
|
d}|
d}|�|��|�|
d��|r#|dkr||xxt|��z
cc<���|||fS)z�
        Return Wordpress absolute paths, paths with install WPOS object cache module
        and counter of php versions that are used by these Wordpresses.
        r��php_version�'wp_paths_with_enabled_wpos_object_cache�	undefined)r	rurr��userdomainsrrdr�r�r�append�_get_docroot_wp_inforpr�)
r�r��$paths_with_enabled_wpos_object_cache�php_versions�panel_users�user�domains_info�docroot_domains_map�domain�docroot�docroot_info�docroot_wp_paths�docroot_php_versions
             rgr�z(CloudlinuxSummary._prepare_wp_statisticsJs���
>@��:��"�3�'�'���m�o�o���	O�	O�D�
�$�0��6�6�����
�
�
���
����#.�d�"3�"3��#/�
@�
@�����7�>�>�'�*�*�@�'��0�7�7��?�?�?��.�
O�
O��#�8�8��w�H[�\�\��#/�
�#;� �&2�=�&A�#��#�#�$4�5�5�5�4�;�;� �!J�K����$�O�(;�{�(J�(J� �!4�5�5�5��=M�9N�9N�N�5�5�5��
O��A�<�O�Os�A�
A�Ac��t��t��}}tj��}|D�]&}	tj|��}n?#t$r2}t
�dt|����Yd}~�Pd}~wwxYwtt��}|D]?\}}	tj�|	��r||	�
|���@|D]u}	|�||	|��}
t|
d��dkr|�|��t|
d��dkr|�|���v��(||fS)z]
        Return Wordpress absolute paths, paths with install LiteSpeed cache plugin.
        z(Can't get user's domains info, error: %sNr�r�%wp_paths_with_enabled_litespeed_cache)r!rr�r�rr�r�rtr	rdr�r�rr�r�r��add)r�r�r�r�r�r�r�r�r�r�r�s           rgr�z1CloudlinuxSummary._prepare_per_user_wp_statisticsmsz��69�U�U�C�E�E�2�
��m�o�o���	:�	:�D�
�$�0��6�6�����
�
�
�� � �!K�S�QR�V�V�T�T�T����������
����#.�d�"3�"3��#/�
@�
@�����7�>�>�'�*�*�@�'��0�7�7��?�?�?��.�
:�
:��#�8�8��w�H[�\�\���|�J�/�0�0�1�4�4�!�%�%�d�+�+�+��|�$K�L�M�M�PQ�Q�Q�/�3�3�D�9�9�9��

:��9�9�9s�A�
B�(B�Br�r�r�c����ggt��dd�}��fd�t���D��}|s|S�fd�|D��|d<�fd�t||��D��|d<|dD]d}t|d��}|�d
|vr|d�|��t|d��}|�d
|vr|d�|���e��D]$}	|�|	��}
|
dkr|
|d
<n�%|S)zM
        Return data about docroot's WP paths and used php versions.
        r�)r�r�r�r�c���g|]J}tj��|���ks"tj��|���v�H|��KSre)r�r�r�)r��wp_pathr�r�s  ��rgr�z:CloudlinuxSummary._get_docroot_wp_info.<locals>.<listcomp>�sZ���
�
�
���w�|�|�G�W�-�-��8�8��'�,�,�w��0�0�8K�K�K�
�K�K�Krfc�T��g|]$}t����|����%Sre�r�joinpath�r�r�r�s  �rgr�z:CloudlinuxSummary._get_docroot_wp_info.<locals>.<listcomp>�s-���#V�#V�#V�T�D��M�M�$:�$:�4�$@�$@�#V�#V�#Vrfr�c�X��g|]&}|�t����|����'Srcr�r�s  �rgr�z:CloudlinuxSummary._get_docroot_wp_info.<locals>.<listcomp>�s@���C
�C
�C
�-1���
��M�M�"�"�4�(�(���rfr�r�Nr�r�r�r�)r!r$r&r%r��_get_php_version_for_domain)r�r�r�r�r�r�r��object_cache_plugin�advanced_cache_pluginr�r�s  ``       rgr�z&CloudlinuxSummary._get_docroot_wp_info�s������79�58�U�U�&�	
�
��
�
�
�
�
�#0��#9�#9�
�
�
���	 ���#V�#V�#V�#V�X�#V�#V�#V��Z� �C
�C
�C
�C
�5U�VZ�\d�5e�5e�C
�C
�C
��>�?�
!��,�	P�	P�D�"5�d�N�"K�"K��"�.�;�BU�3U�3U��D�E�I�I�$�O�O�O�$7��>N�$O�$O�!�$�0�[�DY�5Y�5Y��D�E�I�I�$�O�O�O��)�'�2�	�	�F��:�:�6�B�B�K��k�)�)�.9��]�+���*��rfr�c��tj��tjtjtjfvrdS|���\}}}|�|i��}|�dd��}tj��tjkr||kr|S|���D],\}}||vr#|dkrd|�	dd����}	|	cS�-tj��tjkrd|�	dd����}
|
Stj��tjkrE|�dd��}|d	t|����d
��}|pdS|S)z�
        Return php version that is used for specified domain.
        Determine whether of MultiPHP Manager or PHP Selector is used.
        r��php_version_idrzalt-php�.r�zda-php�handler_typeN�-)rr�rr��DIRECTADMIN_NAMEr��_get_system_php_infor�r��replacer�r)
r�r��system_default_php_version�domains_php_info�selector_php_info�php_info�multi_php_versionr��domains�alt_php_version�da_php_version�handlerr�s
             rgr�z-CloudlinuxSummary._get_php_version_for_domain�s���
����e�&7��9O�QV�Qa�%b�b�b��;�JN�Jc�Jc�Je�Je�G�"�$4�6G�$�'�'���3�3��$�L�L�)9�;�G�G��
�����!2�2�2�.�2C�C�C�$�$�!2� 7� 7� 9� 9�	'�	'��G�W��� � �W��%8�%8�"F�G�O�O�C��,D�,D�"F�"F��&�&�&�&�������!7�7�7�J�&7�&?�&?��R�&H�&H�J�J�N�!�!������!1�1�1��l�l�>�2�6�6�G�+�N�c�'�l�l�]�N�;�A�A�#�F�F�K��-�+�-� � rf)�maxsizec���	tj��d}n#t$rd}YnwxYwtj��}t	��}|�	|d}ni}|||fS)z�
        Return info about:
        - system_php_version (implemented only on cPanel)
        - domains_php_info (php versions and handlers turned on in MultiPHP)
        - selector_php_info (php version used by panel users via PHP Selector)
        �default_version_idN�domains_by_php_version)r�get_system_php_infor�get_domains_php_inforZ)�system_php_versionr�php_selector_usagers    rgrz&CloudlinuxSummary._get_system_php_info�s���	&�!&�!:�!<�!<�=Q�!R�����	&�	&�	&�!%����	&����!�5�7�7��3�5�5���)� 2�3K� L��� "��!�#3�5F�F�Fs��+�+c����|j�|jdd������B|j��fd�ddd��|j��fd�dd	d
��|j��fd�ddd
��|j��fd�ddd��|j��fd�ddd��|j��fd�ddd��|j��fd�ddd��|j��fd�ddd��|j��fd�ddd ��|j��fd!�d"d#d$��dSt|jd<dS)%z/
        Fill dict with SSA statistics
        rtzCan't get SSA statisticsNc����dS)N�configre��	ssa_statss�rgrhz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>����	�(�+�rfr{�
ssa_configzCan't get SSA configc����dS)Nr�rers�rgrhz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>s���	�)�,�rf�ssa_versionzCan't get version of SSAc����dS)NrDrers�rgrhz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>rrf�
ssa_statuszCan't get state of SSAc����dS)N�agent_statusrers�rgrhz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>s���	�.�1�rf�ssa_agent_statuszCan't get state of SSA agentc� ���ddS)N�autotracingrDrers�rgrhz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda> s���	�-�0��:�rf�autotracing_statusz"Can't get state of SSA Autotracingc� ���ddS)Nr&�disabled_users_quantityrers�rgrhz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>&s���	�-�0�1J�K�rfru�#autotracing_disabled_users_quantityz1Can't get state of SSA Autotracing disabled usersc� ���ddS)Nr&�
rules_versionrers�rgrhz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>,����	�-�0��A�rf�autotracing_rules_versionz'Can't get SSA Autotracing rules versionc� ���ddS)Nr&�urls_processedrers�rgrhz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>2s���	�-�0�1A�B�rf�autotracing_urls_processedz.Can't get SSA Autotracing processed URLs countc� ���ddS)Nr&�
urls_selectedrers�rgrhz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>8r-rf�autotracing_urls_selectedz-Can't get SSA Autotracing selected URLs countc� ���ddS)Nr&�rejectsrers�rgrhz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>>s���	�-�0��;�rfry�autotracing_rejectsz!Can't get SSA Autotracing rejects)r�r��
get_ssa_statsr�r)r�rs @rg�_fill_ssa_statisticsz&CloudlinuxSummary._fill_ssa_statistics�s6���
�O�:�:����'�
�
�	�� ��O�)�)�+�+�+�+���'�	
�
�
�
�O�)�)�,�,�,�,���+�	
�
�
�
�O�)�)�+�+�+�+���)�	
�
�
�
�O�)�)�1�1�1�1��"�/�	
�
�
�
�O�)�)�:�:�:�:��$�5�	
�
�
�
�O�)�)�K�K�K�K��5�D�	
�
�
�
�O�)�)�A�A�A�A��+�:�	
�
�
�
�O�)�)�B�B�B�B��,�A�	
�
�
�
�O�)�)�A�A�A�A��+�@�	
�
�
�
�O�)�)�;�;�;�;��%�4�	
�
�
�
�
�-:�D�O�L�)�)�)rfc����|j�d�dd��}|���|j�t|jd��ddd��|j�t|j|t��d	d
dd�
��|j�t|j|t��d	ddd�
��|j�tddd��|j�tddd��|j�td��jddd��|j�tddd��|j�tdd�����d|jd<d|jd<dS|j��fd�dddd�
��|j��fd�dddd�
��dSt|jd<dS) zS
        Fill dict with statistics by varied statistics about PHP selector
        c� �td��S)Nr)rXrerfrgrhzACloudlinuxSummary._fill_php_selector_statistics.<locals>.<lambda>Ns��+�E�2�2�rfruz+Can't get statistics about PHP interpretersNrrt�selector_php_statusz Can't get status of PHP selectorrw�selector_php_versions_installedz8Can't get list of versions of installed PHP interpretersFr��selector_php_versions_enabledz6Can't get list of versions of enabled PHP interpreters�selector_php_version_defaultz,Can't get default version of PHP interpreter�selector_php_version_nativez+Can't get native version of PHP interpreter�selector_php_enabled_uiz%Can't get state of UI of PHP selector�selector_php_modezCan't get mode of PHP selectorz'Can't get summary usage of PHP selector�'selector_php_num_domains_by_interpreter�%selector_php_num_users_by_interpreterc�L��d��d���D��S)Nc�4�i|]\}}|t|����Srer��r��vrs   rg�
<dictcomp>zUCloudlinuxSummary._fill_php_selector_statistics.<locals>.<lambda>.<locals>.<dictcomp>�s$��s�s�s���G�Q��G���s�s�srfr�r���php_usage_summarys�rgrhzACloudlinuxSummary._fill_php_selector_statistics.<locals>.<lambda>�s)���s�s�?P�Qi�?j�?p�?p�?r�?r�s�s�s�rfryzBCan't get amount of domains which use PHP selector per PHP versionc�L��d��d���D��S)Nc�4�i|]\}}|t|����Srer�rGs   rgrIzUCloudlinuxSummary._fill_php_selector_statistics.<locals>.<lambda>.<locals>.<dictcomp>�s$��q�q�q���G�Q��G���q�q�qrf�users_by_php_versionrJrKs�rgrhzACloudlinuxSummary._fill_php_selector_statistics.<locals>.<lambda>�s)���q�q�?P�Qg�?h�?n�?n�?p�?p�q�q�q�rfz@Can't get amount of users which use PHP selector per PHP version)r�r�r�rr�"_get_list_versions_of_interperters�	INSTALLEDr�r\rYr^�php_selector_is_enabledr]rZr)r��php_interpretersrLs  @rg�_fill_php_selector_statisticsz/CloudlinuxSummary._fill_php_selector_statisticsGsl��� �?�A�A�2�2��:�
�
��
�'��O�)�)���4�e�<�<��%�3�	
�
�
�
�O�)�)���?�AQ�S\�]�]��1�K�#�
*�
�
�
�
�O�)�)���?�AQ�SZ�[�[��/�I�#�
*�
�
�
�
�O�)�)�'��.�?�	
�
�
�
�O�)�)�'��-�>�	
�
�
�
�O�)�)�%�e�,�,�D��)�8�	
�
�
�
�O�)�)�(��#�1�	
�
�
�!%�� F� F�&��:�!�!��
!�(�MQ��� I�J�KO��� G�H�H�H���-�-�s�s�s�s��=�Y�"'�.������-�-�q�q�q�q��;�W�"'�.������6C�D�O�1�2�2�2rfc�(�|dks|dkrdS||zS)z�
        Get average amount of applications per domain
        :param total_apps: total amount of applications
        :param amount_of_apps_per_domain: amount of applications per domain
        r3Nre)�
total_apps�amount_of_apps_per_domains  rg�_get_average_apps_per_domainz.CloudlinuxSummary._get_average_apps_per_domain�s)����>�>�6��:�:��4��6�6�6rfc�(�|dks|dkrdS||zS)z�
        Get average amount of applications per user
        :param total_apps: total amount of applications
        :param amount_of_apps_per_user: amount of applications per user
        r3Nre)rV�amount_of_apps_per_users  rg�_get_average_apps_per_userz,CloudlinuxSummary._get_average_apps_per_user�s)����>�>�4�q�8�8��4��4�4�4rfc�4�td�|D����S)z
        Get amount of running applications on server
        :param apps: list of applications for something selector
        c�6�g|]}|j�	|jdk�|��S)�started)�
app_status)r��apps  rgr�z@CloudlinuxSummary._get_amount_of_runned_apps.<locals>.<listcomp>�s,��Z�Z�Z�C�3�>�Z�c�n�PY�>Y�>Y�C�>Y�>Y�>Yrfr�)�appss rg�_get_amount_of_runned_appsz,CloudlinuxSummary._get_amount_of_runned_apps�s!���Z�Z�4�Z�Z�Z�[�[�[rfc��t��}|D]}||jxxdz
cc<�|�d��pdg}|ddS)z�
        Get maximum amount of applications per domain
        :param apps: list of applications for something selector
        r3�rrr)r�doc_root�most_common)ra�apps_per_domainr`�most_commonss    rg�_get_max_apps_per_domainz*CloudlinuxSummary._get_max_apps_per_domain�sh��"�)�)���	/�	/�C��C�L�)�)�)�Q�.�)�)�)�)�'�2�2�1�5�5�A�&����A��q�!�!rfc��t��}|D]}||jxxdz
cc<�|�d��pdg}|ddS)z~
        Get maximum amount of applications per user
        :param apps: list of applications for something selector
        r3rdr)rr�rf)ra�
apps_per_userr`rhs    rg�_get_max_apps_per_userz(CloudlinuxSummary._get_max_apps_per_user�sh�� �	�	�
��	)�	)�C��#�(�#�#�#�q�(�#�#�#�#�%�0�0��3�3�?��x���A��q�!�!rfc�V�t��}|D]}||jxxdz
cc<�|S)z�
        Get Counter object which contains amount applications per version of interpreter
        :param apps: list of applications for something selector
        r3)rr�)ra�apps_per_versionr`s   rg�_get_counter_apps_per_versionz/CloudlinuxSummary._get_counter_apps_per_version�sD��#�9�9���	/�	/�C��S�[�)�)�)�Q�.�)�)�)�)��rfc�x�|�|��}|�d��pdg}|ddS)z�
        Get maximum amount of applications per version of interpreter
        :param apps: list of applications for something selector
        r3rdr)rorf)r�rarnrhs    rg�_get_max_apps_per_versionz+CloudlinuxSummary._get_max_apps_per_version�sC�� �=�=�d�C�C��(�3�3�A�6�6�B�6�(���A��q�!�!rfc�z�t��}|D]}|�|j���t|��S)zz
        Get amount of domains with applications
        :param apps: list of applications for something selector
        )r!r�rer�)rarr`s   rg� _get_amount_of_domains_with_appsz2CloudlinuxSummary._get_amount_of_domains_with_apps�s?���%�%���	&�	&�C��K�K���%�%�%�%��7�|�|�rfc�z�t��}|D]}|�|j���t|��S)zx
        Get amount of users with applications
        :param apps: list of applications for something selector
        )r!r�r�r�)ra�usersr`s   rg�_get_amount_of_users_with_appsz0CloudlinuxSummary._get_amount_of_users_with_apps	s?�������	 �	 �C��I�I�c�h������5�z�z�rfc�J�|�|��}t|��S)z�
        Get amount of applications per each versoin of interpeters
        :param apps: list of applications for something selector
        )ror�)r�rarns   rg�4_get_amount_of_apps_per_each_version_of_interpreterszFCloudlinuxSummary._get_amount_of_apps_per_each_version_of_interpreterss'�� �=�=�d�C�C���$�%�%�%rfc�:���fd�t|��D��S)z�
        Get list of versions of interpreters on server
        :param interpreters_stats: dict with varied statistics about each version of interpeters
        :param state: state of interpeters (installed, enabled)
        c�*��g|]\}}|��
|��Srere)r��interpreter_stats�stat�states   �rgr�zHCloudlinuxSummary._get_list_versions_of_interperters.<locals>.<listcomp>+s,���n�n�n�&=�&7��bf�gl�bm�n�!�n�n�nrfr)�interpreters_statsr}s `rgrPz4CloudlinuxSummary._get_list_versions_of_interperters"s)���o�n�n�n��K]�A^�A^�n�n�n�nrfc�^�t|��}|�t|��St��S)zI
        Get list of apllications on server for defined selector
        )r[rd)r�	iter_appss  rg�_get_list_of_applicationsz+CloudlinuxSummary._get_list_of_applications-s,��-�[�9�9�	�� ��	�?�?�"��6�6�Mrfc
��	��|jD�]�}|j�tt|��dd�|����}|�t|jd|zdz<�]|j�t|j|��dd|zdzd�|����|j�t|j	|t��dd|zd	zd
�|��d���|j�t|j	|t��dd|zd
zd�|��d���|j�t|j|��dd�|�����|j��fd�dd|zdzd�|��d���|jd|zdzdk|jd|zdz<|j�t|j
���dd|zdzd�|��d���|j�tt|��dd�|����}|�||jd|zdz<|j�t|j���dd|zdzd�|����|j�t|j���dd|zdzd�|����|j�t|j���dd|zdzd�|����|j�t|j���dd|zdzd �|����|j�t|j|jd|zdz|jd|zdz��dd!�|����}|�||jd|zd"z<|j�t|j|jd|zdz|jd|zdz��dd#�|����}|�||jd|zd$z<|j�t|j���d%d|zd&zd'�|�������dS)(zc
        Fill dict with statistics by varied statistics about ruby/nodejs/python selectors
        ruz*Can't get statistics about {} interpretersN�	selector_�_statusrtzCan't get status of {} selectorrw�_versions_installedz7Can't get list of versions of installed {} interpretersFr��_versions_enabledz5Can't get list of versions of enabled {} interpretersz!Can't get list of {} applicationsc�"��t���Srcr�)�interpreter_appss�rgrhz>CloudlinuxSummary._fill_selectors_statistics.<locals>.<lambda>cs����,�-�-�rf�_applications_amountz)Can't get total amount of {} applicationsr�_used�_applications_runningz6Can't get amount of runned application for {} selectorz(Can't get default version of {} selector�_default_version�_max_applications_per_domainz8Can't get max applications per domain for {} interpreter�_max_applications_per_userz6Can't get max applications per user for {} interpreter�_num_users_with_appsz=Can't get amount of users with applications for {} interpeter�_num_domains_with_appsz?Can't get amount of domains with applications for {} interpeterzFCan't get average amount of applications per domain for {} interpreter� _average_applications_per_domainzDCan't get average amount of applications per user for {} interpreter�_average_applications_per_userry� _num_applications_by_interpreterzDCan't get amount of applications per each version of {} interpreters)�	SELECTORSr�r�rrXr�rr�rrPrQr�r�rbr_rirlrvrsrXr[rx)r��selectorr~�default_version_of_selector�average_apps_per_domain�average_apps_per_userr�s      @rg�_fill_selectors_statisticsz,CloudlinuxSummary._fill_selectors_statistics:s������n	�n	�H�!%��!G�!G��/��:�:��=�D�D�X�N�N�"�"��
"�)�FS����h� 6�� B�C���O�)�)���4�h�?�?���h�&��2�2�9�9�(�C�C�	
�
�
�
�O�)�)���?�AS�U^�_�_���h�&�)>�>�J�Q�Q�RZ�[�[�#�
*�
�
�
�
�O�)�)���?�AS�U\�]�]���h�&�)<�<�H�O�O�PX�Y�Y�#�
*�
�
�
� $��E�E���6��A�A��4�;�;�H�E�E� � ��

�O�)�)�-�-�-�-���h�&�)?�?�<�C�C�H�M�M�#�
*�
�
�
����h� 6�9O� O�P�ST�T�
�O�K�(�2�W�<�=��O�)�)���7�9I�J�J���h�&�)@�@�I�P�P�QY�Z�Z�#�
*�
�
�
�+/�/�*P�*P��+�X�6�6��;�B�B�8�L�L�+�+�'�
+�6�Oj����h� 6�9K� K�L��O�)�)���5�7G�H�H���h�&�)G�G�K�R�R�S[�\�\�	
�
�
�
�O�)�)���3�5E�F�F���h�&�)E�E�I�P�P�QY�Z�Z�	
�
�
�
�O�)�)���;�=M�N�N���h�&�)?�?�P�W�W�X`�a�a�	
�
�
�
�O�)�)���=�?O�P�P���h�&�)A�A�R�Y�Y�Zb�c�c�	
�
�
�'+�o�&L�&L���5��O�K�(�$:�=S�$S�T��O�K�(�$:�=U�$U�V���
�Y�`�`�ai�j�j�'�'�#�'�2�+����h� 6�9[� [�\�$(�O�$J�$J���3��O�K�(�$:�=S�$S�T��O�K�(�$:�=S�$S�T���
�W�^�^�_g�h�h�%�%�!�%�0�)����h� 6�9Y� Y�Z��O�)�)���Q�Sc�d�d���h�&�)K�K�W�^�^�_g�h�h�	
�
�
�
�Sn	�n	rfc�6�ddg}t|d���\}}}|dkrt|���tj|��}t	��}|d|d<d�|dD��}t
D]#}|�|t��|d	|z<�$|S)
zA
        Get wizard status and list of installed modules
        z/usr/sbin/cloudlinux-wizardrDTr�r�
wizard_statusc�,�i|]}|d|d��S)r�rDre)r�r�s  rgrIz<CloudlinuxSummary._get_wizard_statistics.<locals>.<dictcomp>�s#��`�`�`�v�&��.�&��*:�`�`�`rfr��wizard_module_)rrr�r�r�rRr��NOT_SELECTED)r��ret_code�std_out�std_err�parsed_json�wizard_statistics�parsed_modulesr�s        rg�_get_wizard_statisticsz(CloudlinuxSummary._get_wizard_statistics�s���
*��
��&1���%N�%N�%N�"��'�7��q�=�=�'��0�0�0��j��)�)�� �F�F��-8��-I��/�*�`�`��U^�I_�`�`�`��!�	d�	d�F�;I�;M�;M�f�Vb�;c�;c��.��7�8�8� � rfc	����|j�|jdd���|j��fd�dddd���tD];�|j���fd�dd	�zd
����d����<dS)zX
        Fill dict with statistics by varied statistics about cloudlinux-wizard
        rtz,Can't get statistics about cloudlinux-wizardc����dS)Nr�re)r�s�rgrhz;CloudlinuxSummary._fill_wizard_statistics.<locals>.<lambda>�s
���%�o�6�rfr�z%Can't get status of cloudlinux-wizardFr�c����d�zS)Nr�re)r�r�s��rgrhz;CloudlinuxSummary._fill_wizard_statistics.<locals>.<lambda>�s���)�*:�V�*C�D�rfr�z;Can't get statistics about module "{}" of cloudlinux-wizardN)r�r�r�r�rRr�)r�r�r�s @@rg�_fill_wizard_statisticsz)CloudlinuxSummary._fill_wizard_statistics�s�����!�O�B�B��'��;�
�
��	
��%�%�6�6�6�6���4��	&�	
�	
�	
�"�	�	�F��O�)�)�D�D�D�D�D�� �6�)�N�U�U�V\�]�]�#�
*�
�
�
�
�	�	rfc��t��}g}|D],}|t||�����z
}�-|S)zH
        Returns list of implemented scripts in integration.ini
        )rUrd�keys)r�scripts�sections   rg�$_get_implemented_integration_scriptsz6CloudlinuxSummary._get_implemented_integration_scripts�sL��
#�$�$�����	4�	4�G��t�F�7�O�0�0�2�2�3�3�3�G�G��rfc��dgd�}tj�t��s|Sd|d<|���|d<|S)zh
        Checks integration script exists and if exists
        get list of implemented scripts
        F)�integration_scripts_used�integration_scripts_specifiedTr�r�)r�r�r�rTr�r�s  rg�_get_integration_infoz'CloudlinuxSummary._get_integration_info�sT��
/4�VX�Y�Y���w�~�~�k�*�*�	��M�-1��)�*�26�2[�2[�2]�2]��.�/��
rfc��ddl}d}|���}t|j��|z}t|j��|z}||fS)zG
        Gets memory usage: total and used memory in megabytes
        rNi)�psutil�virtual_memoryrv�total�used)r��bytes_in_mb�mem�	mem_total�mem_useds     rg�_get_memory_usedz"CloudlinuxSummary._get_memory_used�sT��
	�
�
�
����#�#�%�%���#�)�$�$�{�2�	����?�?�[�0���(�"�"rfc�B�tj��}d}d}ttj��rlt
j�|��rMt|��5}|�	���
��}ddd��n#1swxYwY||fS)za
        Gets kernel info release and module version (starting from 7h)
        :return:
        z/sys/module/kmodlve/versionN)�platform�releaserrr�r�r�rr�rr)�kernel_release�kmodlve_version_file�kmodlve_versionrs    rg�_get_kernel_infoz"CloudlinuxSummary._get_kernel_info	s���"�)�+�+��<����%�g�k�2�2�	3�r�w�~�~�FZ�7[�7[�	3��*�+�+�
3�q�"#�&�&�(�(�.�.�"2�"2��
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3���.�.s�'B�B�Bc�8�tt����S)zp
        Gets info about lve extensions usage
        Calculates amount of packages with lve extensions
        )r�rHrerfrg�#_get_lve_extensions_packages_amountz5CloudlinuxSummary._get_lve_extensions_packages_amount	s���3�5�5�6�6�6rfc��d}tj�|��sdSt|��5}|������}ddd��n#1swxYwYt
t|����S)zk
        Reads /proc/sys/fs/datacycle/enable in order to check
        datacycle enabled parameter
        z/proc/sys/fs/datacycle/enableFN)r�r�rr�rrr�ru)�datacycle_filerrIs   rg�$_is_kernel_datacycle_enabled_in_filez6CloudlinuxSummary._is_kernel_datacycle_enabled_in_file	s���9���w�~�~�n�-�-�	��5�
�.�
!�
!�	$�Q��6�6�8�8�>�>�#�#�D�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$��C��I�I���s�'A&�&A*�-A*c��d\}}tj�|��sdSt|��5}|�������d��}ddd��n#1swxYwY||vS)zR
        Checks if datacycle parameter was given
        for current boot
        )z
/proc/cmdline�	datacycleF� N)r�r�rr�rr�split)�cmdline_filerrrIs    rg�_is_datacycle_param_was_passedz0CloudlinuxSummary._is_datacycle_param_was_passed-	s���$@� ��j��w�~�~�l�+�+�	��5�
�,�
�
�	/�1��6�6�8�8�>�>�#�#�)�)�#�.�.�D�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/��T�!�!s�:A<�<B�Bc��tj��}d}|D]&}|ttj|����z
}�'|S)z=
        Returns general amount of domains on server
        r)rr�r�r�)�cpusers_list�
domains_countr�s   rg�_get_total_domains_amountz+CloudlinuxSummary._get_total_domains_amount=	sH��
�}�����
� �	:�	:�D��S��!2�4�!8�!8�9�9�9�M�M��rfc��t��}tt|�d������}tt|�d������}|r|rdS|rdS|rdSdS)zi
        Returns is links traversal protection enabled on server
        (symlinks or hardlinks)
        zfs.protected_symlinks_createzfs.protected_hardlinks_create�all�
symlinks_only�hardlinks_only�no)r)r�rur�)r��symlink_protection_enabled�hardlink_protection_enableds   rg�%_is_link_traversal_protection_enabledz7CloudlinuxSummary._is_link_traversal_protection_enabledH	s�������%)�#�f�j�j�9W�.X�.X�*Y�*Y�%Z�%Z�"�&*�3�v�z�z�:Y�/Z�/Z�+[�+[�&\�&\�#�%�	�*E�	��5�
'�	�"�?�
(�	�#�#��4rfc���d}d}d}tj�d��stj�d��r|Stj�d��r|S|S)N�iso�cldeploy�qcow2z/etc/cl-convert-savedz/var/log/cldeployz/etc/cloudlinux-qcow2-installr)r�r�r�s   rg�_get_cl_installation_sourcez-CloudlinuxSummary._get_cl_installation_sourceZ	sd��������
�7�>�>�1�2�2�	�b�g�n�n�EX�6Y�6Y�	��O�
�W�^�^�;�
<�
<�	��L��Jrfc�����������ttj��rj�j��jdddd����j��jdddd	����j��fd
�dddd���td	�
��s$�j�tdddd	����j�tdddd����j�tdddd����j��jddd���j��j
ddd���j��fd�dddd���������j��fd�dddd����j��fd�dd d!d���������j��fd"�d#d$d%d����j��fd&�d#d'd(d����j��jdd)d*d	���ttj��r"�j��fd+�dd,d-d	����j�t"dd.d/d	����j�t$dd0d1d	����j��jdd2d3d	���dS)4Nru�lve_extension_packages_amountz"Can't get lve extension usage infoFr�rt�!link_traversal_protection_enabledz5Can't get link traversal protection enabled parameterTc����dSrpre��kernel_infos�rgrhz;CloudlinuxSummary._fill_system_statistics.<locals>.<lambda>z	s����A��rf�installed_kmod_lve_versionz)Can't get installed kmod-lve version info��skip_jwt_check�cldiag_cron_check_enabledz&Can't get is cldiag cron check enabled�
cpu_amountzCan't get cpu amount�testing_repository_enabledz#Can't get testing repository status�base_distrozCan't detect platform for CLOS�secureboot_statusz+Can't detect whether secure boot is enabledc����dSr�rer�s�rgrhz;CloudlinuxSummary._fill_system_statistics.<locals>.<lambda>�	s���K��N�rfr�zCan't get kernel release infoc����dS)Nr�re��vendor_integration_infos�rgrhz;CloudlinuxSummary._fill_system_statistics.<locals>.<lambda>�	s���+�,F�G�rfr�z'Can't get integration_scripts_used infoc����dS)Nr�rer�s�rgrhz;CloudlinuxSummary._fill_system_statistics.<locals>.<lambda>�	s���+�,K�L�rfrwr�z-Can't get integrations scripts specified infoc����dSr�re��memory_usages�rgrhz;CloudlinuxSummary._fill_system_statistics.<locals>.<lambda>�	����L��O�rfrv�memory_total_mbzCan't get total memory infoc����dSrprer�s�rgrhz;CloudlinuxSummary._fill_system_statistics.<locals>.<lambda>�	r�rf�memory_used_mbzCan't get used memory info�
domains_totalzCan't get domains amountc�T������p����Src)r�r�r�s�rgrhz;CloudlinuxSummary._fill_system_statistics.<locals>.<lambda>�	s*����A�A�C�C�>��;�;�=�=�rf�kernel_datacycle_usage_enabledz,Can't get kernel datacycle enabled parameter�	virt_typez!Can't get the virtualization type�hostnamezCan't get the hostname�cloudlinux_installation_sourcezCan't get installation source)r�rrr�r�r�r�r�rrVrrr�r�r�r�r�r!rr�)r�r�r�r�s`@@@rg�_fill_system_statisticsz)CloudlinuxSummary._fill_system_statisticsf	s"�������+�+�-�-��%�g�k�2�2�	��O�)�)��8��/�5�#�
*�
�
�
�
�O�)�)��:��3�H�"�
*�
�
�
�
�O�)�)�&�&�&�&��,�<�#�
*�
�
�
�"��6�6�6�	��O�)�)�-��+�9�"�
*�
�
�
�	
��%�%����#��	&�	
�	
�	
�	
��%�%�#��(�2��	&�	
�	
�	
�	
��%�%�����-�		
�	
�	
�	
��%�%��#���:�		
�	
�	
�	
��%�%�"�"�"�"���,��	&�	
�	
�	
�#'�"<�"<�">�">����%�%�G�G�G�G��&�6��	&�	
�	
�	
�	
��%�%�L�L�L�L��+�<��	&�	
�	
�	
��,�,�.�.����%�%�#�#�#�#���*��	&�	
�	
�	
�	
��%�%�#�#�#�#���)��	&�	
�	
�	
�	
��%�%��*���'��	&�	
�	
�	
�&�g�k�2�2�	��O�)�)�>�>�>�>��0�?�"�

*�
�
�
�	
��%�%����0��	&�	
�	
�	
�	
��%�%����%��	&�	
�	
�	
�	
��%�%��,��,�,��	&�	
�	
�	
�	
�	
rfc�����j��fd�ddd���j�tddd���j�tddd	��dS)
Nc� ���jptSrc�r��UNKNOWN_RHN_IDr�s�rgrhzKCloudlinuxSummary._fill_dict_with_rpm_packages_statistics.<locals>.<lambda>�	����D�N�4�n�rfrtr��Can't get system ID�
os_versionzCan't get version of OSr|rcz*Can't get info about client's rpm packages)r�r�r rNr�s`rgr�z9CloudlinuxSummary._fill_dict_with_rpm_packages_statistics�	s������%�%�4�4�4�4���"�		
�	
�	
�	
��%�%����&�		
�	
�	
�	
��%�%�!���:�		
�	
�	
�	
�	
rf�paramc�Z�tj|j�|����S)z�
        Retrieve data from proc/mounts for param
        :return: param_value - Optional[int],
        if there is no value - None
        )r,�
str_to_intr�r�)r�rs  rg�_get_proc_paramz!CloudlinuxSummary._get_proc_param
s#���(������)?�)?�@�@�@rfc	�p�dg}ttj��r|�gd���|D][}|j�t
|j|��d|�dd��d�	|��d����\|j�tdd	d
d���dS)z�
        Filling stats about mounting
        - mount params from parameters list
        - separate hidepid getting, since it is more complicated than
        other mounting params
        zkernel.memcg_oom_disable)
zfs.enforce_symlinksifownerzfs.symlinkown_gidzfs.protected_symlinks_allow_gidz fs.protected_hardlinks_allow_gidzfs.global_root_enablezfs.proc_can_see_other_uidzfs.proc_super_gidzfs.xfs.cap_res_quota_disablezubc.ubc_oom_disablezfs.process_symlinks_by_taskrurr�z
Can't get {0}Tr��hidepidzCan't get hidepid valueN)rrr�rpr�r�rrrr�rW�r��
parameters�ps   rg�_fill_proc_params_statisticsz.CloudlinuxSummary._fill_proc_params_statistics
s���
'�
�
�&�g�k�2�2�	�

������
�
�
��	�	�A��O�)�)���,�a�0�0���	�	�#�s�#�#� �'�'��*�*�"�

*�
�
�
�
�	
��%�%�*���&��	&�	
�	
�	
�	
�	
rfc	��d}|D];}|j�t|j|��dd|��d|�d�d����<dS)	zJ
        Fill dict with statistics about kmodlve parameters usage
        )�lve_setuid_enterru�kmodlve_zCan't get "z" kmodlve parameter valueTr�N)r�r�r�_get_kmodlve_param_valuers   rg�_fill_kmodlve_params_statisticsz1CloudlinuxSummary._fill_kmodlve_params_statisticsA
su��
�
��	�	�A��O�)�)���5�q�9�9���1���;�q�;�;�;�"�
*�
�
�
�
�	�	rfc����td����|j��fd�ddd��|j��fd�ddd	��|j��fd
�ddd��|j��fd
�ddd��|j��fd�ddd��|j�tt���ddd��dS)zv
        Fill statistics fields from jwt token.
        - jwt token metrics (cl_plus existence and client_id)
        F)�check_expirationc�8����dn��dd��S)N�cl_plus�r��rIs�rgrhz=CloudlinuxSummary._fill_cln_jwt_information.<locals>.<lambda>Y
s!���D�L�D�D����)�T�*�*�rfrurzCan't get cl_plus informationc�8����dn��dd��S)N�	client_idrrs�rgrhz=CloudlinuxSummary._fill_cln_jwt_information.<locals>.<lambda>`
s!���D�L�D�D����+�t�,�,�rfrzCan't get client_id valuec�8����dn��dd��S)N�is_awp_premium_allowedrrs�rgrhz=CloudlinuxSummary._fill_cln_jwt_information.<locals>.<lambda>g
s"���D�L�D�D����2�D�9�9�rf�jwt_is_awp_premium_allowedz&Can't get is_awp_premium_allowed valuec�8����dn��dd��S)N�is_awp_cdn_allowedrrs�rgrhz=CloudlinuxSummary._fill_cln_jwt_information.<locals>.<lambda>n
s"���D�L�D�D����.��5�5�rf�jwt_is_awp_cdn_allowedz"Can't get is_awp_cdn_allowed valuec�8����dn��dd��S)N�is_trialrrs�rgrhz=CloudlinuxSummary._fill_cln_jwt_information.<locals>.<lambda>u
s!���D�L�D�D����*�d�+�+�rf�jwt_is_trial_licensez$Can't get jwt_is_trial_license value�license_activezCan't get license status valueN)rKr�r�rrM)r�rIs @rg�_fill_cln_jwt_informationz+CloudlinuxSummary._fill_cln_jwt_informationQ
sm���.�u�E�E�E����%�%�
+�
+�
+�
+���,�	
�	
�	
�	
��%�%�
-�
-�
-�
-���(�	
�	
�	
�	
��%�%�
:�
:�
:�
:��(�5�	
�	
�	
�	
��%�%�
6�
6�
6�
6��$�1�	
�	
�	
�	
��%�%�
,�
,�
,�
,��"�3�	
�	
�	
�	
��%�%��0�$�7�7���-�		
�	
�	
�	
�	
rfc����j��fd�ddd���j�tddd��dS)	za
        Filling stats centralized management
        - centralized management existence
        c�L��tj��j��Src)r�r�r��CL_PLUS_CM_DISABLED_PATHr�s�rgrhzKCloudlinuxSummary._fill_centralized_management_statistics.<locals>.<lambda>�
s���B�G�N�N�4�#@�A�A�rfru�centralized_management_disabledzCan't check CM disabling statusrt�cl_plus_sender_service_statusz)Can't check cl plus sender service statusN)r�r�rLr�s`rg�'_fill_centralized_management_statisticsz9CloudlinuxSummary._fill_centralized_management_statistics�
sf���	
��%�%�A�A�A�A��-�.�	
�	
�	
�	
��%�%�%��+�8�		
�	
�	
�	
�	
rfc�J�t��}	t��}|D]H}|���D]1\}}|�d|��g���|���2�In9#t
tf$r%}t�d|��Yd}~nd}~wwxYw|S)a�
        Prepare list of dicts with CPU metrics

        Method get_cpu_metrics returns data in following format:
        [
            {
              "id": 0,
              "model": "QEMU Virtual CPU version 2.5+"
            },
            {
              "id": 0,
              "model": "QEMU Virtual CPU version 2.5+"
            }
        ]

        This helper produces a dict, where each key - metric_name,
        value - list of values for all CPUs

        "cpu_model": [
            "QEMU Virtual CPU version 2.5+",
            "QEMU Virtual CPU version 2.5+"
        ],
        "cpu_id": [
            0,
            0
        ]
        �cpu_zCPU metrics getting error: %sN)	r�rOr��
setdefaultr�r�rQr�r�)r��	cpu_cores�cpu_core�metric�value�exs      rg�make_flat_cpu_metricsz'CloudlinuxSummary.make_flat_cpu_metrics�
s���:����	B�'�)�)�I�%�
I�
I��%-�^�^�%5�%5�I�I�M�F�E��%�%�o�V�o�o�r�:�:�A�A�%�H�H�H�H�I�
I����&�	B�	B�	B����<�b�A�A�A�A�A�A�A�A�����	B�����
s�AA*�*B �;B�B c	��gd�}|���}|D]A}|dkrdnd}|j�t|j|d��||d|�d����B|j�t
dd	d
��dS)z�
        Filling stats about hardware metrics, specifically:
        CPU:
            - cache
            - frequency
            - model
            - id
        RAM:
            - ram
            - swap
        )�cpu_id�cpu_cache_mb�	cpu_model�cpu_frequency_mhzr<rxrwNzCan't parse z metric for all coresry�memoryzCan't parse memory metrics)r8r�r�rr�rP)r��exp_metrics�cpu_metricsr5�metric_types     rg�_fill_hardware_statisticsz+CloudlinuxSummary._fill_hardware_statistics�
s���9�9�9���0�0�2�2��!�	�	�F�(.�+�(=�(=�*�*�:�K��O�)�)������6�6���=��=�=�=�	
�
�
�
�	
��%�%����)�		
�	
�	
�	
�	
rfc��|���\|jd<|jd<|jd<tj�d��|jd<dS)am
        Collect CageFS enter errors number:
        1. "Act like CageFS is disabled (unable to create LVE).. %d"
        2. "Act like CageFS is disabled (unable to enter into NameSpace).. %d"
        3. "Act like CageFS is disabled (unable to acquire lock for user %s uid %d)"
        4. File-marker /etc/cagefs/fail.on.error presense
        :return None
        �(act_cagefs_disabled_unable_to_create_lve�&act_cagefs_disabled_unable_to_enter_ns�)act_cagefs_disabled_unable_to_acqure_lockz/etc/cagefs/fail.on.error�"act_cagefs_disabled_marker_presentN)�*_scan_log_for_act_cagefs_disabled_messagesr�r�r�rr�s rg�$_fill_act_cagefs_disabled_statisticsz6CloudlinuxSummary._fill_act_cagefs_disabled_statistics�
s]��HL�Gv�Gv�Gx�Gx�	E���B�C���@�A���C�D�@B����Oj�@k�@k���<�=�=�=rfc���	|���\}}|dkr�|�d��}ttddd|�����}t	|��}ttddd|�����}t	|��}ttddd|�����}t	|��}nd}d}d}|||fS#t
tf$rYdSwxYw)	a�
        Scan /var/log/messages for all needed "Act like CageFS is disabled ..." messages for yesterday
        :return tuple of ints:
            Number of "Act like CageFS is disabled (unable to create LVE).. " messages,
            Number of "Act like CageFS is disabled (unable to enter into NameSpace).. " messages,
            Number of "Act like CageFS is disabled (unable to acquire lock for user %s uid %d)" messages
        r�
z2Act like CageFS is disabled (unable to create LVE)T)�fixed_string�multiple_search�data_from_filez<Act like CageFS is disabled (unable to enter into NameSpace)z<Act like CageFS is disabled (unable to acquire lock for user)rsrsrs)�_get_data_from_logr�rdr"r�r�r�)r��
returncoder��
lines_list�found_lines_list�num_unable_to_create_lve�num_unable_to_enter_ns�num_unable_to_acqure_locks        rgrHz<CloudlinuxSummary._scan_log_for_act_cagefs_disabled_messages�
sG��	!�!%�!8�!8�!:�!:��J���Q���#�\�\�$�/�/�
�#'��-a�:>�PT�eo�)q�)q�)q�$r�$r� �+.�/?�+@�+@�(�#'��-k�:>�PT�eo�)q�)q�)q�$r�$r� �),�-=�)>�)>�&�#'��-k�:>�PT�eo�)q�)q�)q�$r�$r� �,/�0@�,A�,A�)�)�,-�(�)*�&�,-�)�+�-C�E^�^�^����!�	!�	!�	!� �=�=�	!���s�C
C
�
C"�!C"c�B�t��}|dvrd}nOtj���tjd���z
}|�d��}d|�d�}t
j|ddd	tjtj	�
��}|j
|jfS)z�
        Scan /var/log/messages for all needed "Act like CageFS is disabled ..." messages for yesterday
        :return: Tuple (ret code, std_out string)
        )�cl7�cl7h�cl8za/usr/bin/journalctl --since yesterday --until today | /usr/bin/grep 'Act like CageFS is disabled'r3)�daysz%Y-%m-%dz/usr/share/cloudlinux/logs-at z< /var/log/messages | /bin/grep 'Act like CageFS is disabled'TrR)r�rSrTr��stderr)r �datetime�date�today�	timedelta�strftimer]r^�PIPE�DEVNULLrPr�)�os_type�s_cmd�yesterday_date�date_to_scanrs     rgrOz$CloudlinuxSummary._get_data_from_logs���!�"�"���,�,�,�w�E�E�&�]�0�0�2�2�X�5G�Q�5O�5O�5O�O�N�)�2�2�:�>�>�L��\����E��N�5�t�4�K�",�/�*�:L�
N�
N�
N���|�Q�X�%�%rfc���ttj��r"�j��jddd��t�jd<�j�ttj	d���ddd	���j��j
dd
d���j��jddd
���j��jddd���j��fd�ddd���j��fd�ddd��t�0t�)d�tt���jd<n
d�jd<����dS)Nru�old_way_of_integration_used�*Can't detect old LVE integration mechanism�lve_utils_versionF)�
verify_exprt�
cl_editionzCan't get CloudLinux edition�is_solo_meta_file_presentz$Can't detect solo meta file presence�is_admin_meta_file_presentz%Can't detect admin meta file presence�is_container_meta_file_presentz)Can't detect container meta file presencec����jSrc�r�r�s�rgrhzACloudlinuxSummary._prepare_cl_normal_statistics.<locals>.<lambda>H�
���D�'�rfr��$Can't get or generate security tokenc� ���jptSrcrr�s�rgrhzACloudlinuxSummary._prepare_cl_normal_statistics.<locals>.<lambda>Nrrfr�r�{}-{}�lvemanager_version)rrr�r�r�r�LVE_UTILS_PKG_VERSIONrr�get_cl_edition�_is_solo_marker_exists�_is_admin_marker_exists�_is_container_marker_exists�LVEMANAGER_PKG_VERSION�LVEMANAGER_PKG_RELEASEr��_fill_dict_with_statisticsr�s`rgr�z/CloudlinuxSummary._prepare_cl_normal_statistics%s����%�g�k�2�2�	��O�)�)��0��-�=�	
�
�
�0E���+�,���%�%��J�-�%�@�@�@���+�		
�	
�	
�	
��%�%��'��'�3�		
�	
�	
�	
��%�%��(��(�4�		
�	
�	
�	
��%�%��,��,�8�		
�	
�	
�	
��%�%�'�'�'�'���3�	
�	
�	
�	
��%�%�4�4�4�4���"�		
�	
�	
�"�-�&�2�4;�N�N�&�&�5�5�D�O�0�1�1�
59�D�O�0�1��'�'�)�)�)�)�)rfc����	�
���d�	d�d�
d�d�d}tj��	��sdSGd�d	t������	�
��fd
�}�
d�d�di}d�tj�	��D��}|���|D]/}	|||���#�$rY�t$r
|D]}d
||<�Y�,wxYw|�|j�<|�|j�<|�
|j�
<tj�d��rd|j|<dStj�d��rd|j|<dSd|j|<dS)z�
        Filling stats lvemanager
        - number of visits on X-Ray tab
        - number of X-Ray installation
        - number of LVEManager opens
        z/var/log/cloudlinux/i�Q�lve_number_of_opens�xray_number_of_installation�xray_number_of_visits�xray_advanced_metrics_statusNc��eZdZdS)�ECloudlinuxSummary._fill_lvemanager_statistics.<locals>.BreakOuterLoopN)r�r�r�rerfrg�BreakOuterLoopr�ns�������Drfr�c����tj������}t�|zd��}d}|D�]}	d�|�d��dd���}tj�|d�����}|�
z
|cxkr|kr�nn�d�|����d��dd���}|dkr|�xxdz
cc<n0|dkr|�
xxdz
cc<n|d	kr|�xxdz
cc<nd
}��#ttf$rY��wxYw|r�	�dS)N�rFr�r0z%Y-%m-%d %H:%M:%S,%fzlvemanager-openedr3zxray-install-startedzxray-tab-clickedT)
r\�nowrAr�r�r��strptimerr��AttributeError)�stats�file�current_date_timestampr�break_outer_loop�line�log_time�log_date_timestampr�r��COLLECTING_PERIOD�
LOG_FOLDER�LVE_NUMBER_OF_OPENS�XRAY_NUMBER_OF_INSTALLS�XRAY_NUMBER_OF_VISITSs         ������rg�fill_statisticszFCloudlinuxSummary._fill_lvemanager_statistics.<locals>.fill_statisticsrs����%-�%6�%:�%:�%<�%<�%F�%F�%H�%H�"��Z�$�&��,�,�A�$���
�
���"�x�x��
�
�3������(;�<�<�H�)1�):�)C�)C�H�Nd�)e�)e�)o�)o�)q�)q�&�-�0A�A�DV�o�o�o�o�Yo�o�o�o�o�o�"%�(�(�4�:�:�<�<�+=�+=�c�+B�+B�1�2�2�+F�"G�"G��"�&9�9�9�!�"5�6�6�6�!�;�6�6�6�6�$�(>�>�>�!�"9�:�:�:�a�?�:�:�:�:�$�(:�:�:�!�"7�8�8�8�A�=�8�8�8��+/�(���"�N�3�����H������
%�$�$�
%�
%s�
C>E
�
E"�!E"rc�<�g|]}tjd|���|��S)z^lvemanager\.log(\.\d{1,2})?$)�re�match)r�r�s  rgr�zACloudlinuxSummary._fill_lvemanager_statistics.<locals>.<listcomp>�s;��
�
�
���x�8�$�?�?�
��
�
�
rfr�z./opt/alt/php-xray/php/advanced_metrics.enabledrnz//opt/alt/php-xray/php/advanced_metrics.disabledro�none)	r�r��isdirr�listdir�sortr�r�r)
r��XRAY_ADVANCED_METRICS_STATUSr�r��	log_files�log_filer|r�r�r�r�r�r�s
       @@@@@@rg�_fill_lvemanager_statisticsz-CloudlinuxSummary._fill_lvemanager_statistics]s��������,�
�%��3��"?�� 7��'E�$��w�}�}�Z�(�(�	��F�	�	�	�	�	�Y�	�	�	�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�0
 ��!�1�#�Q�
�
�
�
��Z�
�3�3�
�
�
�	�	������!�	*�	*�H�
*���
�H�5�5�5�5��!�
�
�
����
*�
*�
*�&�*�*�D�')�J�t�$�$�*�*�
*����2<�<Q�1R���-�.�3=�>U�3V���/�0�/9�:M�/N���+�,�
�7�>�>�J�K�K�	C�<E�D�O�8�9�9�9�
�W�^�^�M�
N�
N�	C�<F�D�O�8�9�9�9�<B�D�O�8�9�9�9s�B�B:�$B:�9B:c��d}d}|j�|jdd��}|d|j|<|d|j|<dS)z9
        Fill dict with Leapp upgrade statistics
        �leapp_upgrade_status�centos7_cl7_cl8_transformationryzCan't get Leapp statistics�leapp_status�discount_eligibleN)r�r��get_leapp_stats)r��LEAPP_STATUS�DISCOUNT_ELIGIBILITY�elevate_statuss    rg�_fill_leapp_statisticsz(CloudlinuxSummary._fill_leapp_statistics�sa��.�� @����?�?�� ��)�
�
��)7�~�(F����%�0>�?R�0S���,�-�-�-rfc�r�t��}d�|D��|jd<d�|D��|jd<dS)z:
        Fill dict with feature flags information
        c��g|]	}|j��
Srerq�r�rs  rgr�zDCloudlinuxSummary._fill_feature_flags_statistics.<locals>.<listcomp>�s'��5
�5
�5
��A�F�5
�5
�5
rf�server_flags_availablec�*�g|]}|j�	|j��Sre)rnr�r�s  rgr�zDCloudlinuxSummary._fill_feature_flags_statistics.<locals>.<listcomp>�s2��3
�3
�3
���y�3
�
�F�3
�3
�3
rf�server_flags_enabledN)rar�)r��all_flags_infos  rg�_fill_feature_flags_statisticsz0CloudlinuxSummary._fill_feature_flags_statistics�sa��
)�*�*��5
�5
�*�5
�5
�5
���0�1�3
�3
�*�3
�3
�3
���.�/�/�/rfc��d}d}d}d}d}d}d}d}tj�|��r|}tj�|��r|}tj�|��r|}||j|<dS)	z8
        Fill out AccelerateWP promotion status
        �accelerate_wp_promotion_status�enabled_for_current_server�enabled_for_all_servers�skippedz,/var/lve/clflags/enable_awp_all_servers.flagz,/var/lve/clflags/enable_awp_this_server.flagz$/var/lve/clflags/skip_awp_setup.flagN)r�r�r�r�)	r��FIELD�ENABLED_FOR_CURRENT_SERVER�ENABLED_FOR_ALL_SERVERS�SKIPPED�enable_awp_all_servers_flag�enable_awp_this_server_flag�skip_awp_setuprDs	         rg�(_fill_accelerate_wp_promotion_statisticsz:CloudlinuxSummary._fill_accelerate_wp_promotion_statistics�s���1��&B�"�";����'U�#�&T�#�?����
�7�>�>�5�6�6�	-�,�F�
�7�>�>�5�6�6�	0�/�F�
�7�>�>�.�)�)�	��F�!'������rfc����j��fd�ddd���j��fd�ddd��t�jd<t�0t�)d	�tt���jd
<n
d�jd
<�j��jddd
������dS)Nc����jSrcrqr�s�rgrhz7CloudlinuxSummary._prepare_statistics.<locals>.<lambda>�rrrfrtr�rsc� ���jptSrcrr�s�rgrhz7CloudlinuxSummary._prepare_statistics.<locals>.<lambda>�rrfr�rrjrurvrurhri)r�r�rwr|r}r�rr~r�s`rg�_prepare_statisticsz%CloudlinuxSummary._prepare_statistics�s������%�%�'�'�'�'���3�	
�	
�	
�	
��%�%�4�4�4�4���"�		
�	
�	
�0E���+�,�!�-�2H�2T�4;�N�N�&�&�5�5�D�O�0�1�1�
59�D�O�0�1���%�%��,��)�9�		
�	
�	
�	
�'�'�)�)�)�)�)rfc�*�ttj��r|���ttj��r(|���|���ttj��r|���ttj	��r(|�
��|���ttj��r|�
��ttj��s2ttj��sttj��r|���t%d���s|���ttj��r|���ttj��r|���|���|���|���|���|���|���|���|���|� ��|�!��|�"��|�#��|�$��|�%��|�&��dS)NTr�)'rr�GOVERNORr��CAGEFSrrI�RESELLER_LIMITSr?r�r�r�PHP_SELECTORrT�
RUBY_SELECTOR�PYTHON_SELECTOR�NODEJS_SELECTORr�rr/�LSAPIr��WIZARDr��_fill_wpos_statisticsr)r�rrrBr�r9r�r�r�r�r�r��_fill_apache2nginx_statisticsr�s rgr~z,CloudlinuxSummary._fill_dict_with_statistics	s���%�g�&6�7�7�	3��0�0�2�2�2�%�g�n�5�5�	8��(�(�*�*�*��5�5�7�7�7�%�g�&=�>�>�	.��+�+�-�-�-�%�g�k�2�2�	3��(�(�*�*�*��0�0�2�2�2�%�g�&:�;�;�	1��.�.�0�0�0�%�g�&;�<�<�	.�-�g�.E�F�F�	.�-�g�.E�F�F�	.�
�+�+�-�-�-�!��6�6�6�	;��8�8�:�:�:�%�g�m�4�4�	*��'�'�)�)�)�%�g�n�5�5�	+��(�(�*�*�*��"�"�$�$�$��&�&�(�(�(��+�+�-�-�-��$�$�&�&�&��)�)�+�+�+��&�&�(�(�(��*�*�,�,�,��!�!�#�#�#��(�(�*�*�*�� � �"�"�"��)�)�+�+�+��#�#�%�%�%��+�+�-�-�-��5�5�7�7�7��*�*�,�,�,�,�,rfc�J�|j�|jddd��dS)Nry�apache2nginxz Can't parse Apache2Nginx metrics)r�r��get_apache2nginx_statsr�s rgr�z/CloudlinuxSummary._fill_apache2nginx_statistics3s5����%�%��'���/�		
�	
�	
�	
�	
rfc������|j�|jdd���|j�tdd���|j��fd�ddd��|j�d	�dd
d��t�t���rى�d��d
k�r���d��� |j��fd�ddd����d��� |j��fd�ddd��|j��fd�ddd��|j��fd�ddd����d��r |j��fd�ddd���dD]-��dkr�	|j���fd�dd �zd���.��d!g��D]&�|j���fd"�dd#�zd���'�d$D]-��dkr�	|j���fd%�dd&�zd���.��d'g��D]&�|j���fd(�dd)�zd���'��d*g��D]&�|j���fd+�dd,�zd���'��dg��D]-��dkr�	|j���fd-�dd.�zd���.��d/i�����D]\�}||jd0�z<�|j��fd1�dd2d��|j��fd3�dd4d��|j��fd5�dd6d7��|j��fd8�dd9d:��|j��fd;�dd<d=��|j��fd>�dd?d@��|j��fdA�ddBdC��|j��fdD�ddEdF����dG��x}r+|���D]\}}||jdH|��<�dSdSdSdS)INrtz!Can't get AccelerateWP statisticsryz,Can't get AccelerateWP activation statisticsc�.����d��S)N�accelerate_wp_free_activater)�client_activations�rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>Js���%�)�)�*G�H�H�rfru�&cmt_accelerate_wp_free_activated_in_uiz;Can't get statistic of AccelerateWP CMT activation selectedc�J�tj�t��Src)r�r�rr'rerfrgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>Rs��B�G�N�N�#B�C�C�rf�.cmt_is_accelerate_wp_free_activation_completedz2Can't get statistic of AccelerateWP CMT activationr�r?�features_visible_by_defaultc����dS)Nr�re��
wpos_statss�rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>[�
���J�'D�E�rfrw� wpos_features_visible_by_defaultz*Can't get statistic of using AccelerateWP.�features_allowed_by_defaultc����dS)Nr�rer�s�rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>br�rf� wpos_features_allowed_by_defaultc� ���ddS)N�
enabled_sitesr�rer�s�rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>h����
�?�3�G�<�rf�sites_count_with_enabled_wposc� ���ddS)N�
allowed_usersr�rer�s�rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>nr�rf�users_count_with_allowed_wpos�
visible_usersc� ���ddS)Nr�r�rer�s�rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>us���J��7��@�rf�users_count_with_visible_wposr�r�c� ���d�S)Nr�re�r�r�s��rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>~����J��7��?�rf�sites_count_with_enabled_�
enabled_usersc� ���d�S)Nr�rer�s��rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�r�rf�users_count_with_enabled_r�c� ���d�S)Nr�rer�s��rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�r�rf�users_count_with_allowed_�allowed_suitesc� ���d�S)Nr�re��suiter�s��rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�����J�'7�8��?�rf�users_count_with_allowed_suite_�enabled_suitesc� ���d�S)Nr�rer�s��rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�r�rf�users_count_with_enabled_suite_c� ���d�S)Nr�rer�s��rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�r�rf�users_count_with_visible_�upgrade_urls�upgrade_url_c����dS)N�4accelerate_wp_suite_enabled_premium_suite_disallowedrer�s�rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�s
���
�#Y�Z�rfrc����dS)N�1accelerate_wp_suite_enabled_premium_suite_visiblerer�s�rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�s
���
�#V�W�rfr	c�.����d��S)N�is_accelerate_wp_flag_enabledrr�s�rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�����
���'F�G�G�rfrz1Can't get statistic of AccelerateWP feature flag.c�.����d��S)N�is_accelerate_wp_icon_enabledrr�s�rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�rrfrz0Can't get statistic of AccelerateWP icon status.c�.����d��S)N�%is_smart_advice_notifications_enabledrr�s�rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�s���
���'N�O�O�rfrzJCan't get statistic of AccelerateWP is_smart_advice_notifications_enabled.c�.����d��S)N�!is_smart_advice_reminders_enabledrr�s�rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�s���
���'J�K�K�rfrzFCan't get statistic of AccelerateWP is_smart_advice_reminders_enabled.c�.����d��S)N�+is_smart_advice_plugin_installation_enabledrr�s�rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�s���
���'T�U�U�rfrzPCan't get statistic of AccelerateWP is_smart_advice_plugin_installation_enabled.c�.����d��S)N�is_object_cache_banners_enabledrr�s�rgrhz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�s���
���'H�I�I�rfrzDCan't get statistic of AccelerateWP is_object_cache_banners_enabled.r��
awp_whmcs_)	r�r��get_wpos_statsr(r�r�r�r�r�)	r��upgrade_url�whmcs_stats�keyr6r�r�r�r�s	     @@@@rgr�z'CloudlinuxSummary._fill_wpos_statistics;s��������_�;�;����0�
�
�
�!�O�B�B�"��;�
�
��	
��%�%�H�H�H�H��4�I�		
�	
�	
�	
��%�%�C�C��<�@�		
�	
�	
��j�$�'�'�L	@�J�N�N�8�,D�,D�	�,Q�,Q��~�~�;�<�<�H���-�-�E�E�E�E��6�@�	����~�~�;�<�<�H���-�-�E�E�E�E��6�@�	���
�O�)�)�<�<�<�<��/�<�	
�
�
�
�O�)�)�<�<�<�<��/�<�	
�
�
��~�~�o�.�.�
���-�-�@�@�@�@��3�@�	���%�_�5�
�
���W�$�$����-�-�?�?�?�?�?��/�&�8�@�	����%�.�.��"�=�=�
�
����-�-�?�?�?�?�?��/�&�8�@�	����%�_�5�
�
���W�$�$����-�-�?�?�?�?�?��/�&�8�@�	����$���(8�"�=�=�
�
����-�-�?�?�?�?�?��5��=�@�	����$���(8�"�=�=�
�
����-�-�?�?�?�?�?��5��=�@�	����%�.�.��"�=�=�
�
���W�$�$����-�-�?�?�?�?�?��/�&�8�@�	����(2�~�~�n�b�'I�'I�'O�'O�'Q�'Q�
G�
G�#���;F����� 7�8�8��O�)�)�Z�Z�Z�Z��F�<�	
�
�
�
�O�)�)�W�W�W�W��C�<�	
�
�
�
�O�)�)�G�G�G�G��/�C�	
�
�
�
�O�)�)�G�G�G�G��/�B�	
�
�
�
�O�)�)�O�O�O�O��7�\�	
�
�
�
�O�)�)�K�K�K�K��3�X�	
�
�
�
�O�)�)�U�U�U�U��=�b�	
�
�
�
�O�)�)�I�I�I�I��1�V�	
�
�
�)�n�n�W�5�5�5�{�
@�"-�"3�"3�"5�"5�@�@�J�C��:?�D�O�$6��$6�$6�7�7�YL	@�L	@�,Q�,Q�T
@�
@�@�@rfc���dg|z}	t|d���\}}}n3#t$r&}t�d|��Yd}~dSd}~wwxYw|dkr|St�d||��dS)z�
        Run cloudlinux-statistics using subprocess and handle errors.
        :type args: list[str]
        :rtype: str or None
        z/usr/sbin/cloudlinux-statisticsTr�z.Unable to run cloudlinux-statistics, error: %sNrz;cloudlinux-statistics failed with exit code: %i, output: %s)rrr�r�r�)rtr�r�r�r�r�s      rg�_run_cloudlinux_statisticsz,CloudlinuxSummary._run_cloudlinux_statistics�s���1�1�D�8��	�)�#�$�G�G�G�O�B��!�!��$�	�	�	����O�QR�S�S�S��4�4�4�4�4�����	������7�7��O����6�79�8�	E�	E�	E��ts��
A�A	�	Ac�Z�|�gd���}|�dS	tj|��}|d}|d}nM#ttt
f$r3}t�dt|����Yd}~dSd}~wwxYwt|��t|��fS)zp
        Get number of users and resellers with faults for the past 24h
        :rtype: tuple[int, int]
        )z
--by-faultr�r�z--period=1dN)NNr,ruzISomething really bad happened to cloudlinux-statistics, The reason is: %s)
rr�r�r�r�r�r�r�rtr�)r�r��	json_datar,rur�s      rg�#get_users_and_resellers_with_faultsz5CloudlinuxSummary.get_users_and_resellers_with_faults�s���
�2�2�3a�3a�3a�b�b�����:�	��
�8�,�,�I�!�+�.�I��g�&�E�E���*�i�0�	�	�	����$�%(��V�V�
-�
-�
-��:�:�:�:�:�����		����
�5�z�z�3�y�>�>�)�)s�$A�B�(B�Bc�6�|���dS)z�
        a wrapper method for the get_users_and_resellers_with_faults method.
        return the number of users with faults in the past 24 hours.
        r�r r�s rgrlz(CloudlinuxSummary._get_users_with_faults
���
�7�7�9�9�!�<�<rfc�6�|���dS)z�
        a wrapper method for the get_users_and_resellers_with_faults method.
        return the number of resellers with faults in the past 24 hours.
        r3r"r�s rgr6z,CloudlinuxSummary._get_resellers_with_faults
r#rfc���|�dS|���}|�d��rdS|�d��rdS|�d��rdS|���rdSd|zS)zGet config cpu limit formatN�%�speed�mhz�ghz�old_cpu_formatzunknown: %s)�lower�endswith�isdigit)�clsrZ�units   rgr[z&CloudlinuxSummary._get_cpu_limit_units
s����;��4��y�y�{�{���=�=����		'��7�
�]�]�5�
!�
!�	'��5�
�]�]�5�
!�
!�	'��5�
�\�\�^�^�	'�#�#� �3�&�&rfc��|�dSd|zdzS)z/Convert memory limit from mempages to megabytesNr�ire)r6s rgr\z!CloudlinuxSummary._mempages_to_mb/
s���=��4��5�y�D� � rfc�h�|�dStj||pd���}|�dSt|dzd��S)z,Convert cpu and ncpu to percents of one coreNr)�lncpugY@r3)rm�convert_to_kernel_format�round)rZrEr's   rgrYz(CloudlinuxSummary._cpu_limit_to_percents6
sL���;��4��2��t�y�q�"�"�"���=��4��U�U�]�A�&�&�&rfc��|j��ttd�|j���D����td�����}g}t
|td�����D]8\}}tt|����}|�||f���9|�	d���||_|jS)zC
        Return list of tuples [users_in_package, package]
        Nc3�2K�|]}|jj�|V��dSrc)�packager�)r�r�s  rgr�z>CloudlinuxSummary.get_users_amount_per_plan.<locals>.<genexpr>I
s9������!��|�(�4��4�4�4�4��rfr7)rT)�reverse)
r��sortedrdrur�r
r
r�r�r�)r�rG�users_sorted_by_packager�r7�group�	num_userss       rg�get_users_amount_per_planz+CloudlinuxSummary.get_users_amount_per_planA
s�����'�&,����%5�%;�%B�%B�%D�%D�������y�)�)�'�'�'�#�!�O�")�+��I�1F�1F�#H�#H�#H�
=�
=������U���,�,�	��&�&�	�7�';�<�<�<�<�� � �� �.�.�.�#2�D� ��#�#rfc�b�	|�|��|dz
S#t$rYdSwxYwrp)r=�
IndexError)r��
number_of_toprGs   rgr�z5CloudlinuxSummary._get_top_package_by_number_of_usersZ
sI��	��1�1�2B�C�C�M�TU�DU�V�V���	�	�	��4�4�	���s� �
.�.c�r�t|��\}}|s"|�t|����|S)z%
        Parse CLI arguments
        )r4r�r.)r�r�rDrIs    rgr�zCloudlinuxSummary._parse_argsb
s>��5�T�:�:�����	7�� � ���!5�!5�6�6�6��rfr?rc��|tj��|d�}|�||d<t|d��tj|��dS)z?
        Print data in default format for web and exit
        )r�rArIN�statistic_enabledT)r8r-�sysrV)r�rI�	exit_coder=r�s     rgrWz(CloudlinuxSummary._print_result_and_exitl
sX��������
�
��
 �+�+?�G�'�(���$�'�'�'��������rfr3c��|�dtj��i��t|d��tj|��dS)z�
        Print error and exit
        :param dict message: Dictionary with keys "result" as string and optional "context" as dict
        rATN)r�r8r-rDrV)r�rKs  rgr�z!CloudlinuxSummary._error_and_exit|
sG��	����T�Y�[�[�1�2�2�2���$�'�'�'��������rfc���tj�d��rGtjddgdtjtj���}t
j|j��SdS)zD
        Return mod_lsapi info from switch_mod_lsapi script
        rz--statT�r�r�r[N)	r�r�r�r]r^rar�r�r��rs rgr�z$CloudlinuxSummary.get_raw_lsapi_info�
sd���7�>�>�5�6�6�	(��� ;�X�F�$(�&0�o�&0�o�7�7�7�A��:�a�h�'�'�'�	(�	(rfc�b�d}t��r|dz
}tj�|��rzt	j|dgdtjtj���}tj|j	���
d��}d�|���D��}|SdS)	zd
        Return wmt-api config
        if is_solo_edition True, run wpt-api-solo is command
        z-/usr/share/web-monitoring-tool/wmtbin/wmt-apiz-soloz--config-getTrHrc�4�i|]\}}|t|����Sre)rt)r��krHs   rgrIz9CloudlinuxSummary._get_wmt_api_config.<locals>.<dictcomp>�
s$��%[�%[�%[�D�A�q�a��Q���%[�%[�%[rfN)rr�r�r�r]r^rar�r�r�r�r�)r�r�wmt_api_config_summarys   rgr�z%CloudlinuxSummary._get_wmt_api_config�
s���B�����	��w��G�
�7�>�>�'�"�"�	*�����8�t�J�O�dn�ds�t�t�t�A�%)�Z���%9�%9�%=�%=�h�%G�%G�"�%[�%[�<R�<X�<X�<Z�<Z�%[�%[�%[�"�)�)�
	*�	*rfc�@�tj�d��S)Nz/etc/cloudlinux-edition-solo�r�r�r�rerfrgryz(CloudlinuxSummary._is_solo_marker_exists�
s���w�~�~�<�=�=�=rfc�@�tj�d��S)Nz/etc/cloudlinux-edition-adminrOrerfrgrzz)CloudlinuxSummary._is_admin_marker_exists�
s���w�~�~�=�>�>�>rfc�@�tj�d��S)Nz/etc/cloudlinux-containerrOrerfrgr{z-CloudlinuxSummary._is_container_marker_exists�
s���w�~�~�9�:�:�:rfc��tj�d��r2tjddgdd���}tj|j��SdS)zL
        Return statistics from cloudlinux-ssa-manager get-stat API
        z /usr/sbin/cloudlinux-ssa-manager�get-statT�r�r�N�r�r�r�r]r^r�r�r�rIs rgr8zCloudlinuxSummary.get_ssa_stats�
s]���7�>�>�<�=�=�	(��� B�J�O�$(�.2�4�4�4�A��:�a�h�'�'�'�		(�	(rfc���d}d}d}d}tj�|��rhtj�|��rItj�|��}tj�|��}||z
dkrd}d}t	j��tjkrmtj�|��rMd}d}tt||d	�
��d��}	tt||d	�
��d��}
|
r|	sd}nKd}nHtj�|��r)d
}tt||d	�
��d��}|rd}nd}|dkrd}||d�}
|
S)z;
        Return statistics from Leapp upgrade logs
        rz /var/log/leapp/leapp-upgrade.logz/var/log/elevate-cpanel.logz/var/log/cldeploy.logi�'r3zHAn upgrade inhibitor detected\|Workflow interrupted due to the FailPhasez'Starting stage After of phase FirstBootT)rLNr0z
Great SUCCESS)r�r�)
r�r�r��getmtimerr�rr��nextr")r��
leapp_logfile�elevate_cpanel_logfile�cldeploy_logfile�leapp_mtime�cldeploy_mtime�upgrade_status�
fail_grep_str�first_boot_grep_str�
fail_grep_res�first_boot_grep_res�success_grep_str�grep_res�stat_results              rgr�z!CloudlinuxSummary.get_leapp_stats�
s�����:�
�!>��2���7�>�>�-�(�(�	&�R�W�^�^�<L�-M�-M�	&��'�*�*�=�9�9�K��W�-�-�.>�?�?�N��^�+�.?�?�?�$%�!��������!2�2�2��w�~�~�m�,�,�
'� k�
�&P�#� $�T�-��UY�%Z�%Z�%Z�\`� a� a�
�&*�4�0C�]�ae�+f�+f�+f�hl�&m�&m�#�&�'�}�'�%&�N�N�%&�N���w�~�~�4�5�5�
'�#3� ���%5�7M�\`� a� a� a�cg�h�h���'�%&�N�N�%&�N��Q��� !��*�!2�
�
���rfrc���d}t||��}|���sdS|������}|dkrdS|dkrdSt	d|�d|�d	����)
z�
        Get kmodlve parameter value:
        -1 - not supported (parameter file doesn't exist);
        0 - disabled;
        1 - enabled
        z/sys/module/kmodlve/parametersr��Yr3�NrzUnable to interpret "z" kmodlve parameter value: "�")rr�	read_textrr)r�
params_dir�
param_file�param_values    rgrz*CloudlinuxSummary._get_kmodlve_param_value�
s���6�
��*�j�1�1�
�� � �"�"�	��2� �*�*�,�,�2�2�4�4���#����1�
�C�
�
��1��<�
�<�<�-8�<�<�<�=�=�	=rfc���d}tj�|��rEtj|dgdd���}tj|j���d��SdS)�E
        Return statistics from cl-smart-advice counters API
        z/usr/sbin/cl-smart-advice�countersTrTrIN)	r�r�r�r]r^r�r�r�r���utilrs  rg�get_smart_advice_statsz(CloudlinuxSummary.get_smart_advice_statsso��+��
�7�>�>�$���	4����z�"��#�%�%�%�A��:�a�h�'�'�+�+�F�3�3�3�	4�	4rfc�N�tdd���}td���s�|j�|jdd��}|�`	t|d|d���S#t
$r5}t�d	t|��|��|cYd}~Sd}~wwxYw|S)
z=
        Construct dict with Smart Advice statistics
        N)�smart_advice_total�smart_advice_appliedT)�skip_marker_checkr{z!Can't get Smart Advice statisticsr��appliedzAUnexpected json response from server, field %s is missing in "%s")	r�rr�r�rsr�r�r�rt)r�r��sa_statsr�s    rgr�z.CloudlinuxSummary._get_smart_advice_statistics!s���
�#�!%�
�
�
��$�d�;�;�;�	"���=�=��+��4���H�
�#�	"��+3�G�+<�-5�i�-@������ �"�"�"��(�(�8�9<�Q����K�K�K�"�M�M�M�M�M�M�����	"����
�
s�A#�#
B"�-*B�B"�B"c��i}tj�d���r�td��5}t	j|��}t
|��|d<t|�����}d�|D��}t
|��|d<t
d�|D����|d<g|d<g|d<|D]�}|d	d
kr9|�	d��}|r!|d�
|d���G|d	dkr8|�	d��}|r!|d�
|d����tt|d����|d<tt|d����|d<t
d
�|D����|d<t
d�|D����|d<t
d�|D����|d<t
d�|D����|d<ddd��n#1swxYwYtj�d��rPtd��5}|����
��|d<ddd��n#1swxYwY|S)zP
        Return statistics by parsing /var/lib/apache2nginx/server.json
        z!/var/lib/apache2nginx/server.json�total_websitesc�<�g|]}|�d���|��S)�proxy_reasonrr�s  rgr�z<CloudlinuxSummary.get_apache2nginx_stats.<locals>.<listcomp>Qs)��H�H�H��!�%�%��2G�2G�H�1�H�H�Hrf�total_proxy_passc�*�g|]}|ddk�|��S)r}�	directiverer�s  rgr�z<CloudlinuxSummary.get_apache2nginx_stats.<locals>.<listcomp>Ws'��L�L�L�1�1�^�+<��+K�+K�Q�+K�+K�+Krf�proxy_pass_due_directive�failing_directives�failing_handlersr}r��
proxy_detailsrc�*�g|]}|ddk�|��S)r}�testrer�s  rgr�z<CloudlinuxSummary.get_apache2nginx_stats.<locals>.<listcomp>ns'��G�G�G�1�1�^�+<��+F�+F�Q�+F�+F�+Frf�proxy_pass_due_testc�*�g|]}|ddk�|��S)r}�forcedrer�s  rgr�z<CloudlinuxSummary.get_apache2nginx_stats.<locals>.<listcomp>rs'��I�I�I�1�1�^�+<��+H�+H�Q�+H�+H�+Hrf�proxy_pass_due_forcedc�*�g|]}|ddk�|��S)r}rrer�s  rgr�z<CloudlinuxSummary.get_apache2nginx_stats.<locals>.<listcomp>vs'��J�J�J�1�1�^�+<�	�+I�+I�Q�+I�+I�+Irf�proxy_pass_due_handlerc�*�g|]}|ddk�|��S)r}�includesrer�s  rgr�z<CloudlinuxSummary.get_apache2nginx_stats.<locals>.<listcomp>zs'��K�K�K�1�1�^�+<�
�+J�+J�Q�+J�+J�+Jrf�proxy_pass_due_includesNz/var/lib/apache2nginx/stater})r�r�r�r�r��loadr�rdr�r�r�r!rr)r�rrI�websites�proxiedr��failing_directive�failing_handlers        rgr�z(CloudlinuxSummary.get_apache2nginx_statsAsO����
�7�>�>�=�>�>�3	��9�:�:�2
�a��y��|�|��+.�d�)�)��&�'�����
�
�.�.��I�H�h�H�H�H��,/��L�L��(�)�58�L�L��L�L�L�5�5��0�1�/1��*�+�,.��(�)� ���A���(�K�7�7�,-�E�E�/�,B�,B�)�,��!�"6�7�>�>� !�/� 2������>�*�i�7�7�*+�%�%��*@�*@��*��!�"4�5�<�<� !�/� 2�����/3�3�u�=Q�7R�3S�3S�.T�.T��*�+�,0��U�;M�5N�1O�1O�,P�,P��(�)�/2�G�G��G�G�G�0�0��+�,�25�I�I��I�I�I�2�2��-�.�36�J�J��J�J�J�3�3��.�/�47�K�K��K�K�K�4�4��/�0�a2
�2
�2
�2
�2
�2
�2
�2
�2
�2
�2
����2
�2
�2
�2
�j�7�>�>�7�8�8�	2��3�4�4�
2��!"�������!1�!1��g��
2�
2�
2�
2�
2�
2�
2�
2�
2�
2�
2����
2�
2�
2�
2��s$�GH�H�H�*J�J�Jc��d}tj�|��r2tj|dgdd���}tj|j��SdS)roz/usr/bin/clwpos-adminrSTrTNrUrqs  rgrz CloudlinuxSummary.get_wpos_stats�sa��'��
�7�>�>�$���	(����z�"��#�%�%�%�A��:�a�h�'�'�'�	(�	(rf)r�N)r?NrN)r3)�r�r�r�r�r,�	itertools�compressrrrr�r�r�r�r�rZr$r��staticmethodr��propertyr�r�r�r�r�r�r�r�r�rrrr r(r-r%r;r`rvryr5r:r�r�r^r�rur<r�rYr�r�r�rXr�r�r�r�r�r�rrr'r*r-r?r`rmr�r�r�r�r�r�r�rtr9r�r;rr�r!r�r8r�r�rrr9rTrXr[rbrirlrorqrsrvrxrPr�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r6rrrr)r/r8rBrIrHrOr�r�r�r�r�r�r~r�r�rr rlr6�classmethodr[r\rYr=r�r�rWr�r�r�ryrzr{r8r�rrsr�r�rrerfrgr�r��s�
������<��7��"�	�"�$�$�$�	)��(��)@�A�A�(��(��)>�?�?�(��(��)@�A�A����I�D�K�F��K�L�#�#�#��@�@��\�@�����X������X���8�8��\�8��@�@��\�@�����\��
5�5�5�n�	$�	$��X�	$�
�
�
�����

�

��\�

��;�;��\�;��H�H��\�H�<	�	�	�5�5�5�(�$�$��\�$�B�B�B������\��@�@�@�H����\��0�

�

��\�

���t�C��H�~��$�����\��.)#�)#�)#�V4�4�4�0�
:��
:�V�
:��
:�
:�
:��\�
:�
��V�S�[�8I�
�PV�
�ei�
�nr�
�
�
�
����0�%�%��\�%�N�������!�!��\�!�E�E�E�8>
�>
�>
�>
�@����\��@����\��$���(�?�?��\�?�" 
� 
� 
�D
P�
P�
P�	'�	'�	'�����\��<<�<<�<<�|?
�?
�?
�B
�
�
�@h�h�h�T=�=�=�R@�R@�R@�h
�
�
�8
�8
�8
�t
�
�
�*<�<�<��+�c�+�T�+�+�+��\�+�!P��d�4�j�$�t�*�d�3�PS�8�n�.T�(U�!P�!P�!P�!P�F:��s�3�x��S��7I�1J�:�:�:�:�:0��0��0�"&�c�3�h��	0�

�c�5��s��#�#�	$�0�0�0�0�d%!�#�%!�#�%!�%!�%!�%!�N��Y�t����G�G����\�G�,J:�J:�J:�XPC�PC�PC�d�
7�
7��\�
7��
5�
5��\�
5��\�\��\�\��"�"��\�"� �"�"��\�"� � � ��\� �"�"�"�����\������\��	&�	&�	&��o�o��\�o��
�
��\�
�t�t�t�l�!�!��\�!�.���8����\��
�
�
��	#�	#��\�	#��/�/��\�/��7�7��\�7���$�����\���
"�D�
"�
"�
"��\�
"���s�����\����3�����\��"�	�	��\�	�P
�P
�P
�d
�
�
�(A�V�A���
�A�A�A�A�+
�+
�+
�Z��� 0
�0
�0
�d
�
�
�*�$�4�$�$�$��\�$�L
�
�
�Bl�l�l�!�E�#�s�C�-�<P�!�!�!�!�@�&��c�3�h��&�&�&��\�&�,6*�6*�6*�pLC�LC�LC�\T�T�T�*
�
�
�(�(�(�:*�*�*�<(-�(-�(-�T
�
�
�i@�i@�i@�V����\��&*�*�*�*=���
�=�=�=�=�=�H�S�M�=�=�=�=��'�'��[�'�"�!�!��\�!��'�'��\�'�$�$�$�2�������
�
�
��\�
������\���
(�
(��\�
(��*�*��\�*�$�>�>��\�>��?�?��\�?��;�;��\�;��	(�	(��\�	(��<�<��\�<�|�=�S�=�S�=�=�=��\�=�(�4�4��\�4����@�@�@��\�@�D�(�(��\�(�(�(rfr�c�T�t��}|j���|Src)r2r"�
link_xml_node)r�s rgr�r��s$��
�X�X�F�
�O�!�!�#�#�#��Mrf)��
__future__rrr�r]�builtinsrr1r�r�r�r�r�r�rDr8r\r�r��	functoolsrr�collectionsrr	r
�future.utilsr�operatorr
�multiprocessingr�socketr�pathlibrr��cldetectlibrrm�clcommonr�clcommon.constr�clcommon.libr�clcommon.lib.cleditionrrrrr�clcommon.cpapirr�clcommon.utilsrrrrrr r!r"r#�clcommon.clwpos_libr$r%r&�clcommon.lib.constsr'�clcommon.lib.cmt_utilsr(�clcommon.sysctlr)�clconfigr*r+r,�	cli_utilsr-r.�cllimitslib_v2r/r0�
clveconfigr1�lveapir2�cl_summary_arg_parser4�typingr5r6r7r8r9r:r;r<�clsummary.cl_summary_utilsr=r>r?r@rArBrCrDrErFrGrHrIrJrKrLrM�!clsummary.rpm_packages_statisticsrN�clsummary.hardware_statisticsrOrPrQ�clwizard.modulesrR�	lve_utilsrSrw�vendors_api.configrTrU�	cldiaglibrV�cl_proc_hidepidrW�clselect.clselectstatisticsrXrYrZr[r\r]�clselector.selectorlibr^�clselect.clselectctlr_�
lvemanagerr|r`r}�ImportError�clflagsrar�r�r�rrQrrr�r�r��ERRORr�rrr�r��objectr�r�rerfrg�<module>r�s-��'�&�&�&�&�&�������������������������������������	�	�	�	�
�
�
�
�
�
�
�
�
�
�
�
�������������	�	�	�	�(�(�(�(�(�(�(�(�,�,�,�,�,�,�,�,�������"�"�"�"�"�"�������%�%�%�%�%�%�������������������������������"�"�"�"�"�"�&�&�&�&�&�&���������������J�I�I�I�I�I�I�I�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�e�d�d�d�d�d�d�d�d�d�?�?�?�?�?�?�9�9�9�9�9�9�&�&�&�&�&�&�N�N�N�N�N�N�N�N�N�N�6�6�6�6�6�6�6�6�6�6�6�6�6�6�6�6�#�#�#�#�#�#�������?�?�?�?�?�?�L�L�L�L�L�L�L�L�L�L�L�L�L�L�L�L�L�L�L�L���������������������������������������&����������������
)�(�(�(�(�(�:�:�:�:�:�:�=�=�=�=�=�=�=�=�3�3�3�3�3�3�:�:�:�:�:�:�"�����������������=�<�<�<�<�<�8�8�8�8�8�8�@�@�@�@�@�@�@�@�@�@�@�@�@���
"�
"�
"�2��2��1��-��1��1��0�� ��!��!����
"����%�'�'�'�'�'�'�'���%�%�%�$�n�O�O�O�%����-��
�W�
�3�
4�
4�
����	��
�#����
����
��O&�O&�O&�O&�O&�T�O&�O&�O&�d	��	��	�	�	�	�X6(�X6(�X6(�X6(�X6(��X6(�X6(�X6(�vl����s$�<(F%�%G�G�G�G�G