AlkantarClanX12

Your IP : 18.218.190.118


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

�

�ug����ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZmZddlmZmZddlmZddlmZddlmZddlmZddlmZdd	lmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%ddl&Z'ddl(Z(ddl)Z)ddl*Z*dd
l+m,Z,ddl-m.Z.ddl/m0Z0m1Z1m2Z2dd
l3m4Z4ddl5m6Z6m7Z7ddl8m9Z9ddl:m;Z;m<Z<m=Z=ddl>m?Z?ddl@mAZAddlBmCZCddlDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOddlPmQZQmRZRmSZSddlTmUZUddlVmWZWmXZXddlYmZZZm[Z[ddl\m]Z]ddl^m_Z_ddl`maZbddlcmdZdddlemfZfmgZgddlhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxmyZyddlzm{Z{m|Z|m}Z}dd l~mZd!d"l�m�Z�d!d#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�ddl�maZ�n#e�$rejZ�ejZ�ejZ�ejZ�ejZ�ejZ�ejZ�dZ�dZ�dZ�YnwxYw	dd(l�m�Z�n#e�$rd)�Z�YnwxYwd*Z�ej�d+��Z�d,Z�d-Z�d.Z�d/Z�d0Z�d1Z�d2Z�d3Z�d4e�d5e�fd6�Z�Gd7�d8��Z�d9�Z�dS):�N)�Counter�defaultdict)�	lru_cache�partial)�groupby)�	cpu_count)�
attrgetter)�Path)�getfqdn)�Any�AnyStr�Callable�Dict�List�Optional�Tuple�Union)�get_hidepid_typing_from_mounts)�cpapi)�
find_wp_paths�get_wp_cache_plugin� get_wp_paths_with_enabled_module)�Feature)�is_panel_feature_supported�is_wp2_environment)�
MySQLGovernor)�
CLEditions�is_cl_shared_edition�is_cl_solo_edition)�client_activation_data)�ACCELERATE_WP_INSTALLED_FROM_CM)�
SysCtlConf)�ExternalProgramFailed�get_cl_version�get_rhn_systemid_value�
get_virt_type�grep�is_litespeed_running�is_nginx_running�is_secureboot_enabled�is_testing_enabled_repo�	is_ubuntu�run_command)�cagefs_statistics_config�clconfig_utils�db_governor_lib)�is_email_notification_enabled)�print_dictionary�replace_params)�DEFAULTS�LimitsDataStorage)�EMPTY_LIMITS)�ALL_MODULES)�PKG_VERSION)�LvpMap)�CONFIG_PATH�_read_config_file)�
SummaryStatus�dummy_none_function�get_cl_plus_sender_status�get_client_data_from_jwt_token� get_packages_with_lve_extensions�$get_statistics_send_status_from_file�is_active_cloudlinux_license�is_nodejs_selector_installed�is_php_selector_installed�is_python_selector_installed�is_ruby_selector_installed�is_sending_process_running�is_statistic_enabled�is_statistic_rpm_enabled� set_statistic_collection_enabled�$set_statistic_rpm_collection_enabled�$write_statistics_send_status_to_file)�NotSupported�get_cpu_metrics�get_memory_metrics)�get_rpm_packages_info�)�parse_cloudlinux_summary_opts)�StatisticsDict)�get_default_version)�get_default_php_version�get_mode_of_php_selector�get_native_version_safe�get_php_selector_usage�get_versions_statistics�iter_server_applications)�CloudlinuxSelectorLib)�PKG_RELEASE��list_flags_infoc��gS�N�ra��H/opt/cloudlinux/venv/lib64/python3.11/site-packages/clsummary/summary.pyr^r^�s���	rbz/var/log/cloudlinux-summary.logzcloudlinux-summary�unknown�	installed�
not_installed�not_initialized�not_selected�enabled�disabledz-42�	site_dict�returnc�n�ttd�|d�������S)zB
    Checks if wordpress site has at least one enabled module
    c��|dS)Nrira)�modules rc�<lambda>z*site_has_enabled_modules.<locals>.<lambda>�s��&��"3�rb�modules)�any�map�values)rks rc�site_has_enabled_modulesru�s1���s�3�3�Y�y�5I�5P�5P�5R�5R�S�S�T�T�Trbc���eZdZdZdZejgd�eje	j
��eje	j��eje	j��g��Z
dZdZdZd�Zed���Zed	���Zed
efd���Zed���Zed
���Zed���Zd
efd�Zed���Zd�Zd�Zed
e fd���Z!ed���Z"eded
efd���Z#d�Z$d�Z%ed���Z&d�Z'ed�d���Z(d�Z)ed���Z*ed���Z+ed e,e-e-fd
e fd!���Z.d"�Z/d#�Z0ed$e1d%e2d
dfd&���Z3d'e,e2e1fd(e2d)e d
dfd*�Z4d+�Z5ed,���Z6d-�Z7d.�Z8ed
efd/���Z9d�d0�Z:d�d1�Z;ed2���Z<ed3���Z=d4�Z>ed5���Z?d�d6�Z@d
eAe1fd7�ZBd
eAe1fd8�ZCed
eAe1fd9���ZDd�d:�ZEd;eFd
dfd<�ZGd;eFd
dfd=�ZHd;eFd
dfd>�ZId�d?�ZJd�d@�ZKdA�ZLdB�ZMdC�ZNdD�ZOedEedFePfdG���ZQd
eRePeSePeSe,ee1fffdH�ZTd
eReUeeUeffdI�ZVdJedKedLe,eefd
e,eeWePefffdM�ZXdNed
efdO�ZYeeZd�P��dQ�����Z[d�dR�Z\d�dS�Z]edTe1dUe1d
eAe1fdV���Z^edTe1dWe1d
eAe1fdX���Z_edYe`d
e1fdZ���ZaedYe`d
e1fd[���ZbedYe`d
e1fd\���ZcedYe`d
edfd]���ZedYe`d
e1fd^�ZfedYe`d
e1fd_���ZgedYe`d
e1fd`���ZhdYe`d
efda�Ziedbedced
e`efdd���Zjeded
e`fde���Zkd�df�Zled
efdg���Zmd�dh�Znedi���Zodj�Zpedk���Zqedl���Zredm���Zsed
e fdn���Zted
e fdo���Zued
e1fdp���Zved
efdq���Zwedr���Zxds�Zydt�Zzdue2d
eAe1fdv�Z{dw�Z|dx�Z}dy�Z~dz�Zed
e,fd{���Z�d|�Z�d}�Z�d
eRe1e1e1ffd~�Z�ed
eRe1effd���Z�d��Z�d��Z�d�d��Z�d�d��Z�d�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�ed����Z�d��Z�d
eAe1fd��Z�d
eAe1fd��Z�e�d����Z�ed����Z�ed����Z�d;eFd
e`e�e1efd�ffd��Z�d�e1d;eFd
eAeRe1effd��Z�d��Z�e				d�d�ed�e�dzd�e1d�e dzd
e�j�f
d����Z�ed�d�ed�e1d
eAdfd����Z�ed
eAe,fd����Z�ed����Z�ed����Z�ed����Z�ed����Z�ed
eAe,fd����Z�ed
efd����Z�ed�ed
e1fd����Z�ed
eAe,fd����Z�d
e,fd��Z�ed
eAe,fd����Z�ed
eAe,fd����Z�dS)��CloudlinuxSummaryz/var/lve/dashboard_certificatez/etc/cl_plus/.disabled)�python�ruby�nodejsz-https://stat-api.cloudlinux.com/api/clos-statz-https://stat-api.cloudlinux.com/api/rpm-statsz6https://repo.cloudlinux.com/static/cl-settings-v1.jsonc���i|_d|_t��|_d|_d|_|���|_d|_t��|_
dSr`)�_opts�_security_tokenrS�
statistics�_lvpmap�
_system_id�_is_process_not_limited�is_process_not_limited�packages_by_lenr"�sysctl��selfs rc�__init__zCloudlinuxSummary.__init__�sW����
�#���*8�*:�*:���������&*�&B�&B�&D�&D��#�#��� �l�l����rbc��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  rcr�z)CloudlinuxSummary._is_process_not_limited�sP��"�"�*�.�.�1B�"C�"C�D�D�� �����0@�!A�!A�B�B��%�%�?�.?�*?�?rbc�D�|j�t��|_|jS)z.
        Load lvpmap only when needed
        )r�_get_lvpmapr�s rc�lvpmapzCloudlinuxSummary.lvpmap�s��
�<��&�=�=�D�L��|�rbrlc�F�|j�td��|_|jS)N�	system_id)r�r%r�s rcr�zCloudlinuxSummary.system_id�s#���?�"�4�[�A�A�D�O���rbc�&�t��rdndS)N�ubuntu�	rhel_like)r,rarbrc�
_get_platformzCloudlinuxSummary._get_platform�s��$�;�;�7�x�x�K�7rbc�:�t��rtntSr`)r*�ENABLED�DISABLEDrarbrc�_detect_securebootz$CloudlinuxSummary._detect_secureboot�s��/�1�1�?�w�w�x�?rbc���tjtjz�d��fd�t	d��D����}|S)N�c3�@�K�|]}tj���V��dSr`)�random�choice)�.0�_�range_for_random_choices  �rc�	<genexpr>z=CloudlinuxSummary._generate_security_token.<locals>.<genexpr>�s.����� [� [�A���/F�!G�!G� [� [� [� [� [� [rb�@)�string�
ascii_letters�digits�join�range)�security_tokenr�s @rc�_generate_security_tokenz*CloudlinuxSummary._generate_security_token�sI���"(�"6���"F����� [� [� [� [�QV�WY�QZ�QZ� [� [� [�[�[���rbc���i}|j�3d}t�|��|�d|i��d|j��}t�|��|j|jd�}d}	tj|j|d���}n\#tj	$rJ}t|��}t�|��|�d|i��Yd}~nd}~wwxYw|jsCd|j�d|j
��}t�|��|�d|i��t�d	��	|���d}t|dt ��r-|d�|�����t�d
��n�#t&t(f$r6d}t�|��|�d|i��Yndt*$rX}t�dt|��|j��|�dd
t.�d�i��Yd}~nd}~wwxYw|S)NzSecurity token is empty�resultzGetting statistics from server )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"z"Invalid response from server. See z
 for details.)r��
app_logger�error�_error_and_exit�SUMMARY_URL�infor��requestsr��RequestException�str�ok�status_code�reason�json�
isinstance�dict�update�_get_smart_advice_statistics�	TypeError�
ValueError�KeyError�text�LOG_FILE)r��	stat_data�messager��response�es      rc�_get_remote_dataz"CloudlinuxSummary._get_remote_data�s����	���&�/�G����W�%�%�%�� � �(�G�!4�5�5�5�F�D�4D�F�F������ � � ���"�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�f�X�5I�f�f�U]�Ud�f�f�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��	n�	n�	n����\�^a�bc�^d�^d�fn�fs�t�t�t�� � �(�,k�T\�,k�,k�,k�!l�m�m�m�m�m�m�m�m�����	n�����s:�3B�C)�AC$�$C)�A"G�AI5�	I5�AI0�0I5c��|j�|jStj�|j��r|���|_n2|���}|�|��r|nd|_|jSr`)r}r��path�isfile�DASHBOARD_CERTIFICATE�_read_token_from_filer��_write_token_to_file)r��tokens  rcr�z CloudlinuxSummary.security_tokens�����+��'�'�
�7�>�>�$�4�5�5�	W�#'�#=�#=�#?�#?�D� � ��1�1�3�3�E�,0�,E�,E�e�,L�,L�#V�5�5�RV�D� ��#�#rbc�R�	t|jdd���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
        �w�utf-8��encodingNi�Tz,Error while writing secure token to file: %sF)
�openr��writer��chmod�IOError�OSErrorr�r�r�)r�r��fr�s    rcr�z&CloudlinuxSummary._write_token_to_file!s���	��d�0�#��H�H�H�
�A��������
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��H�T�/��7�7�7��4����!�	�	�	����K�S�QR�V�V�T�T�T��5�5�5�5�5�����	���s4�A"�;�A"�?�A"�?�A"�"B&�3(B!�!B&c�D�	t|jdd���5}|������pdcddd��S#1swxYwYdS#tt
f$r3}t�dt|����Yd}~dSd}~wwxYw)N�rr�r�z.Error while reading file with secure token: %s)	r�r��read�stripr�r�r�r�r�)r�r�r�s   rcr�z'CloudlinuxSummary._read_token_from_file0s���	��d�0�#��H�H�H�
0�A��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�����	���s:�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_FILErarbrc�_detect_old_lve_integrationz-CloudlinuxSummary._detect_old_lve_integration8s-���'��+�1���	
�
�
�	
rbc�@�tj�d��S)zO
        Detects presence/absence of lsapi
        :return: True/False
        �/usr/bin/switch_mod_lsapi�r�r��existsrarbrc�_is_lsapi_presentz#CloudlinuxSummary._is_lsapi_presentGs���w�~�~�9�:�:�:rb�interpreterc��|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
        rxryrz�phpN)rzrx�selector_enabledzUnknown interpreter: )rE�
NOT_INSTALLEDrFr�rCrDr[�get_selector_statusr�r��php_selector_is_disabledr�)r��libs  rc�_get_status_of_selectorz)CloudlinuxSummary._get_status_of_selectorOs8���(�"�"�/�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��>��>�>�?�?�?s�'B;�;C�Cc��	tj|d������}|S#tj$rW}t�dt
|����|�dt
|��i��Yd}~dSd}~wttf$r3}t�dt
|����Yd}~dSd}~wwxYw)N�
)r�z3Request exception while getting remote settings: %sr�z'Error while parsing remote settings: %s)
r�r�r�r�r�r�r�r�r�r�)r��settings_url�settingsr�s    rc�_get_remote_settingsz&CloudlinuxSummary._get_remote_settingsms���	��|�L�"�=�=�=�B�B�D�D�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-groupriz4Error occurred while trying to get rollout group: %sr�)
r|r�r�r�r�r�SETTINGS_URL�
_match_serverr�r�r�r�r�)r��is_test_environmentr�
rollout_groupr�s     rc�_is_statistics_enabledz(CloudlinuxSummary._is_statistics_enabledxs���:�>�>�+�,�,�	��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���int)�hash_servers rc�
_to_numberzCloudlinuxSummary._to_number�s���;��#�#�#rbc���|j�dStj|j��������dd�}|�|��d|zzdkS)NT��r)r��hashlib�sha256�encode�	hexdigestr)r��url_numrs   rcrzCloudlinuxSummary._match_server�sa���>�!��4��n�T�^�%:�%:�%<�%<�=�=�G�G�I�I�#�2�#�N������,�,�q�'�z�9�a�?�?rbNc��d}|r9t��s/|dz}tjd��|rt���)dSdSdSdS)zC
        Wait for running background process of cl-summary
        �2rQg�������?N)rG�time�sleep)�retriess rc�_wait_for_background_processz.CloudlinuxSummary._wait_for_background_process�su��
