HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/clsummary/__pycache__/summary.cpython-37.pyc
B

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

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

               should be used with log_exception equal True
        z%s. Exception: "%s"N)�DEFAULT_RESULTS�	Exception�
app_logger�	exception)�self�func�type_of_result�log_message�
log_exceptionZdefault_result�result�errrararb�run_safe_or_log_errors�s

z%StatisticsDict.run_safe_or_log_errorscCs|j||||d�}|||<dS)z�
        Method which call `run_safe_or_log_errors` and save result from it
        :param log_exception: True - exception will been logged, False - exception won't been logged
               See method `run_safe_or_log_errors`
        )ryN)r|)rurvrwZname_of_metricrxryrzrararb�
format_metric�szStatisticsDict.format_metricN)T)T)�__name__�
__module__�__qualname__�__doc__rqr|r}rarararbrh�s
&rh)�	site_dict�returncCsttdd�|d����S)zB
    Checks if wordpress site has at least one enabled module
    cSs|dS)Nrfra)�modulerararbrc�rdz*site_has_enabled_modules.<locals>.<lambda>�modules)�any�map�values)r�rararb�site_has_enabled_modules�sr�c@s�eZdZdZdZe�dddge�e	j
�e�e	j�e�e	j�g�Z
dZdZdZd	d
�Zedd��Zed
d��Zedd��Zedd��Zedd��Zedd��Zdd�Zedd��Zdd�Zdd�Zedd ��Zed!d"��Zed#d$��Z d%d&�Z!d'd(�Z"ed)d*��Z#d+d,�Z$ed-d.�d/d0��Z%d1d2�Z&ed3d4��Z'ed5d6��Z(ee)e*e*fe+d7�d8d9��Z,d:d;�Z-d<d=�Z.ee/e0d-d>�d?d@��Z1e)e0e/fe0e+d-dA�dBdC�Z2dDdE�Z3edFdG��Z4dHdI�Z5dJdK�Z6edLdM��Z7dNdO�Z8d-d.�dPdQ�Z9edRdS��Z:edTdU��Z;dVdW�Z<edXdY��Z=dZd[�Z>d\d]�Z?d^d_�Z@ed`da��ZAdbdc�ZBddde�ZCdfdg�ZDdhdi�ZEdjdk�ZFdldm�ZGdndo�ZHdpdq�ZIdrds�ZJdtdu�ZKeeLeMdv�dwdx��ZNeOeMePeMePe)eLe/ffd.�dydz�ZQeOeReLeReLfd.�d{d|�ZSeLeLe)eLeLfe)eLeTeMeLffd}�d~d�ZUeLeLd��d�d��ZVeeWd-d��d�d����ZXd�d��ZYd�d��ZZed�d���Z[ed�d���Z\ed�d���Z]ed�d���Z^ed�d���Z_ed�d���Z`d�d��Zaed�d���Zbed�d���Zcd�d��Zded�d���Zeed�d���Zfd�d��Zged�d���Zhd�d��Zied�d���Zjd�d��Zked�d���Zled�d���Zmed�d���Znee+d.�d�d���Zoee+d.�d�d���Zpee/d.�d�d���ZqeeLd.�d�d���Zred�d���Zsd�d��Ztd�d��Zue0eve/d��d�d„Zwd�dĄZxd�dƄZyd�dȄZzd�dʄZ{ee)d.�d�d̄�Z|d�d΄Z}d�dЄZ~eOe/e/e/fd.�d�d҄ZeeOe/eLfd.�d�dԄ�Z�d�dքZ�d�d؄Z�d�dڄZ�d�d܄Z�d�dބZ�d�d�Z�d�d�Z�d�d�Z�d�d�Z�ed�d��Z�d�d�Z�e�d�d��Z�ed�d��Z�ed�d��Z�d�d�Z�d�d�Z�d�d��Z�e�dd�d���Z�e�dd�d���Z�ed�d���Z�e�d�d��Z�e�d�d��Z�e�d�d��Z�e�d�d��Z�e�d�d	��Z�e�d
�d��Z�eeLe/�d��d
�d��Z�e�d�d��Z��d�d�Z�e�d�d��Z�e�d�d��Z�d-S(�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.jsoncCs>t�|_d|_t�|_d|_d|_|��|_d|_	t
�|_dS)N)�dict�_opts�_security_tokenrh�
statistics�_lvpmap�
_system_id�_is_process_not_limited�is_process_not_limited�packages_by_lenr'�sysctl)rurararb�__init__	s
zCloudlinuxSummary.__init__cCs,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)Zis_running_by_niceZis_running_in_lverararbr�sz)CloudlinuxSummary._is_process_not_limitedcCs|jdkrt�|_|jS)z.
        Load lvpmap only when needed
        N)r��_get_lvpmap)rurararb�lvpmaps
zCloudlinuxSummary.lvpmapcCs|jdkrtd�|_|jS)N�	system_id)r�r)rurararbr�'s

zCloudlinuxSummary.system_idcCst�r
dSdS)NZubuntuZ	rhel_like)rrarararb�
_get_platform/szCloudlinuxSummary._get_platformcCst�r
tStS)N)r�ENABLED�DISABLEDrarararb�_detect_secureboot3sz$CloudlinuxSummary._detect_securebootcs,tjtj�d��fdd�td�D��}|S)N�c3s|]}t���VqdS)N)�randomZchoice)�.0�_)�range_for_random_choicerarb�	<genexpr>:sz=CloudlinuxSummary._generate_security_token.<locals>.<genexpr>�@)�stringZ
ascii_lettersZdigits�joinr)�security_tokenra)r�rb�_generate_security_token7sz*CloudlinuxSummary._generate_security_tokenc
Cs�i}|jdkr*d}t�|�|�d|i�d|j}t�|�|j|jd�}d}ytj|j|dd�}WnDtj	k
r�}z$t
|�}t�|�|�d|i�Wdd}~XYnX|js�d�|j
|j�}t�|�|�d|i�t�d�y2|��d}t|dt��r|d�|���Wn~ttfk
�rLd	}t�|�|�d|i�YnTtk
�r�}z*t�d
t
|�|j�|�ddti�Wdd}~XYnXt�d�|S)
NzSecurity token is emptyrzz!Getting statistics from server %s)r�r��<)�params�timeoutz*Server answer is: HTTP code {}; Reason: {}z!Received response from the serverz Can't parse api response to jsonz=Invalid json response from server, field %s not found in "%s"z1Invalid response from server. See %s for details.z,SUCCESS: received statistics from the server)r�rs�error�_error_and_exit�SUMMARY_URL�infor��requestsr��RequestExceptionri�ok�format�status_code�reason�json�
isinstancer��update�_get_smart_advice_statistics�	TypeError�
ValueError�KeyError�text�LOG_FILE)ruZ	stat_data�messager��response�erararb�_get_remote_data=sP





 



z"CloudlinuxSummary._get_remote_datacCsL|jdk	r|jStj�|j�r*|��|_n|��}|�|�r@|nd|_|jS)N)r�r��path�isfile�DASHBOARD_CERTIFICATE�_read_token_from_filer��_write_token_to_file)ru�tokenrararbr�ts
z CloudlinuxSummary.security_tokenc
Cspy4t|jd��}|�|�WdQRXt�|jd�dSttfk
rj}zt�dt	|��dSd}~XYnXdS)z�
        Write security token to file and return success/fail status
        :param token: generated security token
        :return: T/F status
        �wNi�Tz,Error while writing secure token to file: %sF)
�openr��writer��chmod�IOError�OSErrorrsr�ri)rur��fr�rararbr��sz&CloudlinuxSummary._write_token_to_filec
Csby&t|j��}|����pdSQRXWn6ttfk
r\}zt�dt|��dSd}~XYnXdS)Nz.Error while reading file with secure token: %s)	r�r��read�stripr�r�rsr�ri)rur�r�rararbr��sz'CloudlinuxSummary._read_token_from_filecCstjtjdddd�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
        ZCUSTOM_GETPACKAGE_SCRIPT�=F)�	file_name�
param_nameZ	separatorZdefault_val)�detectZget_boolean_paramZCL_CONFIG_FILErarararb�_detect_old_lve_integration�s
	z-CloudlinuxSummary._detect_old_lve_integrationcCstj�d�S)zO
        Detects presence/absence of lsapi
        :return: True/False
        z/usr/bin/switch_mod_lsapi)r�r��existsrarararb�_is_lsapi_present�sz#CloudlinuxSummary._is_lsapi_presentcCs�|dkrt�sPtSn<|dkr*t�r&tStS|dkr>t�sPtSn|dkrPt�sPtSt|�}|dkrdtS|dkr�y|��dr~tStSt	k
r�tSXn|dkr�|�
�r�tStStd�|���dS)	zP
        Get selector status for nodejs, python, ruby and php selectors
        r�r�r��phpN)r�r�Zselector_enabledzUnknown interpreter: {})
rA�
NOT_INSTALLEDrBr�rCrDr\Zget_selector_statusr�r�Zphp_selector_is_disabledr�r�)�interpreter�librararb�_get_status_of_selector�s*z)CloudlinuxSummary._get_status_of_selectorc
Cs�yt�|���}|Stjk
rX}z&t�dt|��|�dt|�i�Wdd}~XYn6tt	fk
r�}zt�dt|��dSd}~XYnXdS)Nz3Request exception while getting remote settings: %srzz'Error while parsing remote settings: %s)
r�r�r�r�rsr�rir�r�r�)ruZsettings_url�settingsr�rararb�_get_remote_settings�s"z&CloudlinuxSummary._get_remote_settingsc
Cs�|j�d�rdSttj�d��}|r(dS|�|j�}|dkr@dSy"|dd}|ddob|�|�Stk
r�}z&t	�
d	t|��|�d
t|�i�Wdd}~XYnXdS)z-
        Return cl-statistics status
        z--force-collectTZCL_TEST_SYSTEMNFz
cl-statisticsz
rollout-grouprfz4Error occurred while trying to get rollout group: %srz)
r�r�r�r�r�r��SETTINGS_URL�
_match_serverr�rsr�rir�)ruZis_test_environmentr�Z
rollout_groupr�rararb�_is_statistics_enabled�sz(CloudlinuxSummary._is_statistics_enabledcCs
t|d�S)N�)rj)�hash_serverrararb�
_to_number�szCloudlinuxSummary._to_numbercCs@|jdkrdSt�|j�����dd�}|�|�d|dkS)NT��r)r��hashlibZsha256�encodeZ	hexdigestr�)ruZurl_numr�rararbr��s
zCloudlinuxSummary._match_serverN)r�cCs*d}x |r$t�s$|d8}t�d�qWdS)zC
        Wait for running background process of cl-summary
        �2r1g�������?N)rG�time�sleep)Zretriesrararb�_wait_for_background_process�sz.CloudlinuxSummary._wait_for_background_processcCs|jds|jdr>t|jd�t��dd�}t|d�dS|jdsR|jdr|t|jd�t��dd�}t|d�dS|jdr�t�r�d	nd
}t��|dd�}|�dt�i�t|d�td
�|j�	d�r�|�
�}|j|t�d�|j�	d��rft
��s |j�	d��s |jddid
d�|��|j�	d��rV|j|j|jdd�t�d�nt|jd�dS|���s�tjdt��d�}t|�|jddid
d�|j�	d��r2|j�	d��s�t��s�tjdt��d�}t|�|jddid
d�|jdk�r2d}t�|�tjdtt��d�}t|�|�d|i�|j�	d ��r�t��rZt��d	dd�}n<ttjt��dd!��tjd"dd#d$�|��t��dd�}t|d�td
�|jd�r|j �r�tdd%��r�t��d	dd�}t|d�td
�nttjt��dd!��dS)&N�enable�disable�success)�	timestamprzTz
enable-rpmzdisable-rpm�statusZ
collectingZready)r�r�rzZsending_statusrz
get-remote)�datar;zrpm-packagesz--force-collectrzz\Sending RPM statistics is disabled by admin. Use --force-collect to ignore admin`s settings.)�
error_codez--sendF)�summary�url�save_statuszRPM statistics sentzkStatistics collection is disabled globally. Please, try again later or contact support if it happens again.)rzr�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 %s for details or contact support.z--async)rzr�r�z9/usr/sbin/cloudlinux-summary --send --json &> /dev/null &z	/bin/bash)�shell�
executable)�acquire_lock)!r�r=r�r+r>rGr�rH�exitr�r��_print_result_and_exitr;r<r��_get_rpm_packages_summary� _send_statistics_and_save_statusr��RPM_PACKAGES_URLrsr�r�r@�FAILEDr?r�r�r�ZIN_PROGRESS�
subprocess�runr�r�)rur�r�rz�status_dictr�rararb�&_actions_before_run_process_as_limiteds�













z8CloudlinuxSummary._actions_before_run_process_as_limitedc	Csjtjdddd�}t�|��F}|�dt|�g�tjddt|�dg|ttj	d	t
�tj�d
�d�SQRXdS)
z�
        Run same command in lve and set environ RUNNING_IN_LVE=1
        in order to check it in child process.
        :return:
        �ri@)Zls_cpuZls_cpusZ
ls_memory_phyz--lve-idz/bin/lve_suwrapperz-nz/usr/sbin/cloudlinux-summary�1)r�ZCPU_DATA)�envN)
�	lvectllibZmake_liblve_settingsZ
temporary_lve�extendrir	�callr�r�r�r��dumpsZCPUINFO_DATA)�argsr�Zlve_idrararb�_run_self_in_lve�s
z"CloudlinuxSummary._run_self_in_lvecCs$tjddddg|ttjdd�d�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/nicez-nZ19z/usr/sbin/cloudlinux-summaryr)r�)r)r	rr�r�r�)rrararb�_run_self_by_nice�sz#CloudlinuxSummary._run_self_by_nice)�optsr�cs8t�fdd�dD��rdSt�fdd�dD��r4dSdS)zK
        Check that passed command should run as unlimited process
        c3s|]}�|VqdS)Nra)r��option)rrarbr��szECloudlinuxSummary._should_run_as_unlimited_process.<locals>.<genexpr>)zrpm-packagesr�z
get-remoter�r�z
enable-rpmzdisable-rpmTc3s|]}�|VqdS)Nra)r�r)rrarbr��s)z--sendz--asyncz--jsonz--force-collectF)r�)rra)rrb� _should_run_as_unlimited_process�s

z2CloudlinuxSummary._should_run_as_unlimited_processc
Cs|�|�|_|jr�|��|�|j�r0td�n�ttj�sN|�	|�}t|�nly|�
|�}t|�WnTtjk
r�}z4d|}t
|�t�t�}|j|dd�td�Wdd}~XYnXnH|�|j�r�d}t��|d�}tj||jd�t|d�td	�|��dS)
Nrz$failed to run task in lve, error: %sT)�exc_info���z|You shouldn't use env var "RUNNING_IN_LVE" or "RUNNING_BY_NICE" for run of any command except collection of main statistics.)r�rz)Zextrar1)�_parse_argsr�r�rrrrr�LVErrrZ
PyLveError�print�logging�	getLoggerr~rtr�rsr�r+�run_get_summary)ru�argv�rcr�Z	error_msg�logZerr_msgr�rararbr
�s2






zCloudlinuxSummary.runcCs�t��}|��t��|}||jd<|jdrJ|j�t|j|�ddd�|j�d�rv|j|j|j	dd�t
�d	�nt|jd�dS)
NZcl_summary_execution_timez--lve-idriZcl_summary_max_mem_usedz,Can't get memory usage by cloudlinux-summaryz--sendT)r�r�r�zMain statistics sent)
r��_get_summaryr�r�r}r�_get_max_memoryr�rr�rsr�r+)ruZ
start_time�running_timerararbr!�s"


z!CloudlinuxSummary.run_get_summary)r��summary_resultr�cCs2tj|d�}|dkr&||d<tj|d<t|�dS)z@
        Save status of sending statistics to json file
        )rzr�r�r�rzN)r@�SUCCESSrr?)r�r(rrararb�_save_status
s

zCloudlinuxSummary._save_status)r�r�r�r�cCsJtt���}||d<|j||d�}||d�}t|d�|rF|�||�dS)zH
        Send statistics data to server and save status to file
        r�)r�)rzr�TN)rjr��_send_statisticsr+r*)rur�r�r�r�Zs_resultrzrararbrs

z2CloudlinuxSummary._send_statistics_and_save_statusc	
Cs�|d}|dkrdSdddt|jd�ddd	d
�tt�|���g}yt|dd�\}}}Wn.tk
r�}zt�	d
|�dSd}~XYnX|dkr�t
�|�}ytdd�|dD��St
tfk
r�dSXt�d||�dS)Nr�r1z/usr/sbin/lveinfoz--jsonz--idz--lve-idz--show-columns�mPMemz--periodz{}mT)�return_full_outputz Unable to run lveinfo, error: %srcSsg|]}|d�qS)r,ra)r��xrararb�
<listcomp>7sz5CloudlinuxSummary._get_max_memory.<locals>.<listcomp>r�z-lveinfo failed with exit code: %i, output: %s)rir�r�rj�mathZceilrrrs�warningr��loads�maxr�r�r�)	rur'Ztime_minutes�cmdr#�json_strr�r�Zparsed_datarararbr&&s*
z!CloudlinuxSummary._get_max_memorycCs�d}y�d|}t�|�t�d�}xbtd�D]R}ytj||dd�}Wn6tjk
rz}z|}t�d|�Wdd}~XYq,XPq,W|�|j	d	kr�t�d
�nd�
|j	|j�}t�|�Wn6tjk
r�}zt|�}t�
|�Wdd}~XYnX|S)z�
        Sends statistics to server
        :param data: Statistics data dict
        :return: string - message for JSON 'result' key
        r�zSending statictics to server %sz*Unknown exception while sending statistics�r�)r�r��N��zSending statictics OKz*Server answer is: HTTP code {}; Reason: {})rsr�r�r�rZpost�ConnectionErrorr�r�r�r�r�rir�)r�r�Zout_messager�Zexpected_err�ir�r{rararbr+>s0
 
z"CloudlinuxSummary._send_statisticscCs&dt��d�}|��|j�|�|S)Nr1)�versionr�)r��_prepare_cl_normal_statisticsr�r�)rurzrararbr%fs
zCloudlinuxSummary._get_summarycCs&dt��d�}|��|j�|�|S)Nr1)r;r�)r��'_fill_dict_with_rpm_packages_statisticsr�r�)rurzrararbrns
z+CloudlinuxSummary._get_rpm_packages_summarycCst��tjS)z/
         Get version of control panel
        )r�ZgetCPZ
CP_VERSIONrarararb�_get_panel_versionvsz$CloudlinuxSummary._get_panel_versioncCs`|j�tjdd�}|dk	rR||jd<|j�dd�ddd�|j�d	d�dd
d�n
t|jd
<dS)zN
        Fill dict with statistics by statistics about MySQL governor
        rizCan't get MySQL governor modeNZmysql_governor_modecSs
t���S)N)rZget_governor_versionrarararbrc�rdzCCloudlinuxSummary._fill_mysql_governor_statistics.<locals>.<lambda>Zmysql_governor_versionz Can't get MySQL governor versioncSst���dS)Nr)rZget_governor_statusrarararbrc�rdZmysql_governor_statuszCan't get MySQL governor status)r�r|r)Zget_gov_mode_operationr}r�)ruZmysql_gov_moderararb�_fill_mysql_governor_statistics�s"
z1CloudlinuxSummary._fill_mysql_governor_statisticscCs�|j�tjddd�|j�dd�ddd�|j�|jdd	d
�|j�|jddd�|j�td
dd�|j�dd�d
dd�t��tjkr�|j�|j	d
dd�|j�|j
d
dd�|j�td
dd�dS)zM
        Fill dict with statistics by statistics about control panel
        ri�control_panel_namezCan't get control panel namecSsdd�t����D�S)NcSsg|]\}}|r|�qSrara)r��nameZis_supportedrararbr/�szVCloudlinuxSummary._fill_control_panel_statistics.<locals>.<lambda>.<locals>.<listcomp>)rZget_supported_cl_features�itemsrarararbrc�rdzBCloudlinuxSummary._fill_control_panel_statistics.<locals>.<lambda>rlZsupported_cl_featuresz8Can't get list of supported cl features by control panelZcontrol_panel_versionzCan't get control panel versionZcontrol_panel_apachezCan't get control panel apacherjZ
nginx_runningzCan't get control panel nginxcSstt���S)N)�lenr�cpusersrarararbrc�rdZusers_totalzCan't get amount of usersZinstalled_via_plesk_extz8Can't determine if CL was installed from Plesk ExtensionZlogin_via_whmcs_in_usez)Can't determine if Login via WHMCS in userz Can't if that is WP2 environmentN)r�r}r��	getCPNamer>�_get_control_panel_apacher!r�
PLESK_NAME�_is_installed_via_plesk_ext�_is_login_via_whmcs_in_user)rurararb�_fill_control_panel_statistics�s\z0CloudlinuxSummary._fill_control_panel_statisticscCs�d}t��tjkr|Sdddg}tj|dddd�}t�|j�}d|kr�d|dkr�xP|ddD]@}|d	d
kr`d}t	|�
dd
�|�
dd
�|�
dd
�g�r�d}Pq`W|S)zA
        Determine whether the login method is via WHMCS
        rz/usr/local/cpanel/bin/whmapi1Z&get_available_authentication_providersz--output=jsonprettyT)�capture_outputr�Zcheckr�Z	providersZ
provider_nameZwhmcsrZwhostmgrd_enabledFZcpaneld_enabledZwebmaild_enabledr1)r�rEr�CPANEL_NAMEr	r
r�r2�stdoutr�r�)r��commandrzr�ZproviderrararbrI�s&

z,CloudlinuxSummary._is_login_via_whmcs_in_usecCsd}d}tj�|�rd}|S)aV
        cldeploy-plesk-ext.log is always created by cldeploy-precheck when it downloads cldeploy script,
        if it exists it means there was an attempt to launch a cldeploy from Plesk Extension.
        Since this function is in package lve-utils, which depends from lve, it means that current os is CloudLinux,
        therefore conversion was successful.
        Possible false positives:
            - if there was failed attempt to convert os from Plesk Ext, and then it was successfully converted after manual run of cldeploy, it will be considered as CLOS installed via Plesk extension
            - if user has CL already installed and goes to CLOS Plesk Ext and tries to run conversion from there
        Possible false negatives:
            - if /var/log/cldeploy-plesk-ext.log was deleted or renamed/archived (e.g. via logrotate)
        Fz/var/log/cldeploy-plesk-ext.logT)r�r�r�)rzZext_logrararbrH�s