���	�8�:�:�	��q�L�G��J�s�O�O�O��	�8�:�:�	�	�	�	�	�	�	�	�	rbc�L
�|jds
|jdrBt|jd��tj��dd�}t|d��dS|jds
|jdrBt	|jd��tj��dd�}t|d��dS|jdrpt��rd	nd
}tj��|dd�}|�dt��i��t|d��tj	d
��|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�}t3|��|�ddid
���|j�
d��r�|j�
d��sWt��sIt.jdtj��d�}t3|��|�ddid
���|j�ld}t(�|��t.jdt8�d �tj��d�}t3|��|�d|i��|j�
d!��r�t��rtj��d	dd�}npt3t.jtj��dd"���t=jd#dd$d�%��|� ��tj��dd�}t|d��tj	d
��|jdr�|j!rMtd�&��r=tj��d	dd�}t|d��tj	d
��dSt3t.jtj��dd"���dSdS)'N�enable�disable�success��	timestampr�T�
enable-rpm�disable-rpm�status�
collecting�ready)r%r(r��sending_statusr�
get-remote)�datarH�rpm-packagesrr�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�r%zYCollecting 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 z  for details or contact support.�--async)r�r%r�z9/usr/sbin/cloudlinux-summary --send --json &> /dev/null &�	/bin/bash)�shell�
executable�check)�acquire_lock)"r|rJrr2rKrGr�rA�sys�exitr�r��_print_result_and_exitrHrIr��_get_rpm_packages_summary� _send_statistics_and_save_statusr~�RPM_PACKAGES_URLr�r�rr<�FAILEDrLr�r�r��IN_PROGRESS�
subprocess�runrr�)r�r-r(r��status_dictr�s      rc�&_actions_before_run_process_as_limitedz8CloudlinuxSummary._actions_before_run_process_as_limited�sq���:�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�)�+O�+Q�+Q�R�S�S�S��T�4�(�(�(��H�Q�K�K�K��:�>�>�,�'�'�	b��*�*�,�,�F��'�'�V�J^�J`�J`�'�a�a�a��:�>�>�.�)�)�	�+�-�-�
�d�j�n�n�EV�6W�6W�
��$�$� �#J�� !�%����
�*�*�,�,�,��z�~�~�h�'�'�
8��5�5� �O��-� %�6����
��� 5�6�6�6�6� ���$�7�7�7��F��*�*�,�,�	�'�.�R�!�Y�[�[�	��K�
1��=�=�=�� � ��D���
!�
�
�
��:�>�>�(�#�#�	:��:�>�>�"3�4�4�
�=Q�=S�=S�
�+�2�J�!%����	���5�[�A�A�A��$�$� �#J�� !�%�����"�*�T��� � ��)�)�)�+�2�6�GO�6�6�6�"&�������5�[�A�A�A��$�$�h��%8�9�9�9��:�>�>�)�$�$�	�)�+�+�
G�&*�Y�[�[�L�T]�^�^���5�,�8�t�y�{�{�^b�c�c������O��*��	�����1�1�3�3�3�%)�Y�[�[�I�F�F���T�4�(�(�(��H�Q�K�K�K��:�h��	��*�

�/I�W[�/\�/\�/\�

�&*�Y�[�[�L�T]�^�^�� ��t�,�,�,���������5�,�8�t�y�{�{�^b�c�c������	�	rbc��tjtjddd�����}tj|��5}|�dt|��g��t
jddt|��dg|zttj
d	tjtj
���
�����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�create_liblve_settings�
temporary_lve�extendr�rC�callr�r�r�r��dumps�CPUINFO_DATA)�argsr�lve_ids   rc�_run_self_in_lvez"CloudlinuxSummary._run_self_in_lve1s���1��,���,�
�
�
�
�
���
$�X�
.�
.�	�&��K�K��S��[�[�1�2�2�2��?�%�t�S��[�[�:X�Y�\`�`���J�#&�"�Z�	�(>�?�?�
���
�
�
�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�BC�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/nicerM�19rNrO)r�rQ)rCrXr�r�r�)r[s rc�_run_self_by_nicez#CloudlinuxSummary._run_self_by_niceMsE����I�I�I�D�P���
� #����
�
�
�	
rb�optsc�|��t�fd�dD����rdSt�fd�dD����rdSdS)zK
        Check that passed command should run as unlimited process
        c3�(�K�|]}�|V��
dSr`ra�r��optionras  �rcr�zECloudlinuxSummary._should_run_as_unlimited_process.<locals>.<genexpr>as;�����
�
��
��L�
�
�
�
�
�
rb)r.r(r,r!r"r&r'Tc3�(�K�|]}�|V��
dSr`rards  �rcr�zECloudlinuxSummary._should_run_as_unlimited_process.<locals>.<genexpr>ns;�����
�
��
��L�
�
�
�
�
�
rb)r0r5�--jsonrF)rr)ras`rc� _should_run_as_unlimited_processz2CloudlinuxSummary._should_run_as_unlimited_process\s����
�
�
�
�
��
�
�
�
�
�	��4��
�
�
�
��
�
�
�
�
�		��5��urbc��|�|��|_|j�r)|���|�|j��rtjd��dSttj	��s+|�
|��}tj|��dS	|�|��}tj|��dS#tj
$rc}d|��}t|��tjt"��}|�|d���tjd��Yd}~dSd}~wwxYw|�|j��r]d}t'j��|d�}t(�||j���t-|d��tjd	��|���dS)
Nrz"failed to run task in lve, error: T)�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$)�extrarQ)�_parse_argsr|r�rFrhr;r<rr�LVEr`r]rS�
PyLveError�print�logging�	getLogger�__name__�	exceptionrr�r�r2�run_get_summary)r��argv�rcr��	error_msg�log�err_msgr-s        rcrDzCloudlinuxSummary.runzs����%�%�d�+�+��
��&�(	#�
�7�7�9�9�9��4�4�T�Z�@�@�
!���������/���<�<�
!��+�+�D�1�1����������!��.�.�t�4�4�B��H�R�L�L�L�L�L�� �+�!�!�!� H�Q� H� H�I��)�$�$�$�!�+�H�5�5�C��M�M�)�d�M�;�;�;��H�R�L�L�L�L�L�L�L�L�L�����!�����4�4�T�Z�@�@�

�*��"&����%����� � ���
� �;�;�;� ��t�,�,�,�������� � �"�"�"�"�"s�,)C�E	�&AE�E	c���tj��}|���tj��|z
}||jd<|jdr0|j�t|j|��ddd��|j�d��r>|�|j|j	d���t�d	��dSt|jd��dS)
N�cl_summary_execution_timerLr��cl_summary_max_mem_usedz,Can't get memory usage by cloudlinux-summaryr0Tr1zMain statistics sent)
r�_get_summaryr~r|�
add_metricr�_get_max_memoryr�r?r�r�r�r2)r��
start_time�running_times   rcruz!CloudlinuxSummary.run_get_summary�s����Y�[�[�
��������y�{�{�Z�/��7C���3�4��:�j�!�	��O�&�&���,�l�;�;��)�>�	
�
�
��:�>�>�(�#�#�	4��1�1����$� �
2�
�
�
�

�O�O�2�3�3�3�3�3��T�_�d�3�3�3�3�3rbr%�summary_resultc�v�tj|d�}|dkr||d<tj|d<t|��dS)z@
        Save status of sending statistics to json file
        �r�r%r#r�r�N)r<�SUCCESSrArL)r%r�rEs   rc�_save_statuszCloudlinuxSummary._save_status�sJ��"/�!6�Y�O�O���Y�&�&�$2�K��!�$1�$8�K��!�,�[�9�9�9�9�9rbr2r3r4c���ttj����}||d<|�||���}||d�}t|d��|r|�||��dSdS)zH
        Send statistics data to server and save status to file
        r%)r3r�TN)rr�_send_statisticsr2r�)r�r2r3r4r%�s_resultr�s       rcr?z2CloudlinuxSummary._send_statistics_and_save_status�s�����	���$�$�	�(�����(�(��c�(�:�:��$�9�=�=�����&�&�&��	������
�
�
�
�
�	�	rbc��|dz}|dkrdSdddt|jd��ddd	ttj|�����d
�g}	t|d���\}}}n3#t$r&}t�d
|��Yd}~dSd}~wwxYw|dkrLtj
|��}	td�|dD����S#ttf$rYdSwxYwt�d||��dS)Nr�rQz/usr/sbin/lveinforgz--idrLz--show-columns�mPMemz--period�mT��return_full_outputz Unable to run lveinfo, error: %src3�&K�|]}|dV��
dS)r�Nra�r��xs  rcr�z4CloudlinuxSummary._get_max_memory.<locals>.<genexpr>�s&����C�C�!�1�W�:�C�C�C�C�C�Crbr-z-lveinfo failed with exit code: %i, output: %s)r�r|r�math�ceilr-r#r��warningr��loads�maxr�r�r�)	r�r��time_minutes�cmdrw�json_strr�r��parsed_datas	         rcr�z!CloudlinuxSummary._get_max_memory�sM��#�b�(���!����4������
�:�&�'�'�����4�9�\�*�*�+�+�.�.�.�	
��	�)�#�$�G�G�G�O�B��!�!��$�	�	�	����A�1�E�E�E��4�4�4�4�4�����	������7�7��*�X�.�.�K�
��C�C�{�6�/B�C�C�C�C�C�C����)�
�
�
��t�t�
�������H�"�h�W�W�W��ts*�A)�)
B�3B�B�7C�C+�*C+c�f�d}	d|��}t�|��tjd��}t	d��D]P}	tj||d���}n7#tj$r#}|}tjd|z��Yd}~�Id}~wwxYw|�|j	d	krt�d
��n,d|j	�d|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 z*Unknown exception while sending statistics�r�)r�r��N��zSending statictics OKr�r�)
r�r�r�r�r��post�ConnectionErrorrrr�r�r�r�)r-r3�out_messager��expected_err�ir��errs        rcr�z"CloudlinuxSummary._send_statistics�st�� ��	*�;�c�;�;�G��O�O�G�$�$�$�#�4�5a�b�b�L��1�X�X�	
#�	
#���'�}�S�t�R�H�H�H�H�
�E��	 �/�%�%�%�#&�L��J�q�!�t�$�$�$�$�$�$�$�$�����%����#�"��#�s�*�*���� 7�8�8�8�8�n�X�=Q�n�n�]e�]l�n�n������,�,�,����(�	*�	*�	*��c�(�(�K����[�)�)�)�)�)�)�)�)�����	*�����sC�AC,�	A"� C,�"B�1B�
C,�B�AC,�,D.�;)D)�)D.c��dtj��d�}|���|j�|��|S�NrQ)�versionr%)r�_prepare_cl_normal_statisticsr~r��r�r�s  rcr~zCloudlinuxSummary._get_summarysB���T�Y�[�[�9�9���*�*�,�,�,�����v�&�&�&��
rbc��dtj��d�}|���|j�|��|Sr�)r�'_fill_dict_with_rpm_packages_statisticsr~r�r�s  rcr>z+CloudlinuxSummary._get_rpm_packages_summary!sB���T�Y�[�[�9�9���4�4�6�6�6�����v�&�&�&��
rbc�@�tj��tjS)z.
        Get version of control panel
        )r��getCP�
CP_VERSIONrarbrc�_get_panel_versionz$CloudlinuxSummary._get_panel_version's��	������ � rbc�.�|j�tjd��\}}|st|jd<dS|�H||jd<|j�d�ddd��|j�d	�ddd
��dSt|jd<dS)zN
        Fill dict with statistics by statistics about MySQL governor
        zCan't get MySQL governor mode�mysql_governor_statusN�mysql_governor_modec�B�t�����Sr`)r�get_governor_versionrarbrcrpzCCloudlinuxSummary._fill_mysql_governor_statistics.<locals>.<lambda>>s��
���<�<�>�>�rbr��mysql_governor_versionz Can't get MySQL governor versionc�N�t�����dS�Nr)r�get_governor_statusrarbrcrpzCCloudlinuxSummary._fill_mysql_governor_statistics.<locals>.<lambda>Ds��
���;�;�=�=�a�@�rbzCan't get MySQL governor status)r~�
evaluate_safer0�get_gov_mode_operation�ERRORrr�)r�r#�mysql_gov_modes   rc�_fill_mysql_governor_statisticsz1CloudlinuxSummary._fill_mysql_governor_statistics0s���
#'�/�"?�"?��2�+�#
�#
�����	E�7<�D�O�3�4�4�4�
�
'�5C�D�O�1�2��O�&�&�>�>��(�2�	
�
�
�
�O�&�&�@�@��'�1�	
�
�
�
�
�8E�D�O�3�4�4�4rbc��|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
        r��control_panel_namezCan't get control panel namec�`�d�tj�����D��S)Nc��g|]	\}}|�|��
Srara)r��name�is_supporteds   rc�
<listcomp>zVCloudlinuxSummary._fill_control_panel_statistics.<locals>.<lambda>.<locals>.<listcomp>Xs#��n�n�n�0�d�L�am�n�T�n�n�nrb)r�get_supported_cl_features�itemsrarbrcrpzBCloudlinuxSummary._fill_control_panel_statistics.<locals>.<lambda>Xs*��n�n�E�4S�4U�4U�4[�4[�4]�4]�n�n�n�rb�str_list�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 apacher�
nginx_runningzCan't get control panel nginxc�B�ttj����Sr`)�lenr�cpusersrarbrcrpzBCloudlinuxSummary._fill_control_panel_statistics.<locals>.<lambda>ks��3�u�}���+?�+?�rb�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~rr��	getCPNamer��_get_control_panel_apacher)r�
PLESK_NAME�_is_installed_via_plesk_ext�_is_login_via_whmcs_in_userr�s rc�_fill_control_panel_statisticsz0CloudlinuxSummary._fill_control_panel_statisticsLs���
	
��"�"���� �*�		
�	
�	
�	
��"�"�n�n��#�F�		
�	
�	
�	
��"�"��#��#�-�		
�	
�	
�	
��"�"��*��"�,�		
�	
�	
�	
��"�"�#3�U�O�Ml�m�m�m���"�"�#?�#?��
�Wr�s�s�s������!1�1�1��O�&�&��0��)�J�	
�
�
�	
��"�"��+��$�7�		
�	
�	
�	
��"�"���';�=_�	
�	
�	
�	
�	
rbc	��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
        rk)z/usr/local/cpanel/bin/whmapi1�&get_available_authentication_providersz--output=jsonprettyT)�capture_outputr�r9r-�	providers�
provider_name�whmcsr�whostmgrd_enabledF�cpaneld_enabled�webmaild_enabledrQ)r�r�r�CPANEL_NAMErCrDr�r��stdoutrrr�)r(�commandr�r-�providers     rcr�z,CloudlinuxSummary._is_login_via_whmcs_in_uses��
�������!2�2�2��M�t�t�t������4�t�T�T�T���z�&�-�(�(���T�>�>�k�T�&�\�9�9� ��L��5�

�

���O�,��7�7��F��$�L�L�)<�e�D�D�$�L�L�):�E�B�B�$�L�L�);�U�C�C����#�"#���E�8��
rbc�P�d}d}tj�|��rd}|S)a
        cldeploy-plesk-ext.log is always created by cldeploy-precheck when it downloads the cldeploy script,
        if it exists it means there was an attempt to launch cldeploy from the Plesk Extension.
        Since this function is in package lve-utils, which depends on lve, it means that the current OS is CloudLinux,
        therefore the 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  rcr�z-CloudlinuxSummary._is_installed_via_plesk_ext�s.�� ��3��
�7�>�>�'�"�"�	��F��
rbc���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)r(r��detect_enterprise_litespeed�detect_open_litespeedr~�is_ea4r�s  rcr�z+CloudlinuxSummary._get_control_panel_apache�s~�� �!�!�	��1�3�3�
-�$����-�/�/�
-�(���-���
�_�1�
2�h�
>�
>�$�m�o�o�8�U�U�5�F�F��F��
rbc��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  rc�_cagefs_status_wrapperz(CloudlinuxSummary._cagefs_status_wrapper�sX��1�B�D�D�
�� � � �$�@�-�$�B�O��w���	
��!�$�$�]�I�>�>�>rbc��|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
        r�r�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~rr�r�r�r.�get_cagefs_user_moder�get_quantityr�s rc�_fill_cagefs_statisticsz)CloudlinuxSummary._fill_cagefs_statistics�s���
	
��"�"��'���%�		
�	
�	
��?�?�+�
��/O�O�O�26�D�O�.�/�/��O�&�&�(�=��"�,�	
�
�
�	
��"�"��,�9�4�@�@��%�=�		
�	
�	
�	
��"�"��,�9�5�A�A��&�>�		
�	
�	
�	
�	
rbc�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�rNra�r�r��lvps   rcr�zLCloudlinuxSummary._get_amount_of_endusers_under_resellers.<locals>.<genexpr>�2����Y�Y���3�QT�WX�QX�QX��QX�QX�QX�QX�Y�YrbNc3� �K�|]}|�vV��	dSr`ra)r��lvp_id�enabled_lvp_ids  �rcr�zLCloudlinuxSummary._get_amount_of_endusers_under_resellers.<locals>.<genexpr>s(�����O�O��6�^�+�O�O�O�O�O�Orb)
rr��
lve_lvp_pairsrrM�set�name_map�id_list�sum�elements)r��	lvp_countr
s  @rc�'_get_amount_of_endusers_under_resellersz9CloudlinuxSummary._get_amount_of_endusers_under_resellers�s����	��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��dSrrars   rcr�zBCloudlinuxSummary._get_total_amount_of_endusers.<locals>.<genexpr>r
rbN)rr�rrrMrrt)r�rs  rc�_get_total_amount_of_endusersz/CloudlinuxSummary._get_total_amount_of_enduserssr��	��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�	resellersrMrarbrc�_get_amount_of_resellersz*CloudlinuxSummary._get_amount_of_resellerssB��
	��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
        r� 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�,������Sr`)�_get_resellers_with_faultsr�s�rcrpz>CloudlinuxSummary._fill_resellers_statistics.<locals>.<lambda>Fs���D�3�3�5�5�rb�resellers_with_faultsz:Can't get amount of resellers with faults for the past 24hc�\�tttj������Sr`)r��listrS�lvp_listrarbrcrpz>CloudlinuxSummary._fill_resellers_statistics.<locals>.<lambda>Ms���D��!3�!5�!5�6�6�7�7�rb�resellers_activez$Can't get amount of active resellersN)
r~rrS�lve�is_lve10�is_panel_supported�reseller_limit_supportedrrrr�s`rc�_fill_resellers_statisticsz,CloudlinuxSummary._fill_resellers_statisticss����
	
��"�"��M�"��.�F�		
�	
�	
�	
��"�"��M�,��5�M�		
�	
�	
�	
��"�"��M�2��
&�?�
	
�	
�	
�	
��"�"��)���1�		
�	
�	
�	
��"�"��8��6�L�		
�	
�	
�	
��"�"��.��&�1�		
�	
�	
�	
��"�"�5�5�5�5��#�H�		
�	
�	
��?�4�5�
	<��O�&�&�7�7��"�6�	
�
�
�
�
�37�D�O�.�/�JN�D�O�F�G�7;�D�O�3�4�4�4rb�xml_cfg_providerc���|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
        r�default_limit_speedzCan't get default speed limitr��default_limit_cpu_origin_unitsz+Can't get cpu origin units of default limitc�2���jtjSr`)�defaultsr4�ncpu�r/s�rcrpzCCloudlinuxSummary._fill_default_limits_statistics.<locals>.<lambda>m����$�-�h�7�<�rb�default_limit_ncpuzCan't get default ncpu limitc�2���jtjSr`)r4r4�ior6s�rcrpzCCloudlinuxSummary._fill_default_limits_statistics.<locals>.<lambda>s����$�-�h�7�:�rb�default_limit_iozCan't get default io limitc�2���jtjSr`)r4r4�nprocr6s�rcrpzCCloudlinuxSummary._fill_default_limits_statistics.<locals>.<lambda>ys���$�-�h�7�=�rb�default_limit_nproczCan't get default nproc limitc�2���jtjSr`)r4r4�epr6s�rcrpzCCloudlinuxSummary._fill_default_limits_statistics.<locals>.<lambda>r;rb�default_limit_epzCan't get default ep limitc�2���jtjSr`)r4r4�iopsr6s�rcrpzCCloudlinuxSummary._fill_default_limits_statistics.<locals>.<lambda>�r7rb�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~rr�_cpu_limit_to_percentsr4r4�cpur5�_get_cpu_limit_units�_mempages_to_mb�vmem�pmem�r�r/s `rc�_fill_default_limits_statisticsz1CloudlinuxSummary._fill_default_limits_statisticsWs���
	
��"�"���+� �)�(�3�7� �)�(�3�8�
�
�

�!�+�		
�		
�		
�	
��"�"��D�-�/?�/H��/R�/V�W�W��,�9�		
�	
�	
�	
��"�"�<�<�<�<�� �*�		
�	
�	
�	
��"�"�:�:�:�:���(�		
�	
�	
�	
��"�"�=�=�=�=��!�+�		
�	
�	
�	
��"�"�:�:�:�:���(�		
�	
�	
�	
��"�"�<�<�<�<�� �*�		
�	
�	
�	
��"�"��D�(�*:�*C�H�*M�*R�S�S��#�*�		
�	
�	
�	
��"�"��D�(�*:�*C�H�*M�*R�S�S��#�*�		
�	
�	
�	
�	
rbc���|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��Sr`)r��packagesr6s�rcrpzACloudlinuxSummary._fill_other_limits_statistics.<locals>.<lambda>�s���C�(�1�2�2�rbr�packages_totalz"Can't get total amount of packagesc�F��t������Sr`)r��get_packages_with_custom_limitsr6s�rcrpzACloudlinuxSummary._fill_other_limits_statistics.<locals>.<lambda>�s���C�(�H�H�J�J�K�K�rb�packages_with_custom_limitsz/Can't get amount of packages with custom limitsc�F��t������Sr`)r��get_users_with_custom_limitsr6s�rcrpzACloudlinuxSummary._fill_other_limits_statistics.<locals>.<lambda>�s���C�(�E�E�G�G�H�H�rb�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_faultsrNs `rc�_fill_other_limits_statisticsz/CloudlinuxSummary._fill_other_limits_statistics�s����	
��"�"�2�2�2�2���0�		
�	
�	
�	
��"�"�K�K�K�K��)�=�		
�	
�	
�	
��"�"�H�H�H�H��&�:�		
�	
�	
�	
��"�"��'���D�		
�	
�	
�	
�	
rbc�����tdd��D�]�}�j�t�j||��d|�d���\}�|r��dS�j��fd�dd|�d	�d�
���j��fd�dd|�d
�d�
���j���fd�dd|�d�d�
���j���fd�dd|�d�d�
���j��fd�dd|�d�d�
���j��fd�dd|�d�d�
���j��fd�dd|�d�d�
���j��fd�dd|�d�d�
���j��fd�dd|�d�d�
���j���fd�dd|�d�d�
���j���fd�dd|�d�d�
�����dS) zV
        Fill dict with statistics by statistics about top packages on server
        rQr�zCan't get top z package by usersNc����djS�NrQ�r���
top_results�rcrpzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>�s���
�1�
�*�rbr��top_�
_package_name��log_messagec�.��t�d��Sr�rras�rcrpzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>�s����J�q�M�*�*�rbr�_package_users_numc������djptj�djptj��Sr_)rH�limitsr6rIr5�r�rbs��rcrpzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>�s;����3�3���]�)�9�\�>���]�)�9�\�?���rb�_package_limit_speedc�\�����djptj��Sr_)rJrjr6rIrks��rcrpzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>�s)����1�1���]�)�9�\�>���rb�_package_limit_cpu_origin_unitsc�6���djptjSr_)rjr6r5ras�rcrpzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>������A��-�=��C�rb�_package_limit_ncpuc�6���djptjSr_)rjr6r:ras�rcrpzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>������A��-�=��A�rb�_package_limit_ioc�6���djptjSr_)rjr6r>ras�rcrpzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>�s����A��-�=��D�rb�_package_limit_nprocc�6���djptjSr_)rjr6rAras�rcrpzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>�rsrb�_package_limit_epc�6���djptjSr_)rjr6rDras�rcrpzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>�rprb�_package_limit_iopsc�\�����djptj��Sr_)rKrjr6rLrks��rcrpzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>�$����,�,�j��m�.B�.R�l�-X�Y�Y�rb�_package_limit_vmem_mbc�\�����djptj��Sr_)rKrjr6rMrks��rcrpzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>
r|rb�_package_limit_pmem_mb)r�r~r�r�#_get_top_package_by_number_of_usersr)r�r/r�r#rbs`   @rc�_fill_top_packages_statisticsz/CloudlinuxSummary._fill_top_packages_statistics�ss�����q�!���R	�R	�A�"&�/�"?�"?���@�!�EU�V�V�5��5�5�5�#�#��G�Z��
�j�0����
�O�&�&�*�*�*�*��'�q�'�'�'� �	
'�
�
�
�
�O�&�&�*�*�*�*��,�q�,�,�,� �	
'�
�
�
�
�O�&�&�������.�q�.�.�.� �
'�
�
�
�
�O�&�&�������9�q�9�9�9� �

'�
�
�
�
�O�&�&�C�C�C�C��-�q�-�-�-� �	
'�
�
�
�
�O�&�&�A�A�A�A��+�q�+�+�+� �	
'�
�
�
�
�O�&�&�D�D�D�D��.�q�.�.�.� �	
'�
�
�
�
�O�&�&�A�A�A�A��+�q�+�+�+� �	
'�
�
�
�
�O�&�&�C�C�C�C��-�q�-�-�-� �	
'�
�
�
�
�O�&�&�Y�Y�Y�Y�Y��0�q�0�0�0� �	
'�
�
�
�
�O�&�&�Y�Y�Y�Y�Y��0�q�0�0�0� �	
'�
�
�
�
�[R	�R	rbc��t��}|�|��|�|��|�|��dS)zN
        Fill dict with statistiscs by varied statistics about limits
        N)r5rOr\r�rNs  rc�_fill_limits_statisticsz)CloudlinuxSummary._fill_limits_statisticssU��-�.�.���,�,�-=�>�>�>��*�*�+;�<�<�<��*�*�+;�<�<�<�<�<rbc�0��|j�|jd��\}�|st|jd<dS���L|j��fd�ddd���|j��fd�dd	d���|j��fd
�ddd���|j��fd�dd
d���|j��fd�ddd���|j��fd�ddd���|j��fd�ddd���|j��fd�ddd���|j��fd�ddd���|j��fd�ddd���dSt
|jd<dS)zI
        Fill dict with statistics by statistics about mod_lsapi
        zCan't get raw mod_lsapi info�lsapi_mod_statusNc� ���ddS)N�criur(ra��raw_lsapi_infos�rcrpz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>)s����v�.�x�8�rbr��lsapi_criu_service_statusrec� ���ddS)Nr�r�rar�s�rcrpz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>/s����v�.�y�9�rb�lsapi_criu_service_versionc� ���ddS)N�	lsapiConf�
lsapi_criurar�s�rcrpz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>5s����{�3�L�A�rb�lsapi_option_criuc� ���ddS)Nr��lsapi_with_connection_poolrar�s�rcrpz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>;s����{�3�4P�Q�rb�lsapi_option_connection_poolc����dS)N�
libVersionrar�s�rcrpz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>A�����|�4�rb�lsapi_lib_versionc����dS)N�	modStatusrar�s�rcrpz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>Gs����{�3�rbc����dS)N�
modVersionrar�s�rcrpz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>Mr�rb�lsapi_mod_versionc����dS)N�totalDomainrar�s�rcrpz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>Ss����}�5�rbr�lsapi_total_domain_countc����dS)N�
domainStatrar�s�rcrpz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>Yr�rb�int_dict�lsapi_domain_statc����dS)N�controlPanelrar�s�rcrpz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>_s����~�6�rb�lsapi_apache_environment)r~r��get_raw_lsapi_infor�rr�)r�r#r�s  @rc�_fill_lsapi_statisticsz(CloudlinuxSummary._fill_lsapi_statisticss����#'�/�"?�"?��#�*�#
�#
�����A	@�27�D�O�.�/�/�/�
�
'��O�&�&�8�8�8�8��+� �	
'�
�
�
�
�O�&�&�9�9�9�9��,� �	
'�
�
�
�
�O�&�&�A�A�A�A��#� �	
'�
�
�
�
�O�&�&�Q�Q�Q�Q��.� �	
'�
�
�
�
�O�&�&�4�4�4�4��#� �	
'�
�
�
�
�O�&�&�3�3�3�3��"� �	
'�
�
�
�
�O�&�&�4�4�4�4��#� �	
'�
�
�
�
�O�&�&�5�5�5�5��*� �	
'�
�
�
�
�O�&�&�4�4�4�4��#� �	
'�
�
�
�
�O�&�&�6�6�6�6��*� �	
'�
�
�
�
�
�3@�D�O�.�/�/�/rbc�J�|j�|jddd��dS)N�str_dict�
wmt_configz!Cant get status of wmt_api_config)r~r�_get_wmt_api_configr�s rc�_fill_wmt_settings_statisticsz/CloudlinuxSummary._fill_wmt_settings_statisticsgs3����"�"��$�j�,�@c�	
�	
�	
�	
�	
rbc������	|���\�}�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���Sr`�r�)�all_wp_pathss�rcrpz7CloudlinuxSummary._fill_wp_statistics.<locals>.<lambda>�s���C��%�%�rbr�wordpress_installed_totalz,Can't get total count of installed wordpressc����Sr`ra��object_cache_pluginss�rcrpz7CloudlinuxSummary._fill_wp_statistics.<locals>.<lambda>�s���(�rbr��wordpress_object_cache_pluginsz&Can't get WP object cache plugins infoc����Sr`ra��advanced_cache_pluginss�rcrpz7CloudlinuxSummary._fill_wp_statistics.<locals>.<lambda>�s���*�rb� wordpress_advanced_cache_pluginsz(Can't get WP advanced cache plugins infoc�F��t������Sr`�rrtr�s�rcrpz7CloudlinuxSummary._fill_wp_statistics.<locals>.<lambda>�s���C�,�3�3�5�5�6�6�rb�$wordpress_object_cache_plugins_totalz,Can't get WP object cache total plugins infoc�F��t������Sr`r�r�s�rcrpz7CloudlinuxSummary._fill_wp_statistics.<locals>.<lambda>�s���C�.�5�5�7�7�8�8�rb�&wordpress_advanced_cache_plugins_totalz.Can't get WP advanced cache total plugins infoc����Sr`ra)�wp_php_versionss�rcrpz7CloudlinuxSummary._fill_wp_statistics.<locals>.<lambda>�s���O�rb�wordpress_php_versionszCan't get WP php version info)�_prepare_wp_statistics�	Exceptionr�r�r�r'r�_prepare_wp_plugins_statisticsr�r�r~r)r��paths_with_wpos_object_cacher��without_wpos_object_cacher�r�r�r�s    @@@@rc�_fill_wp_statisticsz%CloudlinuxSummary._fill_wp_statisticsls�������	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�;?�;^�;^�)�<�<�8� �"8�"8���	B�	B�	B����R�TW�XY�TZ�TZ�[�[�[�;=�r�8� �"8�"8�"8�"8�"8�"8�����	B����(�	m� �'�'�)G��Mi�Ij�Ij�(k�l�l�l���"�"�%�%�%�%��'�:�		
�	
�	
�	
��"�"�(�(�(�(��,�4�		
�	
�	
�	
��"�"�*�*�*�*��.�6�		
�	
�	
�	
��"�"�6�6�6�6��2�:�		
�	
�	
�	
��"�"�8�8�8�8��4�<�		
�	
�	
�	
��"�"�#�#�#�#�Z�1I�Kj�	
�	
�	
�	
�	
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���Sr`r�)�
users_with_wps�rcrpz@CloudlinuxSummary._fill_per_user_wp_statistics.<locals>.<lambda>�s���C�
�&�&�rbr�$users_count_with_wordpress_installedz7Can't get total count of users with wordpress installedc�"��t���Sr`r�)�users_with_wp_and_litespeeds�rcrpz@CloudlinuxSummary._fill_per_user_wp_statistics.<locals>.<lambda>�s���C�3�4�4�rb�0users_count_with_wordpress_and_lscache_installedzECan't get total count of users with wordpress and LiteSpeed installed)�_prepare_per_user_wp_statisticsr�r�r�r�r~r)r�r�r�r�s  @@rc�_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�E�		
�	
�	
�	
��"�"�4�4�4�4��>�S�		
�	
�	
�	
�	
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    rcr�z0CloudlinuxSummary._prepare_wp_plugins_statistics�s=��
 $�4�4�^�X�N�N��!%�!6�!6�7G��!R�!R��#�%;�;�;rb�plugin_typer�c���ttd�fd�|D������}tt��}|D]}||xxdz
cc<�|S)Nc�0��g|]}t|�����Sra)r)r�r�r�s  �rcr�z6CloudlinuxSummary._get_plugin_info.<locals>.<listcomp>�s%���1n�1n�1n�]a�2E�d�K�2X�2X�1n�1n�1nrbrQ)r'�filterrr)r�r�r��object_plugin_counter_pairs�plugins`    rcr�z"CloudlinuxSummary._get_plugin_info�ss���#�F�4�1n�1n�1n�1n�em�1n�1n�1n�$o�$o�p�p��&1�#�&6�&6�#�*�	5�	5�F�'��/�/�/�1�4�/�/�/�/�*�*rbc�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)rrrr��userdomainsr�r'r�r�r��append�_get_docroot_wp_inforWr�)
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
             rcr�z(CloudlinuxSummary._prepare_wp_statistics�s���
>@��:��"�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�;�;�L�Ir�<s�t�t�t�#�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)rrr�r�r�r�r�r�rr'r�r�r�r�r�r��add)r�r�r�r�r�r�r�r�r�r�r�s           rcr�z1CloudlinuxSummary._prepare_per_user_wp_statistics�sz��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|��KSra)r�r�r�)r��wp_pathr�r�s  ��rcr�z:CloudlinuxSummary._get_docroot_wp_info.<locals>.<listcomp>sZ���
�
�
������W�g�.�.�'�9�9�R�W�\�\�'�SZ�=[�=[�cv�=v�=v�
�=v�=v�=vrbc�T��g|]$}t����|����%Sra�r
�joinpath�r�r�r�s  �rcr�z:CloudlinuxSummary._get_docroot_wp_info.<locals>.<listcomp>s-���#V�#V�#V�T�D��M�M�$:�$:�4�$@�$@�#V�#V�#Vrbr�c�X��g|]&}|�t����|����'Sr`r�r�s  �rcr�z:CloudlinuxSummary._get_docroot_wp_info.<locals>.<listcomp>s@���C
�C
�C
����
��M�M�"�"�4�(�(���rbr�r�Nr�r�r�r�)rrrrr��_get_php_version_for_domain)r�r�r�r�r�r�r��object_cache_plugin�advanced_cache_pluginr�r�s  ``       rcr�z&CloudlinuxSummary._get_docroot_wp_infos������79�58�U�U�&�	
�
��
�
�
�
�
�(��1�1�
�
�
���	 ���#V�#V�#V�#V�X�#V�#V�#V��Z� �C
�C
�C
�C
�8��x�H�H�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��]�+���*��rbr�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_idr�zalt-php�.r�zda-php�handler_typeN�-)r�r�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
             rcr�z-CloudlinuxSummary._get_php_version_for_domain6s���
����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�7Q�Uf�7f�7f�$�$�!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�+�O�s�7�|�|�m�O�<�B�B�3�G�G�K��-�+�-� � rb)�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_inforX)�system_php_versionr�php_selector_usagers    rcrz&CloudlinuxSummary._get_system_php_info\s���	&�!&�!:�!<�!<�=Q�!R�����	&�	&�	&�!%����	&����!�5�7�7��3�5�5���)� 2�3K� L��� "��!�#3�5F�F�Fs��+�+c���|j�|jd��\}�|st|jd<dS���B|j��fd�ddd��|j��fd�d	d
d��|j��fd�d	dd
��|j��fd�d	dd��|j��fd�d	dd��|j��fd�ddd��|j��fd�d	dd��|j��fd�ddd��|j��fd�ddd ��|j��fd!�d"d#d$��dSt
|jd<dS)%z/
        Fill dict with SSA statistics
        zCan't get SSA statistics�
ssa_statusNc����dS)N�configra��	ssa_statss�rcrpz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>�����y��/B�rbr��
ssa_configzCan't get SSA configc����dS)Nr�rars�rcrpz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>�s���	�)�,�rbr��ssa_versionzCan't get version of SSAc����dS)Nr(rars�rcrpz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>�rrbzCan't get state of SSAc����dS)N�agent_statusrars�rcrpz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>�s���	�.�1�rb�ssa_agent_statuszCan't get state of SSA agentc� ���ddS)N�autotracingr(rars�rcrpz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>�s���	�-�0��:�rb�autotracing_statusz"Can't get state of SSA Autotracingc� ���ddS)Nr&�disabled_users_quantityrars�rcrpz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>�s���	�-�0�1J�K�rbr�#autotracing_disabled_users_quantityz1Can't get state of SSA Autotracing disabled usersc� ���ddS)Nr&�
rules_versionrars�rcrpz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>�����	�-�0��A�rb�autotracing_rules_versionz'Can't get SSA Autotracing rules versionc� ���ddS)Nr&�urls_processedrars�rcrpz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>�s���	�-�0�1A�B�rb�autotracing_urls_processedz.Can't get SSA Autotracing processed URLs countc� ���ddS)Nr&�
urls_selectedrars�rcrpz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>�r-rb�autotracing_urls_selectedz-Can't get SSA Autotracing selected URLs countc� ���ddS)Nr&�rejectsrars�rcrpz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>�s���	�-�0��;�rbr��autotracing_rejectsz!Can't get SSA Autotracing rejects)r~r��
get_ssa_statsr�rr�)r�r#rs  @rc�_fill_ssa_statisticsz&CloudlinuxSummary._fill_ssa_statisticsts;���"�_�:�:���&�
�
����
�	�,1�D�O�L�)��F�� ��O�&�&�'B�'B�'B�'B�J�P\�^t�u�u�u��O�&�&�,�,�,�,�e�]�D^�
�
�
�
�O�&�&�'B�'B�'B�'B�E�<�Yq�r�r�r��O�&�&�1�1�1�1�5�:L�Nl�
�
�
�
�O�&�&�:�:�:�:��$�4�	
�
�
�
�O�&�&�K�K�K�K��5�C�	
�
�
�
�O�&�&�A�A�A�A��+�9�	
�
�
�
�O�&�&�B�B�B�B��,�@�	
�
�
�
�O�&�&�A�A�A�A��+�?�	
�
�
�
�O�&�&�;�;�;�;��%�3�	
�
�
�
�
�-:�D�O�L�)�)�)rbc���|j�d�d��\}}|st|jd<dS|���|j�t	|jd��ddd��|j�t	|j|t��dd	d�
��|j�t	|j|t��ddd�
��|j�tddd
��|j�tddd��|j�td��jddd��|j�tddd��|j�td��\}�|r��d|jd<d|jd<dS|j��fd�ddd�
��|j��fd�ddd�
��dSt|jd<dS)zS
        Fill dict with statistics by varied statistics about PHP selector
        c� �td��S)Nr�)rYrarbrcrpzACloudlinuxSummary._fill_php_selector_statistics.<locals>.<lambda>�s��+�E�2�2�rbz+Can't get statistics about PHP interpreters�selector_php_statusNr�r�z Can't get status of PHP selectorr��selector_php_versions_installedre�selector_php_versions_enabled�selector_php_version_defaultz,Can't get default version of PHP interpreter�selector_php_version_nativez+Can't get native version of PHP interpreterr�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|����Srar��r��vrs   rc�
<dictcomp>zUCloudlinuxSummary._fill_php_selector_statistics.<locals>.<lambda>.<locals>.<dictcomp>�s$��s�s�s���G�Q��G���s�s�srbr�r���php_usage_summarys�rcrpzACloudlinuxSummary._fill_php_selector_statistics.<locals>.<lambda>�s)���s�s�?P�Qi�?j�?p�?p�?r�?r�s�s�s�rbr�c�L��d��d���D��S)Nc�4�i|]\}}|t|����Srar�rGs   rcrIzUCloudlinuxSummary._fill_php_selector_statistics.<locals>.<lambda>.<locals>.<dictcomp>�s$��q�q�q���G�Q��G���q�q�qrb�users_by_php_versionrJrKs�rcrpzACloudlinuxSummary._fill_php_selector_statistics.<locals>.<lambda>�s)���q�q�?P�Qg�?h�?n�?n�?p�?p�q�q�q�rb)r~r�r�rrr��"_get_list_versions_of_interperters�	INSTALLEDr�rUrWr[�php_selector_is_enabledrVrXr�)r�r#�php_interpretersrLs   @rc�_fill_php_selector_statisticsz/CloudlinuxSummary._fill_php_selector_statistics�s����
%)�O�$A�$A�2�2�4a�%
�%
�!��!��B	C�5:�D�O�1�2�2�2�
�
)��O�&�&���4�e�<�<��%�2�	
�
�
�
�O�&�&���?�AQ�S\�]�]��1� �	
'�
�
�
�
�O�&�&���?�AQ�SZ�[�[��/� �	
'�
�
�
�
�O�&�&�'��.�>�	
�
�
�
�O�&�&�'��-�=�	
�
�
�
�O�&�&�%�e�,�,�D��)�7�	
�
�
�
�O�&�&�(��#�0�	
�
�
�*.��)F�)F�&�9�*�*�&�G�&��
�/�7�MQ��� I�J�KO��� G�H�H�H���*�*�s�s�s�s��=� $�	+������*�*�q�q�q�q��;� $�	+������6C�D�O�1�2�2�2rb�
total_apps�amount_of_apps_per_domainc�(�|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
        rQNra)rUrVs  rc�_get_average_apps_per_domainz.CloudlinuxSummary._get_average_apps_per_domain�s)����>�>�6��:�:��4��6�6�6rb�amount_of_apps_per_userc�(�|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
        rQNra)rUrYs  rc�_get_average_apps_per_userz,CloudlinuxSummary._get_average_apps_per_users)����>�>�4�q�8�8��4��4�4�4rb�appsc�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  rcr�z@CloudlinuxSummary._get_amount_of_runned_apps.<locals>.<listcomp>s,��Z�Z�Z�C�3�>�Z�c�n�PY�>Y�>Y�C�>Y�>Y�>Yrbr�)r\s rc�_get_amount_of_runned_appsz,CloudlinuxSummary._get_amount_of_runned_appss!���Z�Z�4�Z�Z�Z�[�[�[rbc��t��}|D]}||jxxdz
cc<�|�d��pdg}|ddS)z�
        Get maximum amount of applications per domain
        :param apps: list of applications for something selector
        rQ�rrr)r�doc_root�most_common)r\�apps_per_domainra�most_commonss    rc�_get_max_apps_per_domainz*CloudlinuxSummary._get_max_apps_per_domain sh��"�)�)���	/�	/�C��C�L�)�)�)�Q�.�)�)�)�)�'�2�2�1�5�5�A�&����A��q�!�!rbc��t��}|D]}||jxxdz
cc<�|�d��pdg}|ddS)z~
        Get maximum amount of applications per user
        :param apps: list of applications for something selector
        rQrdr)rr�rf)r\�
apps_per_userrarhs    rc�_get_max_apps_per_userz(CloudlinuxSummary._get_max_apps_per_user0sh�� �	�	�
��	)�	)�C��#�(�#�#�#�q�(�#�#�#�#�%�0�0��3�3�?��x���A��q�!�!rbc�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
        rQ)rr�)r\�apps_per_versionras   rc�_get_counter_apps_per_versionz/CloudlinuxSummary._get_counter_apps_per_version@sD��#�9�9���	/�	/�C��S�[�)�)�)�Q�.�)�)�)�)��rbc�x�|�|��}|�d��pdg}|ddS)z�
        Get maximum amount of applications per version of interpreter
        :param apps: list of applications for something selector
        rQrdr)rorf)r�r\rnrhs    rc�_get_max_apps_per_versionz+CloudlinuxSummary._get_max_apps_per_versionMsC�� �=�=�d�C�C��(�3�3�A�6�6�B�6�(���A��q�!�!rbc�z�t��}|D]}|�|j���t|��S)zz
        Get amount of domains with applications
        :param apps: list of applications for something selector
        )rr�rer�)r\rras   rc� _get_amount_of_domains_with_appsz2CloudlinuxSummary._get_amount_of_domains_with_appsZs?���%�%���	&�	&�C��K�K���%�%�%�%��7�|�|�rbc�z�t��}|D]}|�|j���t|��S)zx
        Get amount of users with applications
        :param apps: list of applications for something selector
        )rr�r�r�)r\�usersras   rc�_get_amount_of_users_with_appsz0CloudlinuxSummary._get_amount_of_users_with_appsgs?�������	 �	 �C��I�I�c�h������5�z�z�rbc�J�|�|��}t|��S)z�
        Get amount of applications per each version of interpeters
        :param apps: list of applications for something selector
        )ror�)r�r\rns   rc�4_get_amount_of_apps_per_each_version_of_interpreterszFCloudlinuxSummary._get_amount_of_apps_per_each_version_of_interpretersts'�� �=�=�d�C�C���$�%�%�%rb�interpreters_stats�statec�D���fd�|���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|]\}}|��
|��Srara)r��interpreter_stats�statrzs   �rcr�zHCloudlinuxSummary._get_list_versions_of_interperters.<locals>.<listcomp>�s,���k�k�k�&=�&7��_c�di�_j�k�!�k�k�krbrJ)ryrzs `rcrPz4CloudlinuxSummary._get_list_versions_of_interperters~s-���l�k�k�k�AS�AY�AY�A[�A[�k�k�k�krbc�F�t|��}|�t|��SgS)zI
        Get list of apllications on server for defined selector
        )rZr')r��	iter_appss  rc�_get_list_of_applicationsz+CloudlinuxSummary._get_list_of_applications�s(��-�[�9�9�	�� ��	�?�?�"��	rbc
�X��|jD�]}|j�tt|��d|�d���\}}|�t
|jd|zdz<�P|st|jd|zdz<�h|j�t|j|��dd|zdz|rd|�d�nd��|j�t|j	|t��d	d|zd
zd���|j�t|j	|t��d	d|zdzd���|j�t|j|��d
|�d���\}�|s��Y|j��fd�dd|zdzd���|jd|zdzdk|jd|zdz<|j�t|j
���dd|zdzd���|j�tt|��d|�d���\}}|r|�||jd|zdz<|j�t|j���dd|zdzd|�d���|j�t|j���dd|zdzd|�d���|j�t|j���dd|zdzd|�d���|j�t|j���dd|zdzd |�d���|j�t|j|jd|zdz|jd|zdz��d!|�d���\}}|r|�||jd|zd"z<|j�t|j|jd|zdz|jd|zdz��d#|�d���\}}|r|�||jd|zd$z<|j�t|j���d%d|zd&zd'|�d�����!dS)(zc
        Fill dict with statistics by varied statistics about ruby/nodejs/python selectors
        zCan't get statistics about z
 interpretersN�	selector_�_statusr�zCan't get status of z	 selectorr��_versions_installedre�_versions_enabledzCan't get list of z
 applicationsc�"��t���Sr`r�)�interpreter_appss�rcrpz>CloudlinuxSummary._fill_selectors_statistics.<locals>.<lambda>�s����,�-�-�rbr�_applications_amountr�_used�_applications_runningzCan't get default version of �_default_version�_max_applications_per_domainz*Can't get max applications per domain for z interpreter�_max_applications_per_userz(Can't get max applications per user for �_num_users_with_appsz0Can't get amount of users with applications for z interpeter�_num_domains_with_appsz2Can't get amount of domains with applications for z8Can't get average amount of applications per domain for � _average_applications_per_domainz6Can't get average amount of applications per user for �_average_applications_per_userr�� _num_applications_by_interpreterz5Can't get amount of applications per each version of )�	SELECTORSr~r�rrYr�r�rr�rPrQr�r�rbrTrirlrvrsrXr[rx)r��selectorr#ry�default_version_of_selector�average_apps_per_domain�average_apps_per_userr�s       @rc�_fill_selectors_statisticsz,CloudlinuxSummary._fill_selectors_statistics�s����
��o	�o	�H�*.�/�*G�*G��/��:�:�E�h�E�E�E�+�+�'�G�'�"�)�FS����h� 6�� B�C���
�FK����h� 6�� B�C���O�&�&���4�h�?�?���h�&��2�>E�O�:�x�:�:�:�:�4�	
�
�
�
�O�&�&���?�AS�U^�_�_���h�&�)>�>� �	
'�
�
�
�
�O�&�&���?�AS�U\�]�]���h�&�)<�<� �	
'�
�
�
�)-��(E�(E���6��A�A�<�X�<�<�<�)�)�%�G�%��
���O�&�&�-�-�-�-���h�&�)?�?� �	
'�
�
�
����h� 6�9O� O�P�ST�T�
�O�K�(�2�W�<�=�
�O�&�&���7�9I�J�J���h�&�)@�@� �	
'�
�
�
�48�?�3P�3P��+�X�6�6�C��C�C�C�4�4�0�G�0��
k�6�B�Oj����h� 6�9K� K�L��O�&�&���5�7G�H�H���h�&�)G�G�S�X�S�S�S�	
�
�
�
�O�&�&���3�5E�F�F���h�&�)E�E�Q�8�Q�Q�Q�	
�
�
�
�O�&�&���;�=M�N�N���h�&�)?�?�X�8�X�X�X�	
�
�
�
�O�&�&���=�?O�P�P���h�&�)A�A�Z�X�Z�Z�Z�	
�
�
�04��/L�/L���5��O�K�(�$:�=S�$S�T��O�K�(�$:�=U�$U�V���
b�8�a�a�a�
0�0�,�G�,��
w�2�>�_v����h� 6�9[� [�\�-1�_�-J�-J���3��O�K�(�$:�=S�$S�T��O�K�(�$:�=S�$S�T���
`��_�_�_�
.�.�*�G�*��
s�0�<�]r����h� 6�9Y� Y�Z��O�&�&���Q�Sc�d�d���h�&�)K�K�_��_�_�_�	
�
�
�
�Uo	�o	rbc��ddg}t|d���\}}}|dkrt|���tj|��}i}|d|d<d�|dD��}tD]#}|�|t��|d	|z<�$|S)
zA
        Get wizard status and list of installed modules
        z/usr/sbin/cloudlinux-wizardr(Tr�r�
wizard_statusc�,�i|]}|d|d��S)r�r(ra)r�ros  rcrIz<CloudlinuxSummary._get_wizard_statistics.<locals>.<dictcomp>s#��`�`�`�v�&��.�&��*:�`�`�`rbrq�wizard_module_)r-r#r�r�r7r��NOT_SELECTED)r��ret_code�std_out�std_err�parsed_json�wizard_statistics�parsed_modulesros        rc�_get_wizard_statisticsz(CloudlinuxSummary._get_wizard_statistics	s���-�h�7��%0���%N�%N�%N�"��'�7��q�=�=�'��0�0�0��j��)�)����-8��-I��/�*�`�`��U^�I_�`�`�`��!�	d�	d�F�;I�;M�;M�f�Vb�;c�;c��.��7�8�8� � rbc�����|j�|jd��\}�|j��fd�ddd���tD]'�|j���fd�dd�zd����(dS)	zX
        Fill dict with statistics by varied statistics about cloudlinux-wizard
        z,Can't get statistics about cloudlinux-wizardc����dS)Nr�ra)r�s�rcrpz;CloudlinuxSummary._fill_wizard_statistics.<locals>.<lambda>)s
���%�o�6�rbr�r�Nrec����d�zS)Nr�ra)ror�s��rcrpz;CloudlinuxSummary._fill_wizard_statistics.<locals>.<lambda>0s���)�*:�V�*C�D�rbr�)r~r�r�rr7)r�r�ror�s  @@rc�_fill_wizard_statisticsz)CloudlinuxSummary._fill_wizard_statisticss����� $��<�<��'�:� 
� 
����
	
��"�"�6�6�6�6����		#�	
�	
�	
�"�	�	�F��O�&�&�D�D�D�D�D�� �6�)� �	
'�
�
�
�
�	�	rbc��t��}g}|D],}|t||�����z
}�-|S)zH
        Returns list of implemented scripts in integration.ini
        )r;r'�keys)r�scripts�sections   rc�$_get_implemented_integration_scriptsz6CloudlinuxSummary._get_implemented_integration_scripts6sL��
#�$�$�����	4�	4�G��t�F�7�O�0�0�2�2�3�3�3�G�G��rbc��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�r:r�r�s  rc�_get_integration_infoz'CloudlinuxSummary._get_integration_infoAsT��
/4�VX�Y�Y���w�~�~�k�*�*�	��M�-1��)�*�26�2[�2[�2]�2]��.�/��
rbc��d}tj��}t|j��|z}t|j��|z}||fS)zG
        Gets memory usage: total and used memory in megabytes
        i)�psutil�virtual_memory�float�total�used)�bytes_in_mb�mem�	mem_total�mem_useds    rc�_get_memory_usedz"CloudlinuxSummary._get_memory_usedMsH��
���#�%�%���#�)�$�$�{�2�	����?�?�[�0���(�"�"rbc�H�tj��}d}d}ttj��rot
j�|��rPt|dd���5}|�	���
��}ddd��n#1swxYwY||fS)za
        Gets kernel info release and module version (starting from 7h)
        :return:
        z/sys/module/kmodlve/versionNr�r�r�)�platform�releaserrrnr�r�r�r�r�r�)�kernel_release�kmodlve_version_file�kmodlve_versionr�s    rc�_get_kernel_infoz"CloudlinuxSummary._get_kernel_infoXs���"�)�+�+��<����%�g�k�2�2�	3�r�w�~�~�FZ�7[�7[�	3��*�C�'�B�B�B�
3�a�"#�&�&�(�(�.�.�"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�r@rarbrc�#_get_lve_extensions_packages_amountz5CloudlinuxSummary._get_lve_extensions_packages_amountgs���3�5�5�6�6�6rbc� �d}tj�|��sdSt|dd���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/enableFr�r�r�N)r�r�r�r�r�r�r�r)�datacycle_filer�r-s   rc�$_is_kernel_datacycle_enabled_in_filez6CloudlinuxSummary._is_kernel_datacycle_enabled_in_fileos���9���w�~�~�n�-�-�	��5�
�.�#��
8�
8�
8�	$�A��6�6�8�8�>�>�#�#�D�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$��C��I�I���s�'A)�)A-�0A-c��d\}}tj�|��sdSt|dd���5}|�������d��}ddd��n#1swxYwY||vS)zR
        Checks if datacycle parameter was given
        for current boot
        )z
/proc/cmdline�	datacycleFr�r�r�� N)r�r�r�r�r�r��split)�cmdline_filer�r�r-s    rc�_is_datacycle_param_was_passedz0CloudlinuxSummary._is_datacycle_param_was_passed~s���$@� ��j��w�~�~�l�+�+�	��5�
�,��g�
6�
6�
6�	/�!��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   rc�_get_total_domains_amountz+CloudlinuxSummary._get_total_domains_amount�sH��
�}�����
� �	:�	:�D��S��!2�4�!8�!8�9�9�9�M�M��rbc��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�rr�)r��symlink_protection_enabled�hardlink_protection_enableds   rc�%_is_link_traversal_protection_enabledz7CloudlinuxSummary._is_link_traversal_protection_enabled�s�������%)�#�f�j�j�9W�.X�.X�*Y�*Y�%Z�%Z�"�&*�3�v�z�z�:Y�/Z�/Z�+[�+[�&\�&\�#�%�	�*E�	��5�%�	#�"�?�&�	$�#�#��trbc���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   rc�_get_cl_installation_sourcez-CloudlinuxSummary._get_cl_installation_source�sd��������
�7�>�>�1�2�2�	�b�g�n�n�EX�6Y�6Y�	��O�
�7�>�>�9�:�:�	��L��
rbc������������ttj��rg�j��jddd����j��jddd����j��fd�ddd���td�	��s#�j�tdd
d����j�tddd����j�tddd����j��jdd
d���j��j
ddd���j��fd�ddd���������j��fd�ddd����j��fd�ddd���������j��fd�ddd����j��fd�ddd����j��jddd���ttj��r �j��fd�ddd ���j�t"dd!d"���j�t$dd#d$���j��jdd%d&��dS)'Nr�lve_extension_packages_amountrer��!link_traversal_protection_enabledc����dSr_ra��kernel_infos�rcrpz;CloudlinuxSummary._fill_system_statistics.<locals>.<lambda>�s����A��rb�installed_kmod_lve_versionT��skip_jwt_check�cldiag_cron_check_enabled�
cpu_amount�testing_repository_enabled�base_distrozCan't detect platform for CLOS�secureboot_statusz+Can't detect whether secure boot is enabledc����dSr�rar�s�rcrpz;CloudlinuxSummary._fill_system_statistics.<locals>.<lambda>�s���K��N�rbr�c����dS)Nr�ra��vendor_integration_infos�rcrpz;CloudlinuxSummary._fill_system_statistics.<locals>.<lambda>�s���+�,F�G�rbr�c����dS)Nr�rar�s�rcrpz;CloudlinuxSummary._fill_system_statistics.<locals>.<lambda>�s���+�,K�L�rbr�r�c����dSr�ra��memory_usages�rcrpz;CloudlinuxSummary._fill_system_statistics.<locals>.<lambda>�����L��O�rbr��memory_total_mbc����dSr_rar�s�rcrpz;CloudlinuxSummary._fill_system_statistics.<locals>.<lambda>�r�rb�memory_used_mb�
domains_totalc�T������p����Sr`)r�r�r�s�rcrpz;CloudlinuxSummary._fill_system_statistics.<locals>.<lambda>	s$����B�B�D�D�m��Hk�Hk�Hm�Hm�rb�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�rrrnr~rr�r�rr1rr+r�r�r�r�r�r&rr�)r�r�r�r�s`@@@rc�_fill_system_statisticsz)CloudlinuxSummary._fill_system_statistics�s��������+�+�-�-��%�g�k�2�2�	��O�&�&��8��/� �	
'�
�
�
�
�O�&�&��:��3� �	
'�
�
�
�
�O�&�&�&�&�&�&��,� �	
'�
�
�
�"��6�6�6�	��O�&�&�-��+� �	
'�
�
�
�	
��"�"�9�e�\�t�"�T�T�T���"�"�#��(��		#�	
�	
�	
�	
��"�"�4�#5�u�m�Mm�n�n�n���"�"��#�U�,?�An�	
�	
�	
�	
��"�"�"�"�"�"�E�+;��	#�	
�	
�	
�#'�"<�"<�">�">����"�"�G�G�G�G��&��		#�	
�	
�	
�	
��"�"�L�L�L�L��+��		#�	
�	
�	
��,�,�.�.����"�"�#�#�#�#�W�.?�T�	#�	
�	
�	
�	
��"�"�#�#�#�#�W�.>�D�	#�	
�	
�	
�	
��"�"��*�E�?�PT�	#�	
�	
�	
�&�g�k�2�2�	��O�&�&�n�n�n�n��0�>�	
�
�
�	
��"�"��5�+�/R�	
�	
�	
�	
��"�"�7�E�:�?W�X�X�X���"�"��,��,�+�		
�	
�	
�	
�	
rbc�����j��fd�ddd���j�tddd���j�tddd	��dS)
Nc� ���jptSr`�r��UNKNOWN_RHN_IDr�s�rcrpzKCloudlinuxSummary._fill_dict_with_rpm_packages_statistics.<locals>.<lambda>	����D�N�4�n�rbr�r��Can't get system ID�
os_versionzCan't get version of OS�
rpm_stat_listrRz*Can't get info about client's rpm packages)r~rr$rPr�s`rcr�z9CloudlinuxSummary._fill_dict_with_rpm_packages_statistics	s�����"�"�4�4�4�4���!�		
�	
�	
�	
��"�"�>�5�,�Ha�b�b�b���"�"�!�?�J�@l�	
�	
�	
�	
�	
rb�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�r
s  rc�_get_proc_paramz!CloudlinuxSummary._get_proc_param 	s#���(������)?�)?�@�@�@rbc	�H�dg}ttj��r|�gd���|D]I}|j�t
|j|��d|�dd��d|�����J|j�tddd��d	S)
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_taskrrr�z
Can't get �hidepidzCan't get hidepid valueN)
rrrnrWr~rrr
rr�r��
parameters�ps   rc�_fill_proc_params_statisticsz.CloudlinuxSummary._fill_proc_params_statistics(	s���
'�
�
�&�g�k�2�2�	�

������

�

�

��	�	�A��O�&�&���,�a�0�0���	�	�#�s�#�#� �Q� � �
�
�
�
�	
��"�"�*���%�		
�	
�	
�	
�	
rbc	��d}|D]9}|j�t|j|��dd|��d|�d����:dS)zJ
        Fill dict with statistics about kmodlve parameters usage
        )�lve_setuid_enterr�kmodlve_zCan't get "z" kmodlve parameter valueN)r~rr�_get_kmodlve_param_valuers   rc�_fill_kmodlve_params_statisticsz1CloudlinuxSummary._fill_kmodlve_params_statisticsU	sk��+�
��	�	�A��O�&�&���5�q�9�9���1���;�q�;�;�;�	
�
�
�
�	�	rbc����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��r-s�rcrpz=CloudlinuxSummary._fill_cln_jwt_information.<locals>.<lambda>j	s���D�L�D�D�d�h�h�y�$�.G�.G�rbrrzCan't get cl_plus informationc�8����dn��dd��S)N�	client_idrrs�rcrpz=CloudlinuxSummary._fill_cln_jwt_information.<locals>.<lambda>p	s���D�L�D�D�d�h�h�{�D�.I�.I�rbr zCan't get client_id valuec�8����dn��dd��S)N�is_awp_premium_allowedrrs�rcrpz=CloudlinuxSummary._fill_cln_jwt_information.<locals>.<lambda>v	s���D�L�D�D�d�h�h�7O�QU�.V�.V�rb�jwt_is_awp_premium_allowedz&Can't get is_awp_premium_allowed valuec�8����dn��dd��S)N�is_awp_cdn_allowedrrs�rcrpz=CloudlinuxSummary._fill_cln_jwt_information.<locals>.<lambda>|	s���D�L�D�D�d�h�h�7K�T�.R�.R�rb�jwt_is_awp_cdn_allowedz"Can't get is_awp_cdn_allowed valuec�8����dn��dd��S)N�is_trialrrs�rcrpz=CloudlinuxSummary._fill_cln_jwt_information.<locals>.<lambda>�	s���D�L�D�D�d�h�h�z�4�.H�.H�rb�jwt_is_trial_licensez$Can't get jwt_is_trial_license value�license_activezCan't get license status valueN)r?r~rrrB)r�r-s @rc�_fill_cln_jwt_informationz+CloudlinuxSummary._fill_cln_jwt_informationb	sD���.�u�E�E�E����"�"�G�G�G�G���+�		
�	
�	
�	
��"�"�I�I�I�I���'�		
�	
�	
�	
��"�"�V�V�V�V��(�4�		
�	
�	
�	
��"�"�R�R�R�R��$�0�		
�	
�	
�	
��"�"�H�H�H�H��"�2�		
�	
�	
�	
��"�"��0�$�7�7��@P�Rr�	
�	
�	
�	
�	
rbc����j��fd�ddd���j�tddd��dS)	za
        Filling stats centralized management
        - centralized management existence
        c�L��tj��j��Sr`)r�r�r��CL_PLUS_CM_DISABLED_PATHr�s�rcrpzKCloudlinuxSummary._fill_centralized_management_statistics.<locals>.<lambda>�	s���B�G�N�N�4�#@�A�A�rbr�centralized_management_disabledzCan't check CM disabling statusr��cl_plus_sender_service_statusz)Can't check cl plus sender service statusN)r~rr>r�s`rc�'_fill_centralized_management_statisticsz9CloudlinuxSummary._fill_centralized_management_statistics�	sf���	
��"�"�A�A�A�A��-�-�	
�	
�	
�	
��"�"�%��+�7�		
�	
�	
�	
�	
rbc�2�i}	t��}|D]H}|���D]1\}}|�d|��g���|���2�In9#tt
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)rNr��
setdefaultr�r�rMr�r�)r��	cpu_cores�cpu_core�metric�value�exs      rc�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�Bc	��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>�int_listr�NzCan't parse z metric for all coresr��memoryzCan't parse memory metrics)r:r~rrr�rO)r��exp_metrics�cpu_metricsr7�metric_types     rc�_fill_hardware_statisticsz+CloudlinuxSummary._fill_hardware_statistics�	s���S�R�R���0�0�2�2��!�	�	�F�(.�+�(=�(=�*�*�:�K��O�&�&������6�6���<�v�<�<�<�	
�
�
�
�	
��"�"����(�		
�	
�	
�	
�	
rbc��|���\|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�r�r�s rc�$_fill_act_cagefs_disabled_statisticsz6CloudlinuxSummary._fill_act_cagefs_disabled_statistics�	s[��
�;�;�=�=�		
��O�F�G��O�D�E��O�G�H�@B����Oj�@k�@k���<�=�=�=rbc���	|���\}}|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)����rRrR)�_get_data_from_logr�r'r'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        rcrKz<CloudlinuxSummary._scan_log_for_act_cagefs_disabled_messages�	sA��(	!�!%�!8�!8�!:�!:��J���Q���#�\�\�$�/�/�
�#'��L�%)�(,�'1�	���$�$� �,/�/?�+@�+@�(�#'��V�%)�(,�'1�	���$�$� �*-�-=�)>�)>�&�#'��V�%)�(,�'1�	���$�$� �-0�0@�,A�,A�)�)�,-�(�)*�&�,-�)�+�-C�E^�^�^����!�	!�	!�	!� �=�=�	!���s�C
C
�
C"�!C"c	�D�t��}|dvrd}nOtj���tjd���z
}|�d��}d|�d�}t
j|ddd	tjtj	d
���}|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'rQ)�daysz%Y-%m-%dz/usr/share/cloudlinux/logs-at z< /var/log/messages | /bin/grep 'Act like CageFS is disabled'Tr6F)r�r7r8r��stderrr9)r$�datetime�date�today�	timedelta�strftimerCrD�PIPE�DEVNULLrTr�)�os_type�s_cmd�yesterday_date�date_to_scanrs     rcrSz$CloudlinuxSummary._get_data_from_log*
s���!�"�"���,�,�,�w�E�E�&�]�0�0�2�2�X�5G�Q�5O�5O�5O�O�N�)�2�2�:�>�>�L�N��N�N�N�
�
�N����"��?��%��
�
�
���|�Q�X�%�%rbc����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�!t�t�dt���jd<n
d�jd<����dS)Nr�old_way_of_integration_used�*Can't detect old LVE integration mechanism�lve_utils_versionF)�
verify_expr��
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����jSr`�r�r�s�rcrpzACloudlinuxSummary._prepare_cl_normal_statistics.<locals>.<lambda>e
�
���D�'�rbr��$Can't get or generate security tokenc� ���jptSr`rr�s�rcrpzACloudlinuxSummary._prepare_cl_normal_statistics.<locals>.<lambda>k
rrbr�rr�lvemanager_version)rrrnr~rr��LVE_UTILS_PKG_VERSIONrr�get_cl_edition�_is_solo_marker_exists�_is_admin_marker_exists�_is_container_marker_exists�LVEMANAGER_PKG_VERSION�LVEMANAGER_PKG_RELEASE�_fill_dict_with_statisticsr�s`rcr�z/CloudlinuxSummary._prepare_cl_normal_statisticsK
s����%�g�k�2�2�	��O�&�&��0��-�<�	
�
�
�0E���+�,���"�"��J�-�%�@�@�@�%��Wu�	
�	
�	
�	
��"�"��'��0K�Ms�	
�	
�	
�	
��"�"��(�%�1M�Ov�	
�	
�	
�	
��"�"��,��,�7�		
�	
�	
�	
��"�"�'�'�'�'���2�	
�	
�	
�	
��"�"�4�4�4�4���!�		
�	
�	
�"�-�2H�2T�7M�4h�4h�Pf�4h�4h�D�O�0�1�1�48�D�O�0�1��'�'�)�)�)�)�)rbc����	�
���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)rs�
__module__�__qualname__rarbrc�BreakOuterLoopr��
s�������Drbr�c���tj������}�|z}t|dd���5}d}|D�]}	d�|�d��dd���}tj�|d�����}|�z
|cxkr|kr�nn�d�|����d��dd���}	|	dkr|�
xxd	z
cc<n0|	d
kr|�xxd	z
cc<n|	dkr|�xxd	z
cc<nd}��#ttf$rY��wxYw|r�
�	ddd��dS#1swxYwYdS)
Nr�r�r�Fr�rz%Y-%m-%d %H:%M:%S,%fzlvemanager-openedrQzxray-install-startedzxray-tab-clickedT)
r`�nowr%r�r�r��strptimer�r��AttributeError)�stats�file�current_date_timestamp�	file_pathr��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          ������rc�fill_statisticszFCloudlinuxSummary._fill_lvemanager_statistics.<locals>.fill_statistics�
s#���%-�%6�%:�%:�%<�%<�%F�%F�%H�%H�"�"�T�)�I��i��w�7�7�7�
)�1�#(� ��!�!�D�!�#&�8�8�D�J�J�s�O�O�B�Q�B�,?�#@�#@��-5�->�-G�-G��Rh�-i�-i�-s�-s�-u�-u�*�1�4E�E�HZ�s�s�s�s�]s�s�s�s�s�s�&)�h�h�t�z�z�|�|�/A�/A�#�/F�/F�q�r�r�/J�&K�&K�G�&�*=�=�=� %�&9� :� :� :�a� ?� :� :� :� :�!(�,B�!B�!B� %�&=� >� >� >�!� C� >� >� >� >�!(�,>�!>�!>� %�&;� <� <� <�� A� <� <� <��/3�,���&��7�!�!�!� ��!����#�)�(�(�)�%
)�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)����
)�
)�
)�
)�
)�
)s7�	E<�C>E�E<�E'�#E<�&E'�'E<�<F�Frc�<�g|]}tjd|���|��S)z^lvemanager\.log(\.\d{1,2})?$)�re�match)r�r�s  rcr�zACloudlinuxSummary._fill_lvemanager_statistics.<locals>.<listcomp>�
s+��q�q�q�d���Ii�ko�@p�@p�q�T�q�q�qrbrkz./opt/alt/php-xray/php/advanced_metrics.enabledriz//opt/alt/php-xray/php/advanced_metrics.disabledrj�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
       @@@@@@rc�_fill_lvemanager_statisticsz-CloudlinuxSummary._fill_lvemanager_statisticsv
s��������,�
�%��3��"?�� 7��'E�$��w�}�}�Z�(�(�	��F�	�	�	�	�	�Y�	�	�	�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�0*�1�.C�Q�H_�ab�c�
�
r�q�b�j��&<�&<�q�q�q�	�������!�	*�	*�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�|jd��\}}|st|j|<dS|d|j|<|d|j|<dS)z9
        Fill dict with Leapp upgrade statistics
        �leapp_upgrade_status�centos7_cl7_cl8_transformationzCan't get Leapp statisticsN�leapp_status�discount_eligible)r~r��get_leapp_statsr�)r��LEAPP_STATUS�DISCOUNT_ELIGIBILITYr#�elevate_statuss     rc�_fill_leapp_statisticsz(CloudlinuxSummary._fill_leapp_statistics�
s|��.�� @��"&�/�"?�"?�� �(�#
�#
����
�	�,1�D�O�L�)��F�(6�~�(F����%�0>�?R�0S���,�-�-�-rbc�~�|j�d�ddd��|j�d�ddd��dS)	z:
        Fill dict with feature flags information
        c�2�d�t��D��S)Nc��g|]	}|j��
Srar`�r�r�s  rcr�zVCloudlinuxSummary._fill_feature_flags_statistics.<locals>.<lambda>.<locals>.<listcomp>�
s��7�7�7��Q�V�7�7�7rbr]rarbrcrpzBCloudlinuxSummary._fill_feature_flags_statistics.<locals>.<lambda>�
s��7�7�_�%6�%6�7�7�7�rbr��server_flags_availablez3Can't get information about available feature flagsc�2�d�t��D��S)Nc�*�g|]}|j�	|j��Sra)rir�r�s  rcr�zVCloudlinuxSummary._fill_feature_flags_statistics.<locals>.<lambda>.<locals>.<listcomp>�
s!��D�D�D��!�)�D�Q�V�D�D�Drbr]rarbrcrpzBCloudlinuxSummary._fill_feature_flags_statistics.<locals>.<lambda>�
s��D�D�_�%6�%6�D�D�D�rb�server_flags_enabledz1Can't get information about enabled feature flagsN)r~rr�s rc�_fill_feature_flags_statisticsz0CloudlinuxSummary._fill_feature_flags_statistics�
sb��	
��"�"�7�7��$�A�		
�	
�	
�	
��"�"�D�D��"�?�		
�	
�	
�	
�	
rbc��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_setupr(s	         rc�(_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�!'������rbc�v���j��fd�ddd���j��fd�ddd��t�jd<t�!t�t�d	t���jd
<n
d�jd
<�j��jddd
������dS)Nc����jSr`rur�s�rcrpz7CloudlinuxSummary._prepare_statistics.<locals>.<lambda>rvrbr�r�rwc� ���jptSr`rr�s�rcrpz7CloudlinuxSummary._prepare_statistics.<locals>.<lambda>rrbr�rrnrryrrlrm)r~rrzrr�r�r�r�s`rc�_prepare_statisticsz%CloudlinuxSummary._prepare_statisticss������"�"�'�'�'�'���2�	
�	
�	
�	
��"�"�4�4�4�4���!�		
�	
�	
�0E���+�,�!�-�2H�2T�7M�4h�4h�Pf�4h�4h�D�O�0�1�1�48�D�O�0�1���"�"��,��)�8�		
�	
�	
�	
�'�'�)�)�)�)�)rbc�R�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��CAGEFSrrL�RESELLER_LIMITSr.rnr�r�PHP_SELECTORrT�
RUBY_SELECTOR�PYTHON_SELECTOR�NODEJS_SELECTORr�rr1�LSAPIr��WIZARDr�� _fill_wpos_activation_statistics�_fill_wpos_statisticsr+r�rrrEr�r9r�r�r�r�r�r��_fill_apache2nginx_statisticsr�s rcr�z,CloudlinuxSummary._fill_dict_with_statisticss���%�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�&�w�'<�=�=�	.�)�'�*A�B�B�	.�*�'�*A�B�B�	.�

�+�+�-�-�-�!��6�6�6�	;��8�8�:�:�:�%�g�m�4�4�	*��'�'�)�)�)�%�g�n�5�5�	+��(�(�*�*�*��-�-�/�/�/��"�"�$�$�$��&�&�(�(�(��+�+�-�-�-��$�$�&�&�&��)�)�+�+�+��&�&�(�(�(��*�*�,�,�,��!�!�#�#�#��(�(�*�*�*�� � �"�"�"��)�)�+�+�+��#�#�%�%�%��+�+�-�-�-��5�5�7�7�7��*�*�,�,�,�,�,rbc�J�|j�|jddd��dS)Nr��apache2nginxz Can't parse Apache2Nginx metrics)r~r�get_apache2nginx_statsr�s rcr�z/CloudlinuxSummary._fill_apache2nginx_statisticsJs5����"�"��'���.�		
�	
�	
�	
�	
rbc����|j�d�ddd��|j�td��\}�|j��fd�dd|rdnd��dS)	Nc�J�tj�t��Sr`)r�r�r�r!rarbrcrpzDCloudlinuxSummary._fill_wpos_activation_statistics.<locals>.<lambda>Vs��B�G�N�N�#B�C�C�rbr�.cmt_is_accelerate_wp_free_activation_completedz2Can't get statistic of AccelerateWP CMT activationz,Can't get AccelerateWP activation statisticsc�.����d��S)N�accelerate_wp_free_activater)�client_activations�rcrpzDCloudlinuxSummary._fill_wpos_activation_statistics.<locals>.<lambda>cs���%�)�)�*G�H�H�rb�&cmt_accelerate_wp_free_activated_in_uiz;Can't get statistic of AccelerateWP CMT activation selected)r~rr�r )r�r#r�s  @rcr�z2CloudlinuxSummary._fill_wpos_activation_statisticsRs����	
��"�"�C�C��<�@�		
�	
�	
�&*�_�%B�%B�"�:�&
�&
�"��"�	
��"�"�H�H�H�H��4�MT�^�I�I�Z^�		
�	
�	
�	
�	
rbc�D	��	�
���|j�|jd��\}�|sdSt�t���rW��d��dk�r?��d��� |j��fd�ddd����d	��� |j��fd
�ddd��|j��fd�d
dd��|j��fd�d
dd����d��r |j��fd�d
dd���dD]-�
�
dkr�	|j��
�fd�d
d�
zd���.��dg��D]&�
|j��
�fd�d
d�
zd���'�dD]-�
�
dkr�	|j��
�fd�d
d�
zd���.��dg��D]&�|j���fd�d
d �zd���'��d!g��D]��|j���fd"�d
d#�zd����d$�}��d%�}��|��x�r#|j��fd&�d
d#|zd����|��x�	r#|j��	fd'�d
d#|zd������dg��D]-�
�
dkr�	|j��
�fd(�d
d)�
zd���.��d*i�����D]\�
}||jd+�
z<�|j��fd,�d
d-d��|j��fd.�d
d/d��|j��fd0�d
d1d2��|j��fd3�d
d4d5��|j��fd6�d7d8d9��|j��fd:�d7d;d<��|j��fd=�d7d>d?��|j��fd@�d7dAdB����dC��x}r+|���D]\}}||jdD|��<�dSdSdSdS)ENz!Can't get AccelerateWP statisticsr�r#�features_visible_by_defaultc����dS)Nr�ra��
wpos_statss�rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>u�
���J�'D�E�rbr�� wpos_features_visible_by_defaultz*Can't get statistic of using AccelerateWP.�features_allowed_by_defaultc����dS)Nr�rar�s�rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>|r�rb� wpos_features_allowed_by_defaultc� ���ddS)N�
enabled_sitesr�rar�s�rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�����
�?�3�G�<�rbr�sites_count_with_enabled_wposc� ���ddS)N�
allowed_usersr�rar�s�rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�r�rb�users_count_with_allowed_wpos�
visible_usersc� ���ddS)Nr�r�rar�s�rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�s���J��7��@�rb�users_count_with_visible_wposr�r�c� ���d�S)Nr�ra�ror�s��rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�����J��7��?�rb�sites_count_with_enabled_�
enabled_usersc� ���d�S)Nr�rar�s��rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�r�rb�users_count_with_enabled_r�c� ���d�S)Nr�rar�s��rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�r�rb�users_count_with_allowed_�allowed_suitesc� ���d�S)Nrra��suiter�s��rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�����J�'7�8��?�rb�users_count_with_allowed_suite_�enabled_suitesc� ���d�S)Nrrars��rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�rrb�users_count_with_enabled_suite_�	_billable�
_non_billablec����Sr`ra)�enabled_billables�rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�s��� 0�rbc����Sr`ra)�enabled_non_billables�rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�s��� 4�rbc� ���d�S)Nr�rar�s��rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�r�rb�users_count_with_visible_�upgrade_urls�upgrade_url_c����dS)N�4accelerate_wp_suite_enabled_premium_suite_disallowedrar�s�rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�s
���
�#Y�Z�rbrc����dS)N�1accelerate_wp_suite_enabled_premium_suite_visiblerar�s�rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�s
���
�#V�W�rbrc�.����d��S)N�is_accelerate_wp_flag_enabledrr�s�rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�����
���'F�G�G�rbrz1Can't get statistic of AccelerateWP feature flag.c�.����d��S)N�is_accelerate_wp_icon_enabledrr�s�rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�rrbrz0Can't get statistic of AccelerateWP icon status.c�.����d��S)N�%is_smart_advice_notifications_enabledrr�s�rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�s���
���'N�O�O�rbr�rzJCan't get statistic of AccelerateWP is_smart_advice_notifications_enabled.c�.����d��S)N�!is_smart_advice_reminders_enabledrr�s�rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>�s���
���'J�K�K�rbr zFCan't get statistic of AccelerateWP is_smart_advice_reminders_enabled.c�.����d��S)N�+is_smart_advice_plugin_installation_enabledrr�s�rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>s���
���'T�U�U�rbr"zPCan't get statistic of AccelerateWP is_smart_advice_plugin_installation_enabled.c�.����d��S)N�is_object_cache_banners_enabledrr�s�rcrpz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>s���
���'H�I�I�rbr$zDCan't get statistic of AccelerateWP is_object_cache_banners_enabled.r��
awp_whmcs_)	r~r��get_wpos_statsr�r�r�r�
format_metricr�)
r�r#�billable_suite_metric�non_billable_suite_metric�upgrade_url�whmcs_stats�keyr8r
rrorr�s
        @@@@@rcr�z'CloudlinuxSummary._fill_wpos_statisticsjs��������"�o�;�;���/�
�
�����	��F��j�$�'�'�a	@�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��=�@�	���,1�(;�(;�(;�%�/4�,C�,C�,C�)�'1�~�~�6K�'L�'L�L�#���O�1�1�0�0�0�0��9�<Q�Q�D�	���,6�>�>�:S�+T�+T�T�'���O�1�1�4�4�4�4��9�<U�U�D�	����%�.�.��"�=�=�
�
���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�Ca	@�a	@�,Q�,Q�~
@�
@�@�@rbc���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)r-r#r�r�r�)r[r�rwr�r�r�s      rc�_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����V�XZ�\d�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-faultrrrgz--period=1dN)NNrruzISomething really bad happened to cloudlinux-statistics, The reason is: %s)
r.r�r�r�r�r�r�r�r�r�)r�r��	json_datarrur�s      rc�#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�	�	�	����j�lo�pq�lr�lr�s�s�s��:�:�:�:�:�����	�����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�r1r�s rcr[z(CloudlinuxSummary._get_users_with_faults;���
�7�7�9�9�!�<�<rbc�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.
        rQr3r�s rcr$z,CloudlinuxSummary._get_resellers_with_faultsBr4rbc���|�dS|���}|�d��rdS|�d��rdS|�d��rdS|���rdSd|��S)zGet config cpu limit formatN�%�speed�mhz�ghz�old_cpu_formatz	unknown: )�lower�endswith�isdigit)�clsrI�units   rcrJz&CloudlinuxSummary._get_cpu_limit_unitsIs����;��4��y�y�{�{���=�=����	��7��=�=����	��5��=�=����	��5��<�<�>�>�	$�#�#� �3� � � rbc��|�dSd|zdzS)z/Convert memory limit from mempages to megabytesNr�ira)r8s rcrKz!CloudlinuxSummary._mempages_to_mbZs���=��4��5�y�D� � rbc�h�|�dStj||pd���}|�dSt|dzd��S)z,Convert cpu and ncpu to percents of one coreNr)�lncpugY@rQ)rS�convert_to_kernel_format�round)rIr5r8s   rcrHz(CloudlinuxSummary._cpu_limit_to_percentsasE���;��4��2�3�d�i�a�H�H�H���=��4��U�U�]�A�&�&�&rb.c��|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��dSr`)�packager�)r�r�s  rcr�z>CloudlinuxSummary.get_users_amount_per_plan.<locals>.<genexpr>rs,����g�g�d���IZ�If�T�If�If�If�If�g�grbrH)r,T)�reverse)
r��sortedr'rurtr	rr�r�r�)r�r/�users_sorted_by_packager�rH�group�	num_userss       rc�get_users_amount_per_planz+CloudlinuxSummary.get_users_amount_per_planks���
��'�&,��g�g�&6�&<�&C�&C�&E�&E�g�g�g�g�g��y�)�)�'�'�'�#�!�O�")�*A�z�R[�G\�G\�"]�"]�"]�
=�
=������U���,�,�	��&�&�	�7�';�<�<�<�<�� � �� �.�.�.�#2�D� ��#�#rb�
number_of_topc�b�	|�|��|dz
S#t$rYdSwxYwr_)rN�
IndexError)r�rOr/s   rcr�z5CloudlinuxSummary._get_top_package_by_number_of_userssI��	��1�1�2B�C�C�M�TU�DU�V�V���	�	�	��4�4�	���s� �
.�.c�r�t|��\}}|s"|�t|����|S)z%
        Parse CLI arguments
        )rRr�r3)r�rvr(r-s    rcrmzCloudlinuxSummary._parse_args�s>��5�T�:�:�����	7�� � ���!5�!5�6�6�6��rbr#rr�r-�	exit_coderHc��|tj��|d�}|�||d<t|d��tj|��dS)z?
        Print data in default format for web and exit
        )r�r%r-N�statistic_enabledT)rr2r;r<)r�r-rSrHr�s     rcr=z(CloudlinuxSummary._print_result_and_exit�sP��$�$�)�+�+�t�L�L���+�+?�G�'�(���$�'�'�'��������rbrQr�r/c��|�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
        r%TN)r�rr2r;r<)r�r/s  rcr�z!CloudlinuxSummary._error_and_exit�sG��	����T�Y�[�[�1�2�2�2���$�'�'�'��������rbc���tj�d��rHtjddgdtjtjd���}t
j|j��SdS)zD
        Return mod_lsapi info from switch_mod_lsapi script
        r�z--statTF�r�r�r_r9N)	r�r�r�rCrDrer�r�r��rs rcr�z$CloudlinuxSummary.get_raw_lsapi_info�sg��
�7�>�>�5�6�6�	(���,�h�7��!��!������A��:�a�h�'�'�'�	(�	(rbc�d�d}t��r|dz
}tj�|��r{t	j|dgdtjtjd���}tj|j	���
d��}d�|���D��}|Sd	S)
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-getTFrXrc�4�i|]\}}|t|����Sra)r�)r��krHs   rcrIz9CloudlinuxSummary._get_wmt_api_config.<locals>.<dictcomp>�s$��%[�%[�%[�D�A�q�a��Q���%[�%[�%[rbN)rr�r�r�rCrDrer�r�r�r�r�)r�r�wmt_api_config_summarys   rcr�z%CloudlinuxSummary._get_wmt_api_config�s���B�����	��w��G�
�7�>�>�'�"�"�	*����.�)��Z�_�U_�Ud�lq����A�&*�Z���%9�%9�%=�%=�h�%G�%G�"�%[�%[�<R�<X�<X�<Z�<Z�%[�%[�%[�"�)�)�	*�	*rbc�@�tj�d��S)Nz/etc/cloudlinux-edition-solo�r�r�r�rarbrcr|z(CloudlinuxSummary._is_solo_marker_exists�s���w�~�~�<�=�=�=rbc�@�tj�d��S)Nz/etc/cloudlinux-edition-adminr_rarbrcr}z)CloudlinuxSummary._is_admin_marker_exists�s���w�~�~�=�>�>�>rbc�@�tj�d��S)Nz/etc/cloudlinux-containerr_rarbrcr~z-CloudlinuxSummary._is_container_marker_exists�s���w�~�~�9�:�:�:rbc��tj�d��r3tjddgddd���}tj|j��SdS)zL
        Return statistics from cloudlinux-ssa-manager get-stat API
        z /usr/sbin/cloudlinux-ssa-manager�get-statTF�r�r�r9N�r�r�r�rCrDr�r�r�rYs rcr8zCloudlinuxSummary.get_ssa_stats�s_��
�7�>�>�<�=�=�	(���3�Z�@�t�\`�hm����A��:�a�h�'�'�'�		(�	(rbc���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�'rQzHAn upgrade inhibitor detected\|Workflow interrupted due to the FailPhasez'Starting stage After of phase FirstBootT)rONrz
Great SUCCESS)r�r�)
r�r�r��getmtimer�r�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              rcr�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��� !��'5�L]�^�^���rbr�c���d}t||��}|���sdS|�d������}|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/parametersrkr�r��YrQ�NrzUnable to interpret "z" kmodlve parameter value: "�")r
r��	read_textr��RuntimeError)r��
params_dir�
param_file�param_values    rcrz*CloudlinuxSummary._get_kmodlve_param_value
s���6�
��*�j�1�1�
�� � �"�"�	��2� �*�*�G�*�<�<�B�B�D�D���#����1��#����1��m�:�m�m�_j�m�m�m�n�n�nrbc���d}tj�|��rFtj|dgddd���}tj|j���d��SdS)�E
        Return statistics from cl-smart-advice counters API
        z/usr/sbin/cl-smart-advice�countersTFrdr-N)	r�r�r�rCrDr�r�r�r���utilrs  rc�get_smart_advice_statsz(CloudlinuxSummary.get_smart_advice_stats3
sg��
+��
�7�>�>�$���	4����j�1��T�Y^�_�_�_�A��:�a�h�'�'�+�+�F�3�3�3�	4�	4rbc�"�ddd�}td���sy|j�|jd��\}}|�T	|d|dd�S#t$r5}t
�dt|��|��|cYd}~Sd}~wwxYw|S)	z=
        Construct dict with Smart Advice statistics
        N)�smart_advice_total�smart_advice_appliedT)�skip_marker_checkz!Can't get Smart Advice statisticsr��appliedzAUnexpected json response from server, field %s is missing in "%s")rr~r�r�r�r�rtr�)r�r�r#�sa_statsr�s     rcr�z.CloudlinuxSummary._get_smart_advice_statistics=
s���)-�d�K�K��
$�d�;�;�;�	"� $�� =� =��+�3�!�!��G�X��#�"�2:�7�2C�]e�fo�]p�q�q�q���"�"�"��(�(�[�]`�ab�]c�]c�em����"�M�M�M�M�M�M�����	"����
�
s�A
�
B�*B�B�Bc�(�i}tj�d���r�tddd���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dkr8|�	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��rStddd���5}|����
��|d<ddd��n#1swxYwY|S)zP
        Return statistics by parsing /var/lib/apache2nginx/server.json
        z!/var/lib/apache2nginx/server.jsonr�r�r��total_websitesc�<�g|]}|�d���|��S)�proxy_reasonrr�s  rcr�z<CloudlinuxSummary.get_apache2nginx_stats.<locals>.<listcomp>d
s)��H�H�H��!�%�%��2G�2G�H�1�H�H�Hrb�total_proxy_passc�*�g|]}|ddk�|��S)r��	directiverar�s  rcr�z<CloudlinuxSummary.get_apache2nginx_stats.<locals>.<listcomp>i
s)��8p�8p�8p�q�q�Q_�O`�do�Oo�Oo��Oo�Oo�Oorb�proxy_pass_due_directive�failing_directives�failing_handlersr�r��
proxy_detailsrc�*�g|]}|ddk�|��S)r��testrar�s  rcr�z<CloudlinuxSummary.get_apache2nginx_stats.<locals>.<listcomp>z
s(��3f�3f�3f�!�!�N�J[�_e�Je�Je�A�Je�Je�Jerb�proxy_pass_due_testc�*�g|]}|ddk�|��S)r��forcedrar�s  rcr�z<CloudlinuxSummary.get_apache2nginx_stats.<locals>.<listcomp>|
s(��5j�5j�5j�A�A�n�L]�ai�Li�Li�a�Li�Li�Lirb�proxy_pass_due_forcedc�*�g|]}|ddk�|��S)r�rrar�s  rcr�z<CloudlinuxSummary.get_apache2nginx_stats.<locals>.<listcomp>~
s(��6l�6l�6l�Q�Q�~�M^�bk�Mk�Mk�q�Mk�Mk�Mkrb�proxy_pass_due_handlerc�*�g|]}|ddk�|��S)r��includesrar�s  rcr�z<CloudlinuxSummary.get_apache2nginx_stats.<locals>.<listcomp>�
s)��7n�7n�7n�a�a�P^�N_�cm�Nm�Nm��Nm�Nm�Nmrb�proxy_pass_due_includesNz/var/lib/apache2nginx/staterz)r�r�r�r�r��loadr�r'rtr�r�rr�r�)r�r�r-�websites�proxiedr��failing_directive�failing_handlers        rcr�z(CloudlinuxSummary.get_apache2nginx_statsU
sE��
��
�7�>�>�=�>�>�%	p��9�3��Q�Q�Q�$
p�UV��y��|�|��+.�d�)�)��&�'�����
�
�.�.��I�H�h�H�H�H��,/��L�L��(�)�58�8p�8p�G�8p�8p�8p�4q�4q��0�1�.0��*�+�,.��(�)� �Q�Q�A���(�K�7�7�,-�E�E�/�,B�,B�)�,�S�!�"6�7�>�>�q��?Q�R�R�R���>�*�i�7�7�*+�%�%��*@�*@��*�Q�!�"4�5�<�<�Q��=O�P�P�P��.2�3�u�=Q�7R�3S�3S�.T�.T��*�+�,0��U�;M�5N�1O�1O�,P�,P��(�)�/2�3f�3f�w�3f�3f�3f�/g�/g��+�,�14�5j�5j��5j�5j�5j�1k�1k��-�.�25�6l�6l�'�6l�6l�6l�2m�2m��.�/�36�7n�7n�7�7n�7n�7n�3o�3o��/�0�I$
p�$
p�$
p�$
p�$
p�$
p�$
p�$
p�$
p�$
p�$
p����$
p�$
p�$
p�$
p�N�7�>�>�7�8�8�	2��3�S�7�K�K�K�
2�q�!"�������!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�|��r3tj|dgddd���}tj|j��SdS)r�z/usr/bin/clwpos-adminrcTFrdNrer�s  rcr&z CloudlinuxSummary.get_wpos_stats�
sd��
'��
�7�>�>�$���	(����z�"��#��	���A��:�a�h�'�'�'�	(�	(rb)rlN)r#NrN)rQ)�rsr�r�r�r.�	itertools�compressrrrr�r�r�r�r�r@rr��staticmethodr��propertyr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrFr]r`rrrhrDrurr
r�r?r�r�r~r>r�r�r�r�r�r�r�rrrrrr.r5rOr\r�r�r�r�r�r�r�rr�rr
r�rr�rr�r�rrr9rTrXr[r'rbrirlrrorqrsrvrxrPr�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r
rrr+r1r:rErLrKrSr�r�r�r�r�r�r�r�r�r�r.r1r[r$�classmethodrJrKrH�tuplerNr�rm�object�typing�NoReturnr=r�r�r�r|r}r~r8r�rr�r�r�r&rarbrcrwrw�s�������<��7��"�	�"�$�$�$�,�E�,�W�-D�E�E�,�E�,�W�-B�C�C�,�E�,�W�-D�E�E�	
���I�B�K�F��K�L�#�#�#��@�@��\�@�����X����3�����X���8�8��\�8��@�@��\�@�����\��
-�$�-�-�-�-�^�	$�	$��X�	$�
�
�
�����
��
�
�
��\�
��;�;��\�;��@�S�@�S�@�@�@��\�@�:	�	�	�5�5�5�(�$�$��\�$�@�@�@������\��L�L�L�`����\��6�
�
��\�
���t�C��H�~��$�����\��:+#�+#�+#�Z4�4�4�0�
:��
:�V�
:��
:�
:�
:��\�
:�
��V�S�[�8I�
�PV�
�ei�
�nr�
�
�
�
����:� � ��\� �D�������!��!�!�!��\�!�E�E�E�E�81
�1
�1
�1
�f����\��<����\��*���(�?�?��\�?�"
�
�
�
�B	P��#��	P�	P�	P�	P�'�x��}�'�'�'�'���h�s�m�����\��;<�;<�;<�;<�z>
�@Q�>
�VZ�>
�>
�>
�>
�@
�>O�
�TX�
�
�
�
�>X�>O�X�TX�X�X�X�X�v=�=�=�=�K@�K@�K@�K@�Z
�
�
�
4
�4
�4
�l
�
�
�*<�<�<��+�c�+�T�+�+�+��\�+�P��d�4�j�$�t�*�d�3�PS�8�n�.T�(U�P�P�P�P�B:��s�3�x��S��7I�1J�:�:�:�:�:.��.�"%�.�<@��c��N�.�	
�c�5��s��#�#�	$�.�.�.�.�`$!�#�$!�#�$!�$!�$!�$!�L��Y�t����G�G����\�G�,<:�<:�<:�<:�|KC�KC�KC�KC�Z�	7��	7�QT�	7�Ya�be�Yf�	7�	7�	7��\�	7��	5�s�	5�S�	5�U]�^a�Ub�	5�	5�	5��\�	5��\��\�#�\�\�\��\�\��
"�t�
"��
"�
"�
"��\�
"��
"�T�
"�c�
"�
"�
"��\�
"��
 �D�
 �W�
 �
 �
 ��\�
 �"�d�"�s�"�"�"�"��
�t�
��
�
�
��\�
��
�T�
�c�
�
�
��\�
�&��&�RV�&�&�&�&��l�t�l�C�l�TX�Y\�T]�l�l�l��\�l���s��t�����\��t�t�t�t�l�!�D�!�!�!��\�!�&����2����\��
�
�
��#�#��\�#��/�/��\�/��7�7��\�7���$�����\���
"�D�
"�
"�
"��\�
"���s�����\����3�����\�� ����\��]
�]
�]
�~

�

�

�A�V�A���
�A�A�A�A�+
�+
�+
�Z���(
�(
�(
�T
�
�
�*�$�4�$�$�$��\�$�L
�
�
�@l�l�l� 0!�E�#�s�C�-�<P�0!�0!�0!�0!�d�&��c�3�h��&�&�&��\�&�@)*�)*�)*�VFC�FC�FC�PT�T�T�T�.
�
�
�
�"(�(�(�(�8*�*�*�6+-�+-�+-�Z
�
�
�
�
�
�0i@�i@�i@�V����\��$*�*�*�&=���
�=�=�=�=�=�H�S�M�=�=�=�=��!�!��[�!� �!�!��\�!��'�'��\�'�$�:K�$�PT�UZ�[^�`c�[c�Ud�fi�Ui�Pj�$�$�$�$�(�!$��/��4<�U�3��8�_�4M���������#�"&��04�	�����4�-����#'��+�	�:@��	����\�������3��x��~�����\���(����(�(�(��\�(��*�*��\�*�(�>�>��\�>��?�?��\�?��;�;��\�;��(�8�D�>�(�(�(��\�(��6�T�6�6�6��\�6�p�o�S�o�S�o�o�o��\�o�&�4�H�T�N�4�4�4��\�4��d�����0�1�H�T�N�1�1�1��\�1�f�(�H�T�N�(�(�(��\�(�(�(rbrwc�T�t��}|j���|Sr`)r9r�
link_xml_node)r�s rcr�r��
s$��
�X�X�F�
�O�!�!�#�#�#��Mrb)�r`rr�r�rqr�r�r�r�r�r�rCr;rr��collectionsrr�	functoolsrrr�multiprocessingr�operatorr	�pathlibr
�socketrrr
rrrrrr�cldetectlibr�rSr�r��cl_proc_hidepidr�clcommonr�clcommon.clwpos_librrr�clcommon.constr�clcommon.cpapirr�clcommon.libr�clcommon.lib.cleditionrrr�clcommon.lib.cmt_utilsr �clcommon.lib.constsr!�clcommon.sysctlr"�clcommon.utilsr#r$r%r&r'r(r)r*r+r,r-�clconfigr.r/r0�	cldiaglibr1�	cli_utilsr2r3�cllimitslib_v2r4r5�
clveconfigr6�clwizard.modulesr7�	lve_utilsr8rz�lveapir9�vendors_api.configr:r;�clsummary.utilsr<r=r>r?r@rArBrCrDrErFrGrHrIrJrKrL�clsummary.hardware_statisticsrMrNrO�!clsummary.rpm_packages_statisticsrP�	arg_parserR�storagerS�clselect.clselectctlrT�clselect.clselectstatisticsrUrVrWrXrYrZ�clselector.selectorlibr[�
lvemanagerr\r�r�ImportError�clflagsr^r�rrr�rrQr�r�r�r�r�r�r�r�rurwr�rarbrc�<module>r�s���������������������������	�	�	�	�����
�
�
�
�	�	�	�	�
�
�
�
�����
�
�
�
�����
�
�
�
�,�,�,�,�,�,�,�,�(�(�(�(�(�(�(�(�������%�%�%�%�%�%�������������������L�L�L�L�L�L�L�L�L�L�L�L�L�L�L�L�L�L�L�L���������
�
�
�
�����:�:�:�:�:�:�����������������
#�"�"�"�"�"�I�I�I�I�I�I�I�I�&�&�&�&�&�&�����������
:�9�9�9�9�9�?�?�?�?�?�?�&�&�&�&�&�&���������������������������O�N�N�N�N�N�N�N�N�N�3�3�3�3�3�3�6�6�6�6�6�6�6�6�6�6�6�6�6�6�6�6�#�#�#�#�#�#�(�(�(�(�(�(�:�:�:�:�:�:�������=�=�=�=�=�=�=�=���������������������������������������&����������
D�C�C�C�C�C�4�4�4�4�4�4�#�#�#�#�#�#�"�8�8�8�8�8�8�����������������=�<�<�<�<�<�@�@�@�@�@�@�@�@�@�@�@�@�@���
"�
"�
"�2��2��1��-��1��1��0�� ��!��!����
"�����'�'�'�'�'�'�'���������������-��
�W�
�3�
4�
4�
����	��
�#����
����
��U��U��U�U�U�U�u3(�u3(�u3(�u3(�u3(�u3(�u3(�u3(�pg����s$�2(F�F7�6F7�;G�G
�G