z-CloudlinuxSummary._is_installed_via_plesk_extcCsPt�r(t��rd}qLt��r"d}qLd}n$|jddkrHt��rBdnd}nd}|S)	z�
        Wrapper to retrieve control panel Apache version:
        EA3 or EA4 for cPanel, native otherwise
        :return: EA3|EA4|native
        �	litespeedZ
openlitespeedZunknown_litespeedr@ZcPanelZEA4ZEA3�native)rr�Zdetect_enterprise_litespeedZdetect_open_litespeedr�Zis_ea4)rurzrararbrFsz+CloudlinuxSummary._get_control_panel_apachecCs8t��}|dkr|Stjttjtdtdti}|�|d�S)z�
        Wrapper to convert internal values from cagefs_statistics_config.get_cagefs_status function to values
         for statistics
        :return:
        NZEnabledZDisabledZUnknown)	r(Zget_cagefs_statusZCAGEFS_STATUS_NOT_INSTALLEDr�ZCAGEFS_STATUS_NOT_INITIALIZED�NOT_INITIALIZEDr�r�r�)�
cagefs_statusZcagefs_status_maprararb�_cagefs_status_wrapper$sz(CloudlinuxSummary._cagefs_status_wrappercCs~|j�|jddd�|jdttgkr2d|jd<n|j�tjddd�|j�ttjd�ddd	�|j�ttjd
�ddd�dS)
zF
        Fill dict with statistics by statistics about CageFS
        rirRzCan't get CageFS statusNZcagefs_user_modezCan't get CageFS user modeTZcagefs_enabled_quantityz/Can't get quantity of users with enabled CageFSFZcagefs_disabled_quantityz0Can't get quantity of users with disabled CageFS)	r�r}rSr�rQr(Zget_cagefs_user_moderZget_quantity)rurararb�_fill_cagefs_statistics6s,

z)CloudlinuxSummary._fill_cagefs_statisticscs^ytdd�|j��D��}Wntjk
r2dSXt|jj����t�fdd�|�	�D��S)zJ
        Get amount of end-users which belong to active resellers
        css|]\}}|dkr|VqdS)rNra)r�r��lvprararbr�^szLCloudlinuxSummary._get_amount_of_endusers_under_resellers.<locals>.<genexpr>Nc3s|]}|�kVqdS)Nra)r�Zlvp_id)�enabled_lvp_idrarbr�bs)
rr��
lve_lvp_pairsrrO�set�name_mapZid_list�sum�elements)ru�	lvp_countra)rVrb�'_get_amount_of_endusers_under_resellersXsz9CloudlinuxSummary._get_amount_of_endusers_under_resellerscCs@ytdd�|j��D��}Wntjk
r2dSXt|���S)z/
        Get total amount of end-users
        css|]\}}|dkr|VqdS)rNra)r�r�rUrararbr�jszBCloudlinuxSummary._get_total_amount_of_endusers.<locals>.<genexpr>N)rr�rWrrOrZr�)rur\rararb�_get_total_amount_of_endusersds
z/CloudlinuxSummary._get_total_amount_of_enduserscCs(ytt���Stjk
r"YnXdS)z)
        Get amount of resellers
        N)rCr�	resellersrOrarararb�_get_amount_of_resellersosz*CloudlinuxSummary._get_amount_of_resellerscs��j�tjjddd��j�tjjddd��j�tjjddd��j��fdd	�dd
d��j��jddd
��j��jddd��j��j	ddd��j��fdd	�ddd��jdrԈj�dd	�ddd�nd�jd<d�jd<d�jd<dS)zP
        Fill dict with statistics by varied statistics about resellers
        rjZ reseller_limits_supported_kernelz8Can't detect status of support reseller limits by kernelZ'reseller_limits_supported_control_panelz?Can't detect status of support reseller limits by control panelZreseller_limits_enabledz1Can't detect status of support of reseller limitscs���dS)Nr)�#get_users_and_resellers_with_faultsra)rurarbrc�rdz>CloudlinuxSummary._fill_resellers_statistics.<locals>.<lambda>Zusers_with_faultsz6Can't get amount of users with faults for the past 24hZresellers_totalz#Can't get total amount of resellersZ(resellers_endusers_under_reseller_limitsz>Can't get amount of end-users which belong to active resellersZresellers_endusers_totalz#Can't get total amount of end-userscs���dS)Nr1)rara)rurarbrc�rdZresellers_with_faultsz:Can't get amount of resellers with faults for the past 24hcSsttt����S)N)rCr`rZlvp_listrarararbrc�rdZresellers_activez$Can't get amount of active resellersN)
r�r}rZlveZis_lve10Zis_panel_supportedZreseller_limit_supportedr`r]r^)rura)rurb�_fill_resellers_statisticszsb




z,CloudlinuxSummary._fill_resellers_statisticscs|j�t|j�jtj�jtj�ddd�|j�t|j�jtj�ddd�|j��fdd�dd	d
�|j��fdd�ddd
�|j��fdd�ddd�|j��fdd�ddd�|j��fdd�ddd�|j�t|j	�jtj
�ddd�|j�t|j	�jtj�ddd�dS)zN
        Fill dict with statistics by statistics about default limits
        rjZdefault_limit_speedzCan't get default speed limitriZdefault_limit_cpu_origin_unitsz+Can't get cpu origin units of default limitcs�jtjS)N)�defaultsr.�ncpura)�xml_cfg_providerrarbrc�rdzCCloudlinuxSummary._fill_default_limits_statistics.<locals>.<lambda>Zdefault_limit_ncpuzCan't get default ncpu limitcs�jtjS)N)rcr.�iora)rerarbrc�rdZdefault_limit_iozCan't get default io limitcs�jtjS)N)rcr.�nprocra)rerarbrc�rdZdefault_limit_nproczCan't get default nproc limitcs�jtjS)N)rcr.�epra)rerarbrc�rdZdefault_limit_epzCan't get default ep limitcs�jtjS)N)rcr.�iopsra)rerarbrc�rdZdefault_limit_iopszCan't get default iops limitZdefault_limit_vmem_mbzCan't get default vmem limitZdefault_limit_pmem_mbzCan't get default pmem limitN)r�r}r�_cpu_limit_to_percentsrcr.�cpurd�_get_cpu_limit_units�_mempages_to_mb�vmem�pmem)rurera)rerb�_fill_default_limits_statistics�s`





z1CloudlinuxSummary._fill_default_limits_statisticscsR|j��fdd�ddd�|j��fdd�ddd�|j��fd	d�dd
d�dS)
z�
        Fill dict with statistics by other statistics about limits:
        packages_total, users_total, amount users/packages with custom limits
        cs
t�j�S)N)rC�packagesra)rerarbrcrdzACloudlinuxSummary._fill_other_limits_statistics.<locals>.<lambda>rjZpackages_totalz"Can't get total amount of packagescst����S)N)rCZget_packages_with_custom_limitsra)rerarbrc
rdZpackages_with_custom_limitsz/Can't get amount of packages with custom limitscst����S)N)rCZget_users_with_custom_limitsra)rerarbrcrdZusers_with_custom_limitsz,Can't get amount of users with custom limitsN)r�r})rurera)rerb�_fill_other_limits_statistics�s


z/CloudlinuxSummary._fill_other_limits_statisticscs��x�tdd�D�]�}�j�t�j||�dd|���dkr<P�jj�fdd�dd|d	|d
d��jj�fdd�d
d|d|d
d��jj��fdd�d
d|d|d
d��jj��fdd�dd|d|d
d��jj�fdd�d
d|d|d
d��jj�fdd�d
d|d|d
d��jj�fdd�d
d|d|d
d��jj�fdd�d
d |d!|d
d��jj�fd"d�d
d#|d$|d
d��jj��fd%d�d
d&|d'|d
d��jj��fd(d�d
d)|d*|d
d�qWdS)+zV
        Fill dict with statistics by statistics about top packages on server
        r1r7riz!Can't get top %s package by usersNcs
�djS)Nr1)rAra)�
top_resultrarbrc-rdzACloudlinuxSummary._fill_top_packages_statistics.<locals>.<lambda>ztop_%s_package_namez1Can't get package name of top %s package by usersF)rycst�d�S)Nr)rjra)rsrarbrc4rdrjztop_%s_package_users_numz4Can't get amount of users in top %s package by userscs$���djptj�djptj�S)Nr1)rj�limitsr/rkrdra)rursrarbrc<sztop_%s_package_limit_speedz0Can't get speed limit of top %s package by userscs���djptj�S)Nr1)rlrtr/rkra)rursrarbrcGsz%top_%s_package_limit_cpu_origin_unitsz>Can't get cpu origin units of limit of top %s package by userscs�djptjS)Nr1)rtr/rdra)rsrarbrcPrdztop_%s_package_limit_ncpuz/Can't get ncpu limit of top %s package by userscs�djptjS)Nr1)rtr/rfra)rsrarbrcWrdztop_%s_package_limit_ioz-Can't get io limit of top %s package by userscs�djptjS)Nr1)rtr/rgra)rsrarbrc^rdztop_%s_package_limit_nprocz0Can't get nproc limit of top %s package by userscs�djptjS)Nr1)rtr/rhra)rsrarbrcerdztop_%s_package_limit_epz-Can't get ep limit of top %s package by userscs�djptjS)Nr1)rtr/rira)rsrarbrclrdztop_%s_package_limit_iopsz/Can't get iops limit of top %s package by userscs���djptj�S)Nr1)rmrtr/rnra)rursrarbrcsrdztop_%s_package_limit_vmem_mbz/Can't get vmem limit of top %s package by userscs���djptj�S)Nr1)rmrtr/rora)rursrarbrc{rdztop_%s_package_limit_pmem_mbz/Can't get pmem limit of top %s package by users)rr�r|r�#_get_top_package_by_number_of_usersr})rurer:ra)rursrb�_fill_top_packages_statisticss�







z/CloudlinuxSummary._fill_top_packages_statisticscCs(t�}|�|�|�|�|�|�dS)zN
        Fill dict with statistiscs by varied statistics about limits
        N)r-rprrrv)rurerararb�_fill_limits_statistics�s

z)CloudlinuxSummary._fill_limits_statisticscsX|j�|jdd���dk	�rJ|jj�fdd�ddddd	�|jj�fd
d�ddddd	�|jj�fd
d�ddddd	�|jj�fdd�ddddd	�|jj�fdd�ddddd	�|jj�fdd�ddddd	�|jj�fdd�ddddd	�|jj�fdd�ddddd	�|jj�fd d�d!d"d#dd	�|jj�fd$d�dd%d&dd	�n
t|jd<dS)'zI
        Fill dict with statistics by statistics about mod_lsapi
        rizCan't get raw mod_lsapi infoNcs�ddS)N�criur�rara)�raw_lsapi_inforarbrc�rdz:CloudlinuxSummary._fill_lsapi_statistics.<locals>.<lambda>Zlsapi_criu_service_statusz Can't get status of criu serviceF)rycs�ddS)Nrxr;rara)ryrarbrc�rdZlsapi_criu_service_versionz!Can't get version of criu servicecs�ddS)N�	lsapiConfZ
lsapi_criurara)ryrarbrc�rdZlsapi_option_criuzCan't get state of criucs�ddS)NrzZlsapi_with_connection_poolrara)ryrarbrc�rdZlsapi_option_connection_poolz,Can't get state of mod_lsapi connection poolcs�dS)NZ
libVersionrara)ryrarbrc�rdZlsapi_lib_versionz"Can't get version of mod_lsapi libcs�dS)NZ	modStatusrara)ryrarbrc�rdZlsapi_mod_statuszCan't get mod_lsapi statuscs�dS)NZ
modVersionrara)ryrarbrc�rdZlsapi_mod_versionzCan't get mod_lsapi versioncs�dS)NZtotalDomainrara)ryrarbrc�rdrjZlsapi_total_domain_countz5Can't get total amount of domains which use mod_lsapics�dS)NZ
domainStatrara)ryrarbrc�rdrnZlsapi_domain_statz.Can't get statistics of domains with mod_lsapics�dS)NZcontrolPanelrara)ryrarbrc�rdZlsapi_apache_environmentzCan't get apache environment)r�r|�get_raw_lsapi_infor}r�)rura)ryrb�_fill_lsapi_statistics�s�











z(CloudlinuxSummary._fill_lsapi_statisticscCs|j�|jddd�dS)NroZ
wmt_configz!Cant get status of wmt_api_config)r�r}�_get_wmt_api_config)rurararb�_fill_wmt_settings_statistics�s
z/CloudlinuxSummary._fill_wmt_settings_statisticsc
spy|��\�}�WnBtk
rT}z$t�dt|��ggi�}�Wdd}~XYnXtt��t|��}y|�|�\��Wn<tk
r�}zt�dt|��ii��Wdd}~XYnX|rЈ�dt	|�i�|j
��fdd�ddd�|j
��fd	d�d
dd�|j
��fd
d�d
dd�|j
��fdd�ddd�|j
��fdd�ddd�|j
��fdd�d
dd�dS)Nz+Error while getting WordPress statistics %sz3Error while getting WordPress plugins statistics %sZcloudlinux_wpos_object_cachecst��S)N)rCra)�all_wp_pathsrarbrc�rdz7CloudlinuxSummary._fill_wp_statistics.<locals>.<lambda>rjZwordpress_installed_totalz,Can't get total count of installed wordpresscs�S)Nrara)�object_cache_pluginsrarbrcrdrnZwordpress_object_cache_pluginsz&Can't get WP object cache plugins infocs�S)Nrara)�advanced_cache_pluginsrarbrcrdZ wordpress_advanced_cache_pluginsz(Can't get WP advanced cache plugins infocst����S)N)rZr�ra)r�rarbrcrdZ$wordpress_object_cache_plugins_totalz,Can't get WP object cache total plugins infocst����S)N)rZr�ra)r�rarbrcrdZ&wordpress_advanced_cache_plugins_totalz.Can't get WP advanced cache total plugins infocs�S)Nrara)�wp_php_versionsrarbrcrdZwordpress_php_versionszCan't get WP php version info)�_prepare_wp_statisticsrrrsr�rir`rX�_prepare_wp_plugins_statisticsr�rCr�r})ruZpaths_with_wpos_object_cacher�Zwithout_wpos_object_cachera)r�rr�r�rb�_fill_wp_statistics�sX"





z%CloudlinuxSummary._fill_wp_statisticsc
s�y|��\��Wn:tk
rJ}zt�dt|��g�g�Wdd}~XYnX|j��fdd�ddd�|j��fdd�ddd	�dS)
Nz4Error while getting per-user WordPress statistics %scst��S)N)rCra)�
users_with_wprarbrc,rdz@CloudlinuxSummary._fill_per_user_wp_statistics.<locals>.<lambda>rjZ$users_count_with_wordpress_installedz7Can't get total count of users with wordpress installedcst��S)N)rCra)�users_with_wp_and_litespeedrarbrc2rdZ0users_count_with_wordpress_and_lscache_installedzECan't get total count of users with wordpress and LiteSpeed installed)�_prepare_per_user_wp_statisticsrrrsr�rir�r})rur�ra)r�r�rb�_fill_per_user_wp_statistics#s 

z.CloudlinuxSummary._fill_per_user_wp_statisticscCs |�d|�}|�d|�}||fS)zq
        Prepares dict with plugin-counter pairs
        e.g: {'w3-total-cache': 4, 'redis': 1, 'ls': 2}
        zobject-cachezadvanced-cache)�_get_plugin_info)ru�wp_pathsr�r�rararbr�8sz0CloudlinuxSummary._prepare_wp_plugins_statistics)�plugin_typer�csFttd�fdd�|D���}tt�}x|D]}||d7<q*W|S)Ncsg|]}t|���qSra)r#)r�r�)r�rarbr/Csz6CloudlinuxSummary._get_plugin_info.<locals>.<listcomp>r1)r`�filterrrj)r�r�r�Zobject_plugin_counter_pairsZpluginra)r�rbr�As
z"CloudlinuxSummary._get_plugin_infoc
	Cs�gg}}tt�}t��}x�|D]�}yt�|�}Wntk
rHw YnXtt�}x*|D]"\}}	tj�	|	�rX||	�
|�qXWxb|D]Z}	|�||	|�}
|
d}|
d}|�|�|�|
d�|r�|dkr�||t
|�7<q�Wq W|||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)rrjrrD�userdomainsrrr`r�r�r��append�_get_docroot_wp_inforrC)
rurZ$paths_with_enabled_wpos_object_cacheZphp_versions�panel_users�user�domains_info�docroot_domains_map�domain�docroot�docroot_infoZdocroot_wp_pathsZdocroot_php_versionrararbr�Js,




z(CloudlinuxSummary._prepare_wp_statisticscCs�t�t�}}t��}x�|D]�}yt�|�}Wn4tk
rb}zt�dt|��wWdd}~XYnXtt	�}x*|D]"\}}	t
j�|	�rr||	�
|�qrWxN|D]F}	|�||	|�}
t|
d�dkr�|�|�t|
d�dkr�|�|�q�WqW||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)rXrrDr�rrrsr�rirr`r�r�r�r�r�rC�add)rur�r�r�r�r�r�r�r�r�r�rararbr�ms&


z1CloudlinuxSummary._prepare_per_user_wp_statistics)r�r�r�r�cs�ggt�dd�}��fdd�t��D�}|s0|S�fdd�|D�|d<�fdd�t||�D�|d<x`|dD]T}t|d	�}|d
k	r�d|kr�|d�|�t|d
�}|d
k	rld|krl|d�|�qlWx,��D] }	|�|	�}
|
dkr�|
|d<Pq�W|S)zM
        Return data about docroot's WP paths and used php versions.
        r�)r�r�r�r�cs4g|],}tj��|��ks,tj��|��kr|�qSra)r�r�r�)r�Zwp_path)r�r�rarbr/�sz:CloudlinuxSummary._get_docroot_wp_info.<locals>.<listcomp>csg|]}t���|��qSra)r�joinpath)r�r�)r�rarbr/�sr�cs"g|]}|dk	rt���|��qS)N)rr�)r�r�)r�rarbr/�sr�zobject-cacheNrOr�zadvanced-cacher�)rXr"r$r#r��_get_php_version_for_domain)rur�r�r�r�r�r�Zobject_cache_pluginZadvanced_cache_pluginr�r�ra)r�r�rbr��s,



z&CloudlinuxSummary._get_docroot_wp_info)r�r�c
Cs�t��tjtjtjfkrdS|��\}}}|�|i�}|�dd�}t��tjkr\||kr\|Sx:|��D].\}}||krf|dkrfd|�	dd���}	|	SqfWt��tjkr�d|�	dd���}
|
St��tjkr�|�dd�}|d	t
|���d
�}|p�dS|S)z�
        Return php version that is used for specified domain.
        Determine whether of MultiPHP Manager or PHP Selector is used.
        r�Zphp_version_idrPzalt-php�.r�zda-phpZhandler_typeN�-)r�rErrLZDIRECTADMIN_NAMErG�_get_system_php_infor�rB�replacerCr�)
rur�Zsystem_default_php_version�domains_php_info�selector_php_infoZphp_infoZmulti_php_versionr;�domainsZalt_php_versionZda_php_version�handlerr�rararbr��s(z-CloudlinuxSummary._get_php_version_for_domain)�maxsizecCsXyt��d}Wntk
r(d}YnXt��}t�}|dk	rJ|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)
        Zdefault_version_idN�domains_by_php_version)rZget_system_php_inforrZget_domains_php_inforX)Zsystem_php_versionr�Zphp_selector_usager�rararbr��s	

z&CloudlinuxSummary._get_system_php_infocs0|j�|jdd���dk	�r"|j��fdd�ddd�|j��fd	d�dd
d�|j��fdd�dd
d�|j��fdd�ddd�|j��fdd�ddd�|j��fdd�ddd�|j��fdd�ddd�|j��fdd�ddd�|j��fdd�dd d!�|j��fd"d�d#d$d%�n
t|jd
<dS)&z/
        Fill dict with SSA statistics
        rizCan't get SSA statisticsNcs�dS)N�configrara)�	ssa_statsrarbrcrdz8CloudlinuxSummary._fill_ssa_statistics.<locals>.<lambda>roZ
ssa_configzCan't get SSA configcs�dS)Nr;rara)r�rarbrcrdZssa_versionzCan't get version of SSAcs�dS)Nr�rara)r�rarbrcrdZ
ssa_statuszCan't get state of SSAcs�dS)NZagent_statusrara)r�rarbrcrdZssa_agent_statuszCan't get state of SSA agentcs�ddS)N�autotracingr�rara)r�rarbrc rdZautotracing_statusz"Can't get state of SSA Autotracingcs�ddS)Nr�Zdisabled_users_quantityrara)r�rarbrc&rdrjZ#autotracing_disabled_users_quantityz1Can't get state of SSA Autotracing disabled userscs�ddS)Nr�Z
rules_versionrara)r�rarbrc,rdZautotracing_rules_versionz'Can't get SSA Autotracing rules versioncs�ddS)Nr�Zurls_processedrara)r�rarbrc2rdZautotracing_urls_processedz.Can't get SSA Autotracing processed URLs countcs�ddS)Nr�Z
urls_selectedrara)r�rarbrc8rdZautotracing_urls_selectedz-Can't get SSA Autotracing selected URLs countcs�ddS)Nr�Zrejectsrara)r�rarbrc>rdrnZautotracing_rejectsz!Can't get SSA Autotracing rejects)r�r|�
get_ssa_statsr}r�)rura)r�rb�_fill_ssa_statistics�sp










z&CloudlinuxSummary._fill_ssa_statisticscs@|j�dd�dd�}|dk	�r2|j�t|jd�ddd	�|jjt|j|t�d
ddd
d�|jjt|j|t�d
ddd
d�|j�tddd�|j�t	ddd�|j�t
d�jddd�|j�tddd�|j�t
dd���dkr�d|jd<d|jd<n<|jj�fdd�dddd
d�|jj�fdd�ddd d
d�n
t|jd<dS)!zS
        Fill dict with statistics by varied statistics about PHP selector
        cSstd�S)Nr�)rVrarararbrcNrdzACloudlinuxSummary._fill_php_selector_statistics.<locals>.<lambda>rjz+Can't get statistics about PHP interpretersNr�riZselector_php_statusz Can't get status of PHP selectorrlZselector_php_versions_installedz8Can't get list of versions of installed PHP interpretersF)ryZselector_php_versions_enabledz6Can't get list of versions of enabled PHP interpretersZselector_php_version_defaultz,Can't get default version of PHP interpreterZselector_php_version_nativez+Can't get native version of PHP interpreterZselector_php_enabled_uiz%Can't get state of UI of PHP selectorZselector_php_modezCan't get mode of PHP selectorz'Can't get summary usage of PHP selectorZ'selector_php_num_domains_by_interpreterZ%selector_php_num_users_by_interpretercsdd��d��D�S)NcSsi|]\}}t|�|�qSra)rC)r��vr�rararb�
<dictcomp>�szUCloudlinuxSummary._fill_php_selector_statistics.<locals>.<lambda>.<locals>.<dictcomp>r�)rBra)�php_usage_summaryrarbrc�rdrnzBCan't get amount of domains which use PHP selector per PHP versioncsdd��d��D�S)NcSsi|]\}}t|�|�qSra)rC)r�r�r�rararbr��szUCloudlinuxSummary._fill_php_selector_statistics.<locals>.<lambda>.<locals>.<dictcomp>Zusers_by_php_version)rBra)r�rarbrc�rdz@Can't get amount of users which use PHP selector per PHP version)r�r|r}rr��"_get_list_versions_of_interperters�	INSTALLEDr�rZrWr\Zphp_selector_is_enabledr[rXr�)ruZphp_interpretersra)r�rb�_fill_php_selector_statisticsGs|





z/CloudlinuxSummary._fill_php_selector_statisticscCs|dks|dkrdS||S)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
        r1Nra)�
total_appsZamount_of_apps_per_domainrararb�_get_average_apps_per_domain�s	z.CloudlinuxSummary._get_average_apps_per_domaincCs|dks|dkrdS||S)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
        r1Nra)r�Zamount_of_apps_per_userrararb�_get_average_apps_per_user�s	z,CloudlinuxSummary._get_average_apps_per_usercCstdd�|D��S)z
        Get amount of running applications on server
        :param apps: list of applications for something selector
        cSs g|]}|jr|jdkr|�qS)Zstarted)Z
app_status)r��apprararbr/�sz@CloudlinuxSummary._get_amount_of_runned_apps.<locals>.<listcomp>)rC)�appsrararb�_get_amount_of_runned_apps�sz,CloudlinuxSummary._get_amount_of_runned_appscCsBt�}x|D]}||jd7<qW|�d�p4dg}|ddS)z�
        Get maximum amount of applications per domain
        :param apps: list of applications for something selector
        r1)rrr)r�doc_root�most_common)r�Zapps_per_domainr��most_commonsrararb�_get_max_apps_per_domain�s

z*CloudlinuxSummary._get_max_apps_per_domaincCsBt�}x|D]}||jd7<qW|�d�p4dg}|ddS)z~
        Get maximum amount of applications per user
        :param apps: list of applications for something selector
        r1)rrr)rr�r�)r�Z
apps_per_userr�r�rararb�_get_max_apps_per_user�s

z(CloudlinuxSummary._get_max_apps_per_usercCs*t�}x|D]}||jd7<qW|S)z�
        Get Counter object which contains amount applications per version of interpreter
        :param apps: list of applications for something selector
        r1)rr;)r��apps_per_versionr�rararb�_get_counter_apps_per_version�s
z/CloudlinuxSummary._get_counter_apps_per_versioncCs&|�|�}|�d�pdg}|ddS)z�
        Get maximum amount of applications per version of interpreter
        :param apps: list of applications for something selector
        r1)rrr)r�r�)rur�r�r�rararb�_get_max_apps_per_version�s
z+CloudlinuxSummary._get_max_apps_per_versioncCs(t�}x|D]}|�|j�qWt|�S)zz
        Get amount of domains with applications
        :param apps: list of applications for something selector
        )rXr�r�rC)r�r�r�rararb� _get_amount_of_domains_with_apps�s
z2CloudlinuxSummary._get_amount_of_domains_with_appscCs(t�}x|D]}|�|j�qWt|�S)zx
        Get amount of users with applications
        :param apps: list of applications for something selector
        )rXr�r�rC)r��usersr�rararb�_get_amount_of_users_with_apps	s
z0CloudlinuxSummary._get_amount_of_users_with_appscCs|�|�}t|�S)z�
        Get amount of applications per each versoin of interpeters
        :param apps: list of applications for something selector
        )r�r�)rur�r�rararb�4_get_amount_of_apps_per_each_version_of_interpreterss
zFCloudlinuxSummary._get_amount_of_apps_per_each_version_of_interpreterscs�fdd�t|�D�S)z�
        Get list of versions of interpreters on server
        :param interpreters_stats: dict with varied statistics about each version of interpeters
        :param state: state of interpeters (installed, enabled)
        csg|]\}}|�r|�qSrara)r�Zinterpreter_stats�stat)�staterarbr/+szHCloudlinuxSummary._get_list_versions_of_interperters.<locals>.<listcomp>)r
)�interpreters_statsr�ra)r�rbr�"s	z4CloudlinuxSummary._get_list_versions_of_interperterscCs"t|�}|dk	rt|�St�SdS)zI
        Get list of apllications on server for defined selector
        N)rYr`)r�Z	iter_appsrararb�_get_list_of_applications-sz+CloudlinuxSummary._get_list_of_applicationsc	s�x|jD�]
}|j�tt|�dd�|��}|dkrHt|jd|d<q
|j�t|j|�dd|dd�|��|jjt|j	|t
�dd|d	d
�|�dd�|jjt|j	|t�dd|d
d�|�dd�|j�t|j|�dd�|���|jj�fdd�dd|dd�|�dd�|jd|ddk|jd|d<|jjt|j
��dd|dd�|�dd�|j�tt|�dd�|��}|dk	�r�||jd|d<|j�t|j��dd|dd�|��|j�t|j��dd|dd�|��|j�t|j��dd|dd�|��|j�t|j��dd|d d!�|��|j�t|j|jd|d|jd|d �dd"�|��}|dk	�r�||jd|d#<|j�t|j|jd|d|jd|d�dd$�|��}|dk	�r�||jd|d%<|j�t|j��d&d|d'd(�|��q
WdS))zc
        Fill dict with statistics by varied statistics about ruby/nodejs/python selectors
        rjz*Can't get statistics about {} interpretersNZ	selector_Z_statusrizCan't get status of {} selectorrlZ_versions_installedz7Can't get list of versions of installed {} interpretersF)ryZ_versions_enabledz5Can't get list of versions of enabled {} interpretersz!Can't get list of {} applicationscst��S)N)rCra)�interpreter_appsrarbrccrdz>CloudlinuxSummary._fill_selectors_statistics.<locals>.<lambda>Z_applications_amountz)Can't get total amount of {} applicationsrZ_usedZ_applications_runningz6Can't get amount of runned application for {} selectorz(Can't get default version of {} selectorZ_default_versionZ_max_applications_per_domainz8Can't get max applications per domain for {} interpreterZ_max_applications_per_userz6Can't get max applications per user for {} interpreterZ_num_users_with_appsz=Can't get amount of users with applications for {} interpeterZ_num_domains_with_appsz?Can't get amount of domains with applications for {} interpeterzFCan't get average amount of applications per domain for {} interpreterZ _average_applications_per_domainzDCan't get average amount of applications per user for {} interpreterZ_average_applications_per_userrnZ _num_applications_by_interpreterzDCan't get amount of applications per each version of {} interpreters)�	SELECTORSr�r|rrVr�r�r}r�r�r�r�r�r�r]r�r�r�r�r�r�r�)ruZselectorr�Zdefault_version_of_selectorZaverage_apps_per_domainZaverage_apps_per_userra)r�rb�_fill_selectors_statistics:s�






$














z,CloudlinuxSummary._fill_selectors_statisticscCs~ddg}t|dd�\}}}|dkr*t|��t�|�}t�}|d|d<dd�|d	D�}x tD]}|�|t�|d
|<q^W|S)zA
        Get wizard status and list of installed modules
        z/usr/sbin/cloudlinux-wizardr�T)r-r�
wizard_statuscSsi|]}|d|d�qS)r�rAra)r�r�rararbr��sz<CloudlinuxSummary._get_wizard_statistics.<locals>.<dictcomp>r��wizard_module_)rrr�r2r�rPr��NOT_SELECTED)r4Zret_codeZstd_outZstd_errZparsed_json�wizard_statisticsZparsed_modulesr�rararb�_get_wizard_statistics�s

z(CloudlinuxSummary._get_wizard_statisticscsl|j�|jdd��|jj�fdd�ddddd�x6tD].�|jj��fd	d�dd
�d���dd�q6WdS)
zX
        Fill dict with statistics by varied statistics about cloudlinux-wizard
        riz,Can't get statistics about cloudlinux-wizardcs�dS)Nr�rara)r�rarbrc�rdz;CloudlinuxSummary._fill_wizard_statistics.<locals>.<lambda>r�z%Can't get status of cloudlinux-wizardF)rycs�d�S)Nr�rara)r�r�rarbrc�rdr�z;Can't get statistics about module "{}" of cloudlinux-wizardN)r�r|r�r}rPr�)rura)r�r�rb�_fill_wizard_statistics�s"

z)CloudlinuxSummary._fill_wizard_statisticscCs0t�}g}x |D]}|t||���7}qW|S)zH
        Returns list of implemented scripts in integration.ini
        )rSr`�keys)r�ZscriptsZsectionrararb�$_get_implemented_integration_scripts�s

z6CloudlinuxSummary._get_implemented_integration_scriptscCs2dgd�}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�rRr�)rurzrararb�_get_integration_info�s
z'CloudlinuxSummary._get_integration_infocCs8ddl}d}|��}t|j�|}t|j�|}||fS)zG
        Gets memory usage: total and used memory in megabytes
        rNi)�psutilZvirtual_memoryrk�totalZused)r�Zbytes_in_mbZmemZ	mem_totalZmem_usedrararb�_get_memory_used�sz"CloudlinuxSummary._get_memory_usedc	CsNt��}d}d}ttj�rFtj�|�rFt|��}|�	��
�}WdQRX||fS)za
        Gets kernel info release and module version (starting from 7h)
        :return:
        z/sys/module/kmodlve/versionN)�platform�releaserrrr�r�r�r�r�r�)�kernel_releaseZkmodlve_version_fileZkmodlve_versionr�rararb�_get_kernel_info	s
z"CloudlinuxSummary._get_kernel_infocCs
tt��S)zp
        Gets info about lve extensions usage
        Calculates amount of packages with lve extensions
        )rCrFrarararb�#_get_lve_extensions_packages_amount	sz5CloudlinuxSummary._get_lve_extensions_packages_amountc	Cs@d}tj�|�sdSt|��}|����}WdQRXtt|��S)zk
        Reads /proc/sys/fs/datacycle/enable in order to check
        datacycle enabled parameter
        z/proc/sys/fs/datacycle/enableFN)r�r�r�r�r�r�r�rj)Zdatacycle_filer�r�rararb�$_is_kernel_datacycle_enabled_in_file	s
z6CloudlinuxSummary._is_kernel_datacycle_enabled_in_filec	CsFd\}}tj�|�sdSt|��}|�����d�}WdQRX||kS)zR
        Checks if datacycle parameter was given
        for current boot
        )z
/proc/cmdlineZ	datacycleF� N)r�r�r�r�r�r��split)Zcmdline_filer�r�r�rararb�_is_datacycle_param_was_passed-	s
z0CloudlinuxSummary._is_datacycle_param_was_passedcCs0t��}d}x|D]}|tt�|��7}qW|S)z=
        Returns general amount of domains on server
        r)rrDrCr�)Zcpusers_listZ
domains_countr�rararb�_get_total_domains_amount=	s

z+CloudlinuxSummary._get_total_domains_amountcCsNt�}tt|�d���}tt|�d���}|r6|r6dS|r>dS|rFdSdSdS)zi
        Returns is links traversal protection enabled on server
        (symlinks or hardlinks)
        zfs.protected_symlinks_createzfs.protected_hardlinks_create�allZ
symlinks_onlyZhardlinks_onlyZnoN)r'r�rjr�)r�Zsymlink_protection_enabledZhardlink_protection_enabledrararb�%_is_link_traversal_protection_enabledH	sz7CloudlinuxSummary._is_link_traversal_protection_enabledcCs@d}d}d}tj�d�s$tj�d�r(|Stj�d�r8|S|SdS)N�iso�cldeploy�qcow2z/etc/cl-convert-savedz/var/log/cldeployz/etc/cloudlinux-qcow2-install)r�r�r�)r�r�r�rararb�_get_cl_installation_sourceZ	sz-CloudlinuxSummary._get_cl_installation_sourcecs����ttj�r`�jj�jddddd��jj�jdddd	d��jj�fd
d�ddd
dd�td	d�s��jjt	dddd	d��jjt
ddddd��jjtddddd��j��jddd��j��j
ddd��jj�fdd�ddddd������jj�fdd�ddddd��jj�fdd�d d!d"dd������jj�fd#d�d$d%d&dd��jj�fd'd�d$d(d)dd��jj�jdd*d+d	d�ttj��r��jj�fd,d�dd-d.d	d��jjtdd/d0d	d��jjtdd1d2d	d��jj�jdd3d4d	d�dS)5NrjZlve_extension_packages_amountz"Can't get lve extension usage infoF)ryriZ!link_traversal_protection_enabledz5Can't get link traversal protection enabled parameterTcs�dS)Nr1rara)�kernel_inforarbrcz	rdz;CloudlinuxSummary._fill_system_statistics.<locals>.<lambda>Zinstalled_kmod_lve_versionz)Can't get installed kmod-lve version info)�skip_jwt_checkZcldiag_cron_check_enabledz&Can't get is cldiag cron check enabledZ
cpu_amountzCan't get cpu amountZtesting_repository_enabledz#Can't get testing repository statusZbase_distrozCan't detect platform for CLOSZsecureboot_statusz+Can't detect whether secure boot is enabledcs�dS)Nrrara)r�rarbrc�	rdr�zCan't get kernel release infocs�dS)Nr�rara)�vendor_integration_inforarbrc�	rdr�z'Can't get integration_scripts_used infocs�dS)Nr�rara)r�rarbrc�	rdrlr�z-Can't get integrations scripts specified infocs�dS)Nrrara)�memory_usagerarbrc�	rdrkZmemory_total_mbzCan't get total memory infocs�dS)Nr1rara)r�rarbrc�	rdZmemory_used_mbzCan't get used memory infoZ
domains_totalzCan't get domains amountcs���p���S)N)r�r�ra)rurarbrc�	sZkernel_datacycle_usage_enabledz,Can't get kernel datacycle enabled parameterZ	virt_typez!Can't get the virtualization typeZhostnamezCan't get the hostnameZcloudlinux_installation_sourcezCan't get installation source)r�rrrr�r}r�r�rrTrrr�r�r�r�r�rr
r�)rura)r�r�rur�rb�_fill_system_statisticsf	s�








z)CloudlinuxSummary._fill_system_statisticscsB�j��fdd�ddd��j�tddd��j�tdd	d
�dS)Ncs
�jptS)N)r��UNKNOWN_RHN_IDra)rurarbrc�	rdzKCloudlinuxSummary._fill_dict_with_rpm_packages_statistics.<locals>.<lambda>rir�zCan't get system IDZ
os_versionzCan't get version of OSrprqz*Can't get info about client's rpm packages)r�r}rrL)rura)rurbr=�	s
z9CloudlinuxSummary._fill_dict_with_rpm_packages_statistics)�paramr�cCst�|j�|��S)z�
        Retrieve data from proc/mounts for param
        :return: param_value - Optional[int],
        if there is no value - None
        )r*Z
str_to_intr�r�)rur�rararb�_get_proc_param
sz!CloudlinuxSummary._get_proc_paramcCs�dg}ttj�r.|�dddddddd	d
dg
�x8|D]0}|jjt|j|�d|�d
d�d�	|�dd�q4W|jjt
ddddd�dS)z�
        Filling stats about mounting
        - mount params from parameters list
        - separate hidepid getting, since it is more complicated than
        other mounting params
        zkernel.memcg_oom_disablezfs.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_taskrjr�r�z
Can't get {0}T)ryZhidepidzCan't get hidepid valueN)rrrrr�r}rr�r�r�rU)ru�
parameters�prararb�_fill_proc_params_statistics
s4



z.CloudlinuxSummary._fill_proc_params_statisticscCsBd}x8|D]0}|jjt|j|�dd|��d|�d�dd�q
WdS)	zJ
        Fill dict with statistics about kmodlve parameters usage
        )Zlve_setuid_enterrjZkmodlve_zCan't get "z" kmodlve parameter valueT)ryN)r�r}r�_get_kmodlve_param_value)rur�r�rararb�_fill_kmodlve_params_statisticsA
s


z1CloudlinuxSummary._fill_kmodlve_params_statisticscs�tdd��|j��fdd�ddd�|j��fdd�dd	d
�|j��fdd�ddd
�|j��fdd�ddd�|j��fdd�ddd�|j�tt��ddd�dS)zv
        Fill statistics fields from jwt token.
        - jwt token metrics (cl_plus existence and client_id)
        F)Zcheck_expirationcs�dkrdS��dd�S)N�cl_plus)r�ra)r�rarbrcY
sz=CloudlinuxSummary._fill_cln_jwt_information.<locals>.<lambda>rjr�zCan't get cl_plus informationcs�dkrdS��dd�S)N�	client_id)r�ra)r�rarbrc`
sr�zCan't get client_id valuecs�dkrdS��dd�S)NZis_awp_premium_allowed)r�ra)r�rarbrcg
sZjwt_is_awp_premium_allowedz&Can't get is_awp_premium_allowed valuecs�dkrdS��dd�S)NZis_awp_cdn_allowed)r�ra)r�rarbrcn
sZjwt_is_awp_cdn_allowedz"Can't get is_awp_cdn_allowed valuecs�dkrdS��dd�S)NZis_trial)r�ra)r�rarbrcu
sZjwt_is_trial_licensez$Can't get jwt_is_trial_license valueZlicense_activezCan't get license status valueN)rIr�r}rrK)rura)r�rb�_fill_cln_jwt_informationQ
s>





z+CloudlinuxSummary._fill_cln_jwt_informationcs0�j��fdd�ddd��j�tddd�d	S)
za
        Filling stats centralized management
        - centralized management existence
        cstj��j�S)N)r�r�r��CL_PLUS_CM_DISABLED_PATHra)rurarbrc�
rdzKCloudlinuxSummary._fill_centralized_management_statistics.<locals>.<lambda>rjZcentralized_management_disabledzCan't check CM disabling statusriZcl_plus_sender_service_statusz)Can't check cl plus sender service statusN)r�r}rJ)rura)rurb�'_fill_centralized_management_statistics�
s
z9CloudlinuxSummary._fill_centralized_management_statisticsc
Cs�t�}yFt�}x:|D]2}x,|��D] \}}|�d|��g��|�q"WqWWn2ttfk
r~}zt�d|�Wdd}~XYnX|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
        ]
        Zcpu_zCPU metrics getting error: %sN)	r�rMrB�
setdefaultr�r�rOrsr�)rzZ	cpu_coresZcpu_core�metric�valueZexrararb�make_flat_cpu_metrics�
s
$z'CloudlinuxSummary.make_flat_cpu_metricsc	Cslddddg}|��}x@|D]8}|dkr*dnd}|j�t|j|d�||d|�d	��qW|j�td
dd�dS)
z�
        Filling stats about hardware metrics, specifically:
        CPU:
            - cache
            - frequency
            - model
            - id
        RAM:
            - ram
            - swap
        Zcpu_idZcpu_cache_mbZ	cpu_modelZcpu_frequency_mhzrmrlNzCan't parse z metric for all coresrnZmemoryzCan't parse memory metrics)rr�r}rr�rN)ruZexp_metricsZcpu_metricsr�Zmetric_typerararb�_fill_hardware_statistics�
s

z+CloudlinuxSummary._fill_hardware_statisticscCs6|��\|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
        Z(act_cagefs_disabled_unable_to_create_lveZ&act_cagefs_disabled_unable_to_enter_nsZ)act_cagefs_disabled_unable_to_acqure_lockz/etc/cagefs/fail.on.errorZ"act_cagefs_disabled_marker_presentN)�*_scan_log_for_act_cagefs_disabled_messagesr�r�r�r�)rurararb�$_fill_act_cagefs_disabled_statistics�
s z6CloudlinuxSummary._fill_act_cagefs_disabled_statisticsc	Cs�y�|��\}}|dkrv|�d�}ttddd|d��}t|�}ttddd|d��}t|�}ttddd|d��}t|�}nd}d}d}|||fSttfk
r�dSXd	S)
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_stringZmultiple_searchZdata_from_filez<Act like CageFS is disabled (unable to enter into NameSpace)z<Act like CageFS is disabled (unable to acquire lock for user)i���i���i���N)�_get_data_from_logr�r`r rCr�r�)ru�
returncoderMZ
lines_listZfound_lines_listZnum_unable_to_create_lveZnum_unable_to_enter_nsZnum_unable_to_acqure_lockrararbr�
s&


z<CloudlinuxSummary._scan_log_for_act_cagefs_disabled_messagescCsft�}|dkrd}n,tj��tjdd�}|�d�}d|�d�}tj|ddd	tjtj	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)
        )Zcl7Zcl7hZcl8za/usr/bin/journalctl --since yesterday --until today | /usr/bin/grep 'Act like CageFS is disabled'r1)Zdaysz%Y-%m-%dz/usr/share/cloudlinux/logs-at z< /var/log/messages | /bin/grep 'Act like CageFS is disabled'Tz	/bin/bash)r�rrrM�stderr)r�datetimeZdateZtodayZ	timedeltaZstrftimer	r
�PIPEZDEVNULLrrM)Zos_typeZs_cmdZyesterday_dateZdate_to_scanr�rararbrs
z$CloudlinuxSummary._get_data_from_logcs�ttj�r�j��jddd�t�jd<�j�ttj	dd�ddd	��j��j
dd
d��j��jddd
��j��jddd��j��fdd�ddd��j��fdd�ddd�t
dk	r�tdk	r�d�t
t��jd<n
d�jd<���dS)Nrj�old_way_of_integration_usedz*Can't detect old LVE integration mechanism�lve_utils_versionF)Z
verify_expriZ
cl_editionzCan't get CloudLinux editionZis_solo_meta_file_presentz$Can't detect solo meta file presenceZis_admin_meta_file_presentz%Can't detect admin meta file presenceZis_container_meta_file_presentz)Can't detect container meta file presencecs�jS)N)r�ra)rurarbrcHrdzACloudlinuxSummary._prepare_cl_normal_statistics.<locals>.<lambda>r�z$Can't get or generate security tokencs
�jptS)N)r�r�ra)rurarbrcNrdr�zCan't get system IDz{}-{}�lvemanager_version)rrrr�r}r��LVE_UTILS_PKG_VERSIONrrZget_cl_edition�_is_solo_marker_exists�_is_admin_marker_exists�_is_container_marker_exists�LVEMANAGER_PKG_VERSION�LVEMANAGER_PKG_RELEASEr��_fill_dict_with_statistics)rura)rurbr<%sX




z/CloudlinuxSummary._prepare_cl_normal_statisticsc	s@d�d�d�d�d�d}tj���s(dSGdd	�d	t��������fd
d�}�d�d�di}d
d�t���D�}|��xX|D]P}y|||�Wq��k
r�Yq�tk
r�x|D]}d||<q�WYq�Xq�W|�|j�<|�|j�<|�|j�<tj�d��rd|j|<n$tj�d��r2d|j|<n
d|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�QZlve_number_of_opensZxray_number_of_installationZxray_number_of_visitsZxray_advanced_metrics_statusNc@seZdZdS)zECloudlinuxSummary._fill_lvemanager_statistics.<locals>.BreakOuterLoopN)r~rr�rarararb�BreakOuterLoopnsrc	
stj����}t�|d�}d}x�|D]�}y�d�|�d�dd��}tj�|d���}|�|krn|kr�nnjd�|���d�dd��}|dkr�|�d7<q�|dkr�|�d7<q�|d	kr�|�d7<nd
}Wq&tt	fk
r�w&Yq&Xq&W|�r��dS)N�rFr�r�z%Y-%m-%d %H:%M:%S,%fzlvemanager-openedr1zxray-install-startedzxray-tab-clickedT)
r	Znowr�r�r�r�Zstrptimer�r��AttributeError)	�stats�fileZcurrent_date_timestampr�Zbreak_outer_loop�lineZlog_timeZlog_date_timestampr�)r�COLLECTING_PERIOD�
LOG_FOLDER�LVE_NUMBER_OF_OPENS�XRAY_NUMBER_OF_INSTALLS�XRAY_NUMBER_OF_VISITSrarb�fill_statisticsrs(
zFCloudlinuxSummary._fill_lvemanager_statistics.<locals>.fill_statisticsrcSsg|]}t�d|�r|�qS)z^lvemanager\.log(\.\d{1,2})?$)�re�match)r�rArararbr/�szACloudlinuxSummary._fill_lvemanager_statistics.<locals>.<listcomp>rz./opt/alt/php-xray/php/advanced_metrics.enabledrfz//opt/alt/php-xray/php/advanced_metrics.disabledrgZnone)	r�r��isdirrr�listdir�sortr�r�r�)ruZXRAY_ADVANCED_METRICS_STATUSr r�Z	log_filesZlog_filer�ra)rrrrrrrb�_fill_lvemanager_statistics]s>

z-CloudlinuxSummary._fill_lvemanager_statisticscCs:d}d}|j�|jdd�}|d|j|<|d|j|<dS)z9
        Fill dict with Leapp upgrade statistics
        Zleapp_upgrade_statusZcentos7_cl7_cl8_transformationrnzCan't get Leapp statistics�leapp_status�discount_eligibleN)r�r|�get_leapp_stats)ruZLEAPP_STATUSZDISCOUNT_ELIGIBILITYZelevate_statusrararb�_fill_leapp_statistics�sz(CloudlinuxSummary._fill_leapp_statisticscCs2t�}dd�|D�|jd<dd�|D�|jd<dS)z:
        Fill dict with feature flags information
        cSsg|]
}|j�qSra)rA)r�r�rararbr/�szDCloudlinuxSummary._fill_feature_flags_statistics.<locals>.<listcomp>Zserver_flags_availablecSsg|]}|jr|j�qSra)rfrA)r�r�rararbr/�sZserver_flags_enabledN)r_r�)ruZall_flags_inforararb�_fill_feature_flags_statistics�sz0CloudlinuxSummary._fill_feature_flags_statisticsc	Cs^d}d}d}d}d}d}d}d}tj�|�r0|}tj�|�r@|}tj�|�rP|}||j|<dS)	z8
        Fill out AccelerateWP promotion status
        Zaccelerate_wp_promotion_statusZenabled_for_current_serverZenabled_for_all_serversZskippedz,/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�)	ruZFIELDZENABLED_FOR_CURRENT_SERVERZENABLED_FOR_ALL_SERVERSZSKIPPEDZenable_awp_all_servers_flagZenable_awp_this_server_flagZskip_awp_setupr�rararb�(_fill_accelerate_wp_promotion_statistics�sz:CloudlinuxSummary._fill_accelerate_wp_promotion_statisticscs��j��fdd�ddd��j��fdd�ddd�t�jd	<tdk	rbtdk	rbd
�tt��jd<n
d�jd<�j��jdd
d����dS)Ncs�jS)N)r�ra)rurarbrc�rdz7CloudlinuxSummary._prepare_statistics.<locals>.<lambda>rir�z$Can't get or generate security tokencs
�jptS)N)r�r�ra)rurarbrc�rdr�zCan't get system IDrz{}-{}r
rjrz*Can't detect old LVE integration mechanism)r�r}rrrr�r�r)rura)rurb�_prepare_statistics�s,



z%CloudlinuxSummary._prepare_statisticscCsBttj�r|��ttj�r,|��|��ttj�r>|��ttj	�rX|�
�|��ttj�rj|�
�ttj�s�ttj�s�ttj�r�|��tdd�s�|��ttj�r�|��ttj�r�|��|��|��|��|��|��|��|��|��|� �|�!�|�"�|�#�|�$�|�%�|�&�dS)NT)r�)'rrZGOVERNORr?ZCAGEFSrTrZRESELLER_LIMITSrbrrwr�ZPHP_SELECTORr��
RUBY_SELECTOR�PYTHON_SELECTOR�NODEJS_SELECTORr�rr�ZLSAPIr|ZWIZARDr��_fill_wpos_statisticsr�rJr�r�rr~r�r&r�r�r*r+r,�_fill_apache2nginx_statistics)rurararbr	sJ










z,CloudlinuxSummary._fill_dict_with_statisticscCs|j�|jddd�dS)NrnZapache2nginxz Can't parse Apache2Nginx metrics)r�r}�get_apache2nginx_stats)rurararbr23s
z/CloudlinuxSummary._fill_apache2nginx_statisticscs�|j�|jdd��|j�tdd��|j��fdd�ddd	�|j�d
d�ddd�t�t��r���d
�dk�r���d�dk	r�|j��fdd�ddd���d�dk	r�|j��fdd�ddd�|j��fdd�ddd�|j��fdd�ddd���d��r|j��fdd�ddd�x@�dD]4��dk�r4�q"|j���fd d�dd!�d��q"Wx6��d"g�D]&�|j���fd#d�dd$�d��qhWx@�d%D]4��dk�r��q�|j���fd&d�dd'�d��q�Wx6��d(g�D]&�|j���fd)d�dd*�d��q�Wx6��d+g�D]&�|j���fd,d�dd-�d��qWxD��dg�D]4��dk�rd�qR|j���fd.d�dd/�d��qRWx,��d0i���D]\�}||jd1�<�q�W|j��fd2d�dd3d�|j��fd4d�dd5d�|j��fd6d�dd7d8�|j��fd9d�dd:d;�|j��fd<d�dd=d>�|j��fd?d�dd@dA�|j��fdBd�ddCdD�|j��fdEd�ddFdG�dS)HNriz!Can't get AccelerateWP statisticsrnz,Can't get AccelerateWP activation statisticscs
��d�S)NZaccelerate_wp_free_activate)r�ra)�client_activationrarbrcJrdz9CloudlinuxSummary._fill_wpos_statistics.<locals>.<lambda>rjZ&cmt_accelerate_wp_free_activated_in_uiz;Can't get statistic of AccelerateWP CMT activation selectedcSstj�t�S)N)r�r�r�r%rarararbrcRrdZ.cmt_is_accelerate_wp_free_activation_completedz2Can't get statistic of AccelerateWP CMT activationrzr��features_visible_by_defaultcs�dS)Nr5rara)�
wpos_statsrarbrc[rdrlZ wpos_features_visible_by_defaultz*Can't get statistic of using AccelerateWP.�features_allowed_by_defaultcs�dS)Nr7rara)r6rarbrcbrdZ wpos_features_allowed_by_defaultcs�ddS)N�
enabled_sitesr�rara)r6rarbrchrdZsites_count_with_enabled_wposcs�ddS)N�
allowed_usersr�rara)r6rarbrcnrdZusers_count_with_allowed_wpos�
visible_userscs�ddS)Nr:r�rara)r6rarbrcurdZusers_count_with_visible_wposr8r�cs�d�S)Nr8rara)r�r6rarbrc~rdZsites_count_with_enabled_�
enabled_userscs�d�S)Nr;rara)r�r6rarbrc�rdZusers_count_with_enabled_r9cs�d�S)Nr9rara)r�r6rarbrc�rdZusers_count_with_allowed_�allowed_suitescs�d�S)Nr<rara)�suiter6rarbrc�rdZusers_count_with_allowed_suite_�enabled_suitescs�d�S)Nr>rara)r=r6rarbrc�rdZusers_count_with_enabled_suite_cs�d�S)Nr:rara)r�r6rarbrc�rdZusers_count_with_visible_Zupgrade_urlsZupgrade_url_cs�dS)N�4accelerate_wp_suite_enabled_premium_suite_disallowedrara)r6rarbrc�rdr?cs�dS)N�1accelerate_wp_suite_enabled_premium_suite_visiblerara)r6rarbrc�rdr@cs
��d�S)N�is_accelerate_wp_flag_enabled)r�ra)r6rarbrc�rdrAz1Can't get statistic of AccelerateWP feature flag.cs
��d�S)N�is_accelerate_wp_icon_enabled)r�ra)r6rarbrc�rdrBz0Can't get statistic of AccelerateWP icon status.cs
��d�S)N�%is_smart_advice_notifications_enabled)r�ra)r6rarbrc�rdrCzJCan't get statistic of AccelerateWP is_smart_advice_notifications_enabled.cs
��d�S)N�!is_smart_advice_reminders_enabled)r�ra)r6rarbrc�rdrDzFCan't get statistic of AccelerateWP is_smart_advice_reminders_enabled.cs
��d�S)N�+is_smart_advice_plugin_installation_enabled)r�ra)r6rarbrc�rdrEzPCan't get statistic of AccelerateWP is_smart_advice_plugin_installation_enabled.cs
��d�S)N�is_object_cache_banners_enabled)r�ra)r6rarbrc�rdrFzDCan't get statistic of AccelerateWP is_object_cache_banners_enabled.)	r�r|�get_wpos_statsr&r}r�r�r�rB)ruZupgrade_urlra)r4r�r=r6rbr1;s
















z'CloudlinuxSummary._fill_wpos_statisticsc
Csndg|}yt|dd�\}}}Wn.tk
rN}zt�d|�dSd}~XYnX|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-statisticsT)r-z.Unable to run cloudlinux-statistics, error: %sNrz;cloudlinux-statistics failed with exit code: %i, output: %s)rrrsr1r�)rr4r#r5r�r�rararb�_run_cloudlinux_statistics�s
z,CloudlinuxSummary._run_cloudlinux_statisticsc
Cs�|�ddddg�}|dkrdSyt�|�}|d}|d}Wn8tttfk
rt}zt�d	t|��dSd}~XYnXt	|�t	|�fS)
zp
        Get number of users and resellers with faults for the past 24h
        :rtype: tuple[int, int]
        z
--by-faultr�z--jsonz--period=1dN)NNr_r�zISomething really bad happened to cloudlinux-statistics, The reason is: %s)
rHr�r2r�r�r�rsr1rirC)rur5Z	json_datar_r�r�rararbra�s

z5CloudlinuxSummary.get_users_and_resellers_with_faultscCsV|dkrdS|��}|�d�r"dS|�d�r0dS|�d�r>dS|��rJdSd|SdS)zGet config cpu limit formatN�%�speedZmhzZghzZold_cpu_formatzunknown: %s)�lower�endswith�isdigit)�clsrkZunitrararbrl
s


z&CloudlinuxSummary._get_cpu_limit_unitscCs|dkrdSd|dS)z/Convert memory limit from mempages to megabytesNr7ira)r�rararbrm
sz!CloudlinuxSummary._mempages_to_mbcCs8|dkrdStj||pdd�}|dkr*dSt|dd�S)z,Convert cpu and ncpu to percents of one coreNr)ZlncpugY@r1)rZconvert_to_kernel_format�round)rkrdrJrararbrj$
sz(CloudlinuxSummary._cpu_limit_to_percentscCs�|jdkr|ttdd�|j��D��td�d�}g}x6t|td�d�D]"\}}tt|��}|�||f�qDW|j	dd�||_|jS)zC
        Return list of tuples [users_in_package, package]
        Ncss|]}|jjdk	r|VqdS)N)�packagerA)r�r�rararbr�8
sz>CloudlinuxSummary.get_users_amount_per_plan.<locals>.<genexpr>rP)�keyT)�reverse)
r��sortedr`r�r�rr	rCr�r%)rureZusers_sorted_by_packager�rP�groupZ	num_usersrararb�get_users_amount_per_plan/
s
z+CloudlinuxSummary.get_users_amount_per_plancCs,y|�|�|dStk
r&dSXdS)Nr1)rU�
IndexError)ruZ
number_of_toprerararbruH
sz5CloudlinuxSummary._get_top_package_by_number_of_userscCs"t|�\}}|s|�t|��|S)z%
        Parse CLI arguments
        )r2r�r,)rur"r�r�rararbrP
szCloudlinuxSummary._parse_argsr�rcCs8|t��|d�}|dk	r ||d<t|d�t�|�dS)z?
        Print data in default format for web and exit
        )rzr�r�NZstatistic_enabledT)r�r+�sysr)rzr�Z	exit_coder;r�rararbrZ
s
z(CloudlinuxSummary._print_result_and_exitr1cCs*|�dt��i�t|d�t�|�dS)z�
        Print error and exit
        :param dict message: Dictionary with keys "result" as string and optional "context" as dict
        r�TN)r�r�r+rWr)r�r�rararbr�j
s
z!CloudlinuxSummary._error_and_exitcCs6tj�d�r2tjddgdtjtjd�}t�|j�SdS)zD
        Return mod_lsapi info from switch_mod_lsapi script
        z/usr/bin/switch_mod_lsapiz--statT)r�rMrN)	r�r�r�r	r
r
r�r2rM)r�rararbr{u
s

z$CloudlinuxSummary.get_raw_lsapi_infocCsdd}t�r|d7}tj�|�r`tj|dgdtjtjd�}t�|j	��
d�}dd�|��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-getT)r�rMrr�cSsi|]\}}t|�|�qSra)ri)r��kr�rararbr��
sz9CloudlinuxSummary._get_wmt_api_config.<locals>.<dictcomp>N)rr�r�r�r	r
r
r�r2rMr�rB)rNr�Zwmt_api_config_summaryrararbr}�
sz%CloudlinuxSummary._get_wmt_api_configcCstj�d�S)Nz/etc/cloudlinux-edition-solo)r�r�r�rarararbr�
sz(CloudlinuxSummary._is_solo_marker_existscCstj�d�S)Nz/etc/cloudlinux-edition-admin)r�r�r�rarararbr�
sz)CloudlinuxSummary._is_admin_marker_existscCstj�d�S)Nz/etc/cloudlinux-container)r�r�r�rarararbr�
sz-CloudlinuxSummary._is_container_marker_existscCs0tj�d�r,tjddgddd�}t�|j�SdS)zL
        Return statistics from cloudlinux-ssa-manager get-stat API
        z /usr/sbin/cloudlinux-ssa-managerzget-statT)r�rKN)r�r�r�r	r
r�r2rM)r�rararbr��
s

zCloudlinuxSummary.get_ssa_statscCs�d}d}d}d}tj�|�rPtj�|�rPtj�|�}tj�|�}||dkrPd}d}t��tjkr�tj�|�r�d}d}tt	||d	d
�d�}	tt	||d	d
�d�}
|
r�|	s�d}q�d}n2tj�|�r�d
}tt	||d	d
�d�}|r�d}nd}|dkr�d}||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�'r1zHAn upgrade inhibitor detected\|Workflow interrupted due to the FailPhasez'Starting stage After of phase FirstBootT)rNr�z
Great SUCCESS)r'r()
r�r�r��getmtimer�rErrL�nextr )r(Z
leapp_logfileZelevate_cpanel_logfileZcldeploy_logfileZleapp_mtimeZcldeploy_mtimeZupgrade_statusZ
fail_grep_strZfirst_boot_grep_strZ
fail_grep_resZfirst_boot_grep_resZsuccess_grep_strZgrep_res�stat_resultrararbr)�
s<z!CloudlinuxSummary.get_leapp_stats)r�r�cCsXd}t||�}|��sdS|����}|dkr2dS|dkr>dStd|�d|�d	���d
S)z�
        Get kmodlve parameter value:
        -1 - not supported (parameter file doesn't exist);
        0 - disabled;
        1 - enabled
        z/sys/module/kmodlve/parametersr�Yr1�NrzUnable to interpret "z" kmodlve parameter value: "�"N)rr�Z	read_textr�rr)r�Z
params_dirZ
param_fileZparam_valuerararbr��
s
z*CloudlinuxSummary._get_kmodlve_param_valuecCs:d}tj�|�r6tj|dgddd�}t�|j��d�SdS)zE
        Return statistics from cl-smart-advice counters API
        z/usr/sbin/cl-smart-adviceZcountersT)r�rKr�N)	r�r�r�r	r
r�r2rMr�)�utilr�rararb�get_smart_advice_statssz(CloudlinuxSummary.get_smart_advice_statsc
Cs~tddd�}tdd�sz|j�|jdd�}|dk	rzyt|d|dd�Stk
rx}zt�d	t|�|�|Sd}~XYnX|S)
z=
        Construct dict with Smart Advice statistics
        N)Zsmart_advice_totalZsmart_advice_appliedT)Zskip_marker_checkroz!Can't get Smart Advice statisticsr�ZappliedzAUnexpected json response from server, field %s is missing in "%s")	r�rr�r|r`r�rsrtri)rurzZsa_statsr�rararbr�s&
z.CloudlinuxSummary._get_smart_advice_statisticsc	Cs�i}tj�d��rrtd���P}t�|�}t|�|d<t|���}dd�|D�}t|�|d<tdd�|D��|d<g|d<g|d	<xf|D]^}|d
dkr�|�	d�}|r�|d�
|d�q�|d
d
kr�|�	d�}|r�|d	�
|d�q�Wtt|d��|d<tt|d	��|d	<tdd�|D��|d<tdd�|D��|d<tdd�|D��|d<tdd�|D��|d<WdQRXtj�d��r�td��}|���
�|d<WdQRX|S)zP
        Return statistics by parsing /var/lib/apache2nginx/server.json
        z!/var/lib/apache2nginx/server.jsonZtotal_websitescSsg|]}|�d�r|�qS)�proxy_reason)r�)r�r.rararbr/?sz<CloudlinuxSummary.get_apache2nginx_stats.<locals>.<listcomp>Ztotal_proxy_passcSsg|]}|ddkr|�qS)ra�	directivera)r�r.rararbr/EsZproxy_pass_due_directiveZfailing_directivesZfailing_handlersrarbZ
proxy_detailsr�cSsg|]}|ddkr|�qS)raZtestra)r�r.rararbr/\sZproxy_pass_due_testcSsg|]}|ddkr|�qS)raZforcedra)r�r.rararbr/`sZproxy_pass_due_forcedcSsg|]}|ddkr|�qS)rar�ra)r�r.rararbr/dsZproxy_pass_due_handlercSsg|]}|ddkr|�qS)raZincludesra)r�r.rararbr/hsZproxy_pass_due_includesNz/var/lib/apache2nginx/stater�)r�r�r�r�r��loadrCr`r�r�r�rXr�r�)rr�r�ZwebsitesZproxiedr.Zfailing_directiveZfailing_handlerrararbr3/sJ




z(CloudlinuxSummary.get_apache2nginx_statscCs4d}tj�|�r0tj|dgddd�}t�|j�SdS)zE
        Return statistics from cl-smart-advice counters API
        z/usr/bin/clwpos-adminzget-statT)r�rKN)r�r�r�r	r
r�r2rM)r_r�rararbrGrsz CloudlinuxSummary.get_wpos_stats)r�NrN)r1)�r~rr�r�r��	itertools�compressrrrr/r.r0r�r�rr�r��staticmethodr��propertyr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr3r8r�rr
r!rjr:r*rr&r+r%rr>r?rJrIrHrFrSrTr]r^r`rbrprrrvrwr|r~r�r�r�rir7r�r9rr�rXr�r6r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r=r4r�r�r�r�r�rrrrrr<r&r*r+r,r-rr2r1rHra�classmethodrlrmrjrUrurrr�r{r}rrrr�r)r�r`r�r3rGrarararbr��s<


	7	+(
@!"DAj
T:	(#
-'LR



v
-2&! 8N*(


? Cr�cCst�}|j��|S)N)r0rYZ
link_xml_node)r�rararbr��s
r�)�Z
__future__rrrdr	�builtinsrr�r�rr0r�r�r�rWr�r	r�r!�	functoolsrr�collectionsrrr	Zfuture.utilsr
�operatorrZmultiprocessingrZsocketr
Zpathlibrr�Zcldetectlibr�rZclcommonrZclcommon.constrZclcommon.librZclcommon.lib.cleditionrrrrrZclcommon.cpapirrZclcommon.utilsrrrrrrrr r!Zclcommon.clwpos_libr"r#r$Zclcommon.lib.constsr%Zclcommon.lib.cmt_utilsr&Zclcommon.sysctlr'Zclconfigr(r)r*Z	cli_utilsr+r,Zcllimitslib_v2r-r.Z
clveconfigr/Zlveapir0Zcl_summary_arg_parser2�typingr3r4r5r6r7r8r9r:Zclsummary.cl_summary_utilsr;r<r=r>r?r@rArBrCrDrErFrGrHrIrJrKZ!clsummary.rpm_packages_statisticsrLZclsummary.hardware_statisticsrMrNrOZclwizard.modulesrPZ	lve_utilsrQrZvendors_api.configrRrSZ	cldiaglibrTZcl_proc_hidepidrUZclselect.clselectstatisticsrVrWrXrYrZr[Zclselector.selectorlibr\Zclselect.clselectctlr]Z
lvemanagerrr^r�ImportErrorZclflagsr_r�r rsr�r�r�rQr�r�r�ZERRORr�rhr�r��objectr�r�rarararb�<module>s�,(L 

R$