X,'ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlmZmZddlmZmZddlmZddlmZddlmZddlmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ddl%Z&ddl'Z'ddl(Z(ddl)Z)dd l*m+Z+dd l,m-Z-dd l.m/Z/m0Z0m1Z1dd l2m3Z3dd l4m5Z5m6Z6ddl7m8Z8ddl9m:Z:m;Z;mZ>ddl?m@Z@ddlAmBZBddlCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNddlOmPZPmQZQmRZRddlSmTZTddlUmVZVmWZWddlXmYZYmZZZddl[m\Z\ddl]m^Z^ddl_m`ZaddlbmcZcddldmeZemfZfddlgmhZhddlimjZjddlkmlZmmnZndd lompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~mZmZdd!lmZmZmZdd"lmZd#d$lmZd#d%lmZ dd&lmZdd'lmZmZmZmZmZmZdd(lmZdd)lmZddlm`Zn#e$reqZeqZeqZeqZeqZeqZeqZdZdZdZYnwxYw dd*lmZn#e$rd+ZYnwxYw dd,lmZmZn#e$r d-Zd.ZYnwxYwd/Zejd0Zd1Zd2Zd3Zd4Zd5Zd6Zd7Zd8Zd9Zd:ed;eeeffd<Zd=ed;efd>ZGd?d@ZdAZdS)BN)deepcopy)Counter defaultdict) lru_cachepartial) cpu_count)Path)getfqdn)AnyAnyStrCallableDictListOptionalTupleUnion)get_hidepid_typing_from_mounts)cpapi) find_wp_pathsget_wp_cache_plugin get_wp_paths_with_enabled_module)Feature)is_panel_feature_supportedis_wp2_environment) MySQLGovernor) CLEditionsis_cl_shared_editionis_cl_solo_edition)client_activation_data)ACCELERATE_WP_INSTALLED_FROM_CM) SysCtlConf) ExternalProgramFailedget_cl_versionget_rhn_systemid_value get_virt_typegrepis_litespeed_runningis_nginx_runningis_secureboot_enabledis_testing_enabled_repo is_ubuntu run_command)cagefs_statistics_configclconfig_utilsdb_governor_lib)is_email_notification_enabled)print_dictionaryreplace_params)DEFAULTSLimitsDataStorage) EMPTY_LIMITS) ALL_MODULES) PKG_VERSION)LvpMap) CONFIG_PATH_read_config_file)WebsiteCollector)FeatureManager) METRIC_NAMEScollect_net_acct_metrics) SummaryStatusdummy_none_functionget_cl_plus_sender_statusget_client_data_from_jwt_token get_packages_with_lve_extensions$get_statistics_send_status_from_fileis_active_cloudlinux_licenseis_nodejs_selector_installedis_php_selector_installedis_python_selector_installedis_ruby_selector_installedis_sending_process_runningis_statistic_enabledis_statistic_rpm_enabled set_statistic_collection_enabled$set_statistic_rpm_collection_enabled$write_statistics_send_status_to_file) NotSupportedget_cpu_metricsget_memory_metrics)get_rpm_packages_info)parse_cloudlinux_summary_opts)StatisticsDict)get_default_version)get_default_php_versionget_mode_of_php_selectorget_native_version_safeget_php_selector_usageget_versions_statisticsiter_server_applications)CloudlinuxSelectorLib) PKG_RELEASElist_flags_infocgSNrdpy/clsummary/summary.pyrara re)(is_website_isolation_allowed_server_wide#users_with_enabled_domain_isolationcdS)NFrdrdrerfrhrhsureciSrcrdrdrerfririrgrez/var/log/cloudlinux-summary.logzcloudlinux-summaryunknown installed not_installednot_initialized not_selectedenableddisabledz-42)multisite_statusautoupdate_statusmaxcache_statusmaxcache_directive_statusmod_rewrite_statuslogged_user_cache_statuslogged_common_user_cache_statusmobile_cache_status!mobile_separete_cache_file_statustablet_as_mobile_statusssl_separate_cache_file_statushas_dynamic_cookies_statushas_mandatory_cookies_statuswebp_enabled_status status_keyreturnc|dkrdS|dkrdS|d}|dvr|d}d|d d|d fS) a| Return (enabled_name, disabled_name) for a given AccelerateWP plugin status key. Default mapping: - awp_plugin__enabled / awp_plugin__disabled Special cases for reporting readability: - mod_rewrite_status -> awp_plugin_mod_rewrite_block_enabled/disabled - maxcache_directive_status -> awp_plugin_maxcache_directives_present/absent rw)$awp_plugin_mod_rewrite_block_enabled%awp_plugin_mod_rewrite_block_disabledrv)&awp_plugin_maxcache_directives_present%awp_plugin_maxcache_directives_absent_status)has_dynamic_cookieshas_mandatory_cookieshas_ awp_plugin__enabled _disabled) removesuffix removeprefix)rbases rf!accelerate_wp_plugin_metric_namesrs|)))``000bb  " "9 - -D ???  (( ($ ( ( (*G*G*G*G HHre site_dictcnttd|dS)zB Checks if wordpress site has at least one enabled module c|dS)Nrqrd)modules rfz*site_has_enabled_modules..s &"3remodules)anymapvalues)rs rfsite_has_enabled_modulesrs1 s33Yy5I5P5P5R5RSS T TTrec eZdZdZdZejgdeje j eje j eje j gZ dZdZdZdZdZed Zed Zed efd Zed ZedZedZd efdZedZdZdZ ed e!fdZ"edZ#eded efdZ$dZ%dZ&dZ'edZ(ddZ)eddZ*dZ+ed Z,ed!Z-ed"e.e/e/fd e!fd#Z0d$Z1d%Z2ed&e3d'e4d dfd(Z5d)e.e4e3fd*e4d+e!d dfd,Z6d-Z7ed.Z8d/Z9d0Z:d1Z;ed efd2Zed5Z?ed6Z@d7ZAed8ZBdd9ZCdd:ZDd eEe3fd;ZFd eEe3fd<ZGed eEe3fd=ZHdd>ZId?eJd dfd@ZKd?eJd dfdAZLd?eJd dfdBZMddCZNddDZOdEZPdFZQed e3fdGZRedHeSeTd e.ee3ffdIZUdJZVdKZWedLedHeSfdMZXd eYeSeTeSeTe.ee3fffdNZZd eYe[ee[effdOZ\dPedQedRe.eefd e.ee]eSefffdSZ^dTed efdUZ_ee`dVdWZaddXZbddYZcddZZded e.ee3ffd[Zeed\e3d]e3d eEe3fd^Zfed\e3d_e3d eEe3fd`Zgedaehd e3fdbZiedaehd e3fdcZjedaehd e3fddZkedaehd elfdeZmdaehd e3fdfZnedaehd e3fdgZoedaehd e3fdhZpdaehd efdiZqedjedked ehefdlZreded ehfdmZsddnZted efdoZuddpZvedqZwdrZxedsZyedtZzeduZ{ed e!fdvZ|ed e!fdwZ}ed e3fdxZ~ed efdyZedzZd{Zd|Zd}e4d eEe3fd~ZdZdZdZdZdZed e.fdZdZdZd eYe3e3e3ffdZed eYe3effdZdZdZddZddZddZdZdZdZdZdZedZdZd eEe3fdZd eEe3fdZedZedZedZd?eJd ehee3efdffdZde3d?eJd eEeYe3effdZdZe ddededzde3de!dzd ejf dZeddede3d eEdfdZed eEe.fdZedZedZedZedZed eEe.fdZed efdZeded e3fdZed eEe.fdZd e.fdZd eEe.fdZed eEe.fdZed eEe.fdZed efdZdS)CloudlinuxSummaryz/var/lve/dashboard_certificatez/etc/cl_plus/.disabled)pythonrubynodejsz-https://stat-api.cloudlinux.com/api/clos-statz/https://stat-api.cloudlinux.com/api/clos-uploadz-https://stat-api.cloudlinux.com/api/rpm-statsz6https://repo.cloudlinux.com/static/cl-settings-v1.jsonci|_d|_t|_d|_d|_||_d|_t|_ d|_ dSrc) _opts_security_tokenrV statistics_lvpmap _system_id_is_process_not_limitedis_process_not_limitedpackages_by_lenr!sysctlremote_settingsselfs rf__init__zCloudlinuxSummary.__init__sa #*8*:*: &*&B&B&D&D## ll #recttjd}ttjd}| o| S)zm Return true if process is running outside LVE or it's not running by utility `nice` RUNNING_BY_NICERUNNING_IN_LVE)boolosenvironget)is_running_by_niceis_running_in_lves rfrz)CloudlinuxSummary._is_process_not_limitedsP ""*..1B"C"CDD 0@!A!ABB%%?.?*??recD|jt|_|jS)z. Load lvpmap only when needed )r _get_lvpmaprs rflvpmapzCloudlinuxSummary.lvpmaps < &==DL|rercF|jtd|_|jS)N system_id)rr$rs rfrzCloudlinuxSummary.system_ids# ? "4[AADOrec&trdndS)Nubuntu rhel_like)r+rdrerf _get_platformzCloudlinuxSummary._get_platforms$;;7xxK7rec:trtntSrc)r)ENABLEDDISABLEDrdrerf_detect_securebootz$CloudlinuxSummary._detect_secureboots/11?wwx?rectjtjzdfdt dD}|S)Nc3@K|]}tjVdSrc)secretschoice).0_range_for_random_choices rf z=CloudlinuxSummary._generate_security_token.. s. \ \Q0G!H!H \ \ \ \ \ \re@)string ascii_lettersdigitsjoinrange)security_tokenrs @rf_generate_security_tokenz*CloudlinuxSummary._generate_security_tokensI"("6"F \ \ \ \RWXZR[R[ \ \ \\\reci}|j3d}t||d|id|j}t||j|jd}d} tj|j|d}n\#tj $rJ}t|}t||d|iYd}~nd}~wwxYw|j sCd|j d|j }t||d|itd  |d}t|dt r-|d|td n#t&t(f$r6d }t||d|iYndt*$rX}td t||j|dd t.diYd}~nd}~wwxYw|S)NzSecurity token is emptyresultzGetting statistics from server )rr<)paramstimeoutServer 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_loggererror_error_and_exit SUMMARY_URLinforrequestsrRequestExceptionstrok status_codereasonjson isinstancedictupdate_get_smart_advice_statistics TypeError ValueErrorKeyErrortextLOG_FILE)r stat_datamessagerresponsees rf_get_remote_dataz"CloudlinuxSummary._get_remote_data#s   &/G   W % % %  (G!4 5 5 5FD4DFF   "1   6|D$4VRPPPHH( 6 6 6!ffG   W % % %  (G!4 5 5 5 5 5 5 5 5 6 { 6fX5IffU]UdffG OOG $ $ $  (G!4 5 5 5;<<< L 1I)H-t44 P(#**4+L+L+N+NOOO OOJ K K K K:& 6 6 68G   W % % %  (G!4 5 5 5 5 5 n n n   \^abc^d^dfnfs t t t  (,kT\,k,k,k!l m m m m m m m m n s:3BC)AC$$C)A"GAI5 I5AI00I5c |j|jStj|jr||_n2|}||r|nd|_|jSrc)rrpathisfileDASHBOARD_CERTIFICATE_read_token_from_filer_write_token_to_file)rtokens rfrz CloudlinuxSummary.security_tokenRs   +' ' 7>>$4 5 5 W#'#=#=#?#?D 1133E,0,E,Ee,L,L#V55RVD ##recR t|jdd5}||dddn #1swxYwYtj|jddS#t t f$r3}tdt|Yd}~dSd}~wwxYw) z Write security token to file and return success/fail status :param token: generated security token :return: T/F status wutf-8encodingNiTz,Error while writing secure token to file: %sF) openrwriterchmodIOErrorOSErrorrrr)rrfrs rfrz&CloudlinuxSummary._write_token_to_file^s  d0#HHH A                HT/ 7 7 74!      KSQRVV T T T55555 s4A"; A"?A"?A""B&3(B!!B&cD t|jdd5}|pdcdddS#1swxYwYdS#tt f$r3}t dt|Yd}~dSd}~wwxYw)Nrrrz.Error while reading file with secure token: %s) rrreadstriprrrrr)rr rs rfrz'CloudlinuxSummary._read_token_from_filems d0#HHH 0Avvxx~~''/4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0!      MsSTvv V V V44444 s:A(A AAAAAB,(BBcFtjtjdddS)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)detectget_boolean_paramCL_CONFIG_FILErdrerf_detect_old_lve_integrationz-CloudlinuxSummary._detect_old_lve_integrationus-'+1     rec@tjdS)zO Detects presence/absence of lsapi :return: True/False /usr/bin/switch_mod_lsapirrexistsrdrerf_is_lsapi_presentz#CloudlinuxSummary._is_lsapi_presents w~~9:::re interpreterc|dkrtstSnY|dkrtrtntS|dkrt stSn|dkrt stSt |}|tS|dvr@ |drtntS#t$r tcYSwxYw|dkr"| rtntStd|) zP Get selector status for nodejs, python, ruby and php selectors rrrphpN)rrselector_enabledzUnknown interpreter: ) rH NOT_INSTALLEDrIrrFrGr^get_selector_statusrrphp_selector_is_disabledr)rlibs rf_get_status_of_selectorz)CloudlinuxSummary._get_status_of_selectors8 ( " "/11 %$$ % F " "8::M77 M H $ $/11 %$$ % E ! !*C*E*E ! #K00 ; . . . %"%"9"9";";>>???s'B;;CCc|jr|jS tj|d|_|jS#tj$rW}t dt||dt|iYd}~dSd}~wttf$r3}t dt|Yd}~dSd}~wwxYw)N )rz3Request exception while getting remote settings: %srz'Error while parsing remote settings: %s) rrrrrrrrrrr)r settings_urlrs rf_get_remote_settingsz&CloudlinuxSummary._get_remote_settingss   (' ' #+< b#I#I#I#N#N#P#PD ' '( 5 5 5   RTWXYTZTZ [ [ [  (CFF!3 4 4 4 4 4 4 4 4 4I&      FA O O O44444 s$3AC,A B%%C,9(C''C,c|jdrdSttjd}|rdS||j}|dS |dd}|ddo||S#ttf$rW}t d t|| d t|iYd}~dSd}~wwxYw) z- Return cl-statistics status --force-collectTCL_TEST_SYSTEMNFz cl-statisticsz rollout-grouprqz4Error occurred while trying to get rollout group: %sr)rrrrrr* SETTINGS_URL _match_serverrrrrrr)ris_test_environmentsettings rollout_grouprs rf_is_statistics_enabledz(CloudlinuxSummary._is_statistics_enableds :>>+ , , 4"2:>>2B#C#CDD  4,,T->??  5 5$_5oFMO,Y7]D._prepare_metadatasr b!A!ABB b!A!ABB*<*>*>!VFDTDVDV"&"@"@"B"B H Orer-T)rhtaccess)server_metadatarzFError occurred while trying to get decision for htaccess collection=%sN) rrrrr<r get_decision Exceptionrr)rr<r>r0r=htaccess_collectionrs` rf_website_collector_statusz+CloudlinuxSummary._website_collector_statuss     #2:>>2B#C#CDD  4$$[11 "0J"G"G"G"T"TemGQ#U#S#S        e VV % % %IIIIII #"s*A.. B,8)B'!B,'B,c"t|dS)Nint) hash_servers rf _to_numberzCloudlinuxSummary._to_numbers;###reNc|jdS|j}|r |jd|}tj|dd}||d|zzdkS)NT:r)rhashlibsha256encode hexdigestrJ)rurl_numsalt hash_inputrIs rfr/zCloudlinuxSummary._match_servers > !4^  4 N33T33JnZ%6%6%8%899CCEEcrcJ  ,,qG|;AArecd}|r9ts/|dz}tjd|rt)dSdSdSdS)zC Wait for running background process of cl-summary 2rTg?N)rJtimesleep)retriess rf_wait_for_background_processz.CloudlinuxSummary._wait_for_background_processsu  8::  qLG JsOOO 8::         recL |jds |jdrBt|jdtjdd}t|ddS|jds |jdrBt |jdtjdd}t|ddS|jdrpt rd nd }tj|dd }|d tit|dtj d |j dr7| }| |t|j drts3|j ds|ddid ||j dr=||j|jdt(dnt|jddS|sIt.jdtjd}t3||ddid |j dr|j dsWtsIt.jdtjd}t3||ddid |jld}t(|t.jdt8d tjd}t3||d|i|j d!rt rtjd dd }npt3t.jtjdd"t=jd#dd$d%| tjdd}t|dtj d |jdr|j!rMt d&r=tjd dd }t|dtj d dSt3t.jtjdd"dSdS)'Nenabledisablesuccess timestamprT enable-rpm disable-rpmstatus collectingready)rardrsending_statusr get-remote)datarK rpm-packagesr,rz\Sending RPM statistics is disabled by admin. Use --force-collect to ignore admin`s settings.) error_code--sendFsummaryurl save_statuszRPM statistics sentzkStatistics collection is disabled globally. Please, try again later or contact support if it happens again.)rrrazYCollecting 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)rrarz9/usr/sbin/cloudlinux-summary --send --json &> /dev/null & /bin/bash)shell executablecheck) acquire_lock)"rrMrXr1rNrJrrDsysexitrr_print_result_and_exitrKrLr_get_rpm_packages_summary _send_statistics_and_save_statusrRPM_PACKAGES_URLrrr3r?FAILEDrOrrr IN_PROGRESS subprocessrunr[r)rrirdr status_dictrs rf&_actions_before_run_process_as_limitedz8CloudlinuxSummary._actions_before_run_process_as_limitedsq :h  4:i#8  ,TZ-A B B B!% BBD T4 ( ( ( F :l # tz-'@  0L1I J J J!% BBD T4 ( ( ( F :h  %?%A%AN\\wF!%)TTD KK)+O+Q+QR S S S T4 ( ( ( HQKKK :>>, ' ' b**,,F  ' 'VJ^J`J` ' a a a :>>. ) ) +-- djnnEV6W6W $$ #J ! %  * * , , ,z~~h'' 855 O- %6  56666 $777 F**,, '.R!Y[[ K 1 = = =  D !    :>>( # # ::>>"344 =Q=S=S +2J!%  5[AAA$$ #J ! %"*T  )))+26GO666"&  5[AAA$$h%8999 :>>) $ $ )++ G&*Y[[LT]^^ 5,8ty{{^bccO*  11333%)Y[[IFF T4 ( ( ( HQKKK :h  * /IW[/\/\/\  &*Y[[LT]^^ t,,, 5,8ty{{^bcc  rec tjtjddd}tj|5}|dt |gt 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_cpuls_cpus ls_memory_phy--lve-idz/bin/lve_suwrapper-n/usr/sbin/cloudlinux-summary1)rCPU_DATAenvN) lvectllibmake_liblve_settingscreate_liblve_settings temporary_lveextendrrcallrrrrdumps CPUINFO_DATA)argsr1lve_ids rf_run_self_in_lvez"CloudlinuxSummary._run_self_in_lves1  ,,      $X . . & KKS[[1 2 2 2?%tS[[:XY\``J#&"Z (>??                      sBCCCcjtjgd|zttjdS)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/nicer19rr)rr)rrrrr)rs rf_run_self_by_nicez#CloudlinuxSummary._run_self_by_nicesE I I ID P #    reoptsc|tfddDrdStfddDrdSdS)zK Check that passed command should run as unlimited process c3(K|] }|V dSrcrdroptionrs rfrzECloudlinuxSummary._should_run_as_unlimited_process..s;    L       re)rjrdrhr]r^rbrcTc3(K|] }|V dSrcrdrs rfrzECloudlinuxSummary._should_run_as_unlimited_process..s;   L      re)rlrq--jsonr,F)r)rs`rf _should_run_as_unlimited_processz2CloudlinuxSummary._should_run_as_unlimited_processs          4          5urec|||_|jr)|||jrt jddSttj s+| |}t j|dS | |}t j|dS#tj $rc}d|}t|tjt"}||dt jdYd}~dSd}~wwxYw||jr]d}t'j|d}t(||jt-|dt jd |dS) Nrz"failed to run task in lve, error: T)exc_infoz|You shouldn't use env var "RUNNING_IN_LVE" or "RUNNING_BY_NICE" for run of any command except collection of main statistics.r`)extrarT) _parse_argsrrrrrwrxrrLVErrr PyLveErrorprintlogging getLogger__name__ exceptionrXrrr1run_get_summary)rargvrcr error_msglogerr_msgris rfrzCloudlinuxSummary.runs%%d++  &( #  7 7 9 9 944TZ@@ ! / << !++D11 !..t44BHRLLLLL +!!! HQ H HI)$$$!+H55CMM)dM;;;HRLLLLLLLLL !44TZ@@ *"&%    ;;; t,,,  " " " " "s,)CE &AEE cxtj}|tj|z }||jd<|jdr0|jt |j|ddd|jdr||j|j dt d  | dS#t$r&}td |Yd}~dSd}~wwxYwt|jddS) Ncl_summary_execution_timerrcl_summary_max_mem_usedz,Can't get memory usage by cloudlinux-summaryrlTrmzMain statistics sentWebsite collector failed: %s)rX _get_summaryrr add_metricr_get_max_memoryrr{rrrwebsite_collectorrBrr1)r start_time running_timers rfrz!CloudlinuxSummary.run_get_summary sZY[[  y{{Z/ 7C34 :j !  O & &,l;;)>     :>>( # # 4  1 1$  2    OO2 3 3 3 D&&((((( D D D  !?CCCCCCCCC D T_d 3 3 3 3 3sC22 D"<DD"rasummary_resultcvtj|d}|dkr||d<tj|d<t|dS)z@ Save status of sending statistics to json file rrar_rrN)r?SUCCESSr}rO)rarrs rf _save_statuszCloudlinuxSummary._save_status*sJ "/!6YOO Y & &$2K !$1$8K !,[99999rernrorpcttj}||d<|||}||d}t|d|r|||dSdS)zH Send statistics data to server and save status to file ra)rorTN)rHrX_send_statisticsr1r)rrnrorpras_resultrs rfr{z2CloudlinuxSummary._send_statistics_and_save_status7s $$ ( ((c(::$9==&&&            rec |dz }|dkrdSdddt|jdddd ttj|d g} t |d \}}}n3#t $r&}td |Yd}~dSd}~wwxYw|dkrLtj |} td|dDS#ttf$rYdSwxYwtd||dS)NrrTz/usr/sbin/lveinforz--idrz--show-columnsmPMemz--periodmTreturn_full_outputz Unable to run lveinfo, error: %src3&K|] }|dV dS)rNrdrxs rfrz4CloudlinuxSummary._get_max_memory..]s&CC!1W:CCCCCCreriz-lveinfo failed with exit code: %i, output: %s)rrrHmathceilr,r"rwarningrloadsmaxrrr) rr time_minutescmdrjson_strrr parsed_datas rfrz!CloudlinuxSummary._get_max_memoryFsM#b( !  4     :& ' '   49\**++ . . .   )#$GGGOB!!$      A1 E E E44444  77*X..K CC{6/BCCCCCC)   tt H"hWWWts*A)) B3BB7CC+*C+cfd} d|}t|tjd}t dD]P} tj||d}n7#tj$r#}|}tjd|zYd}~Id}~wwxYw||j d krtd 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 statisticsr)rrNzSending statictics OKrr) rrrrrpostConnectionErrorrXrYrrrr)riro out_messager expected_errirerrs rfrz"CloudlinuxSummary._send_statisticscst  *;c;;G OOG $ $ $#45abbL1XX # #'}StRHHHH E  /%%%#&LJq!t$$$$$$$$% #"#s** 78888nX=Qnn]e]lnn  ,,,( * * *c((K   [ ) ) ) ) ) ) ) ) *sCAC, A" C,"B1B C,BAC,,D.;)D))D.c "|jstddStjt jkrtddStd}||}t dt|| ddkstd dStj rtd dS | d }tt| }||jpt|dn| d d|t#rdntj||j| dddS#t($r&}td|Yd}~dSd}~wwxYw)z4 Collect data via WebsiteCollector. z:Website collector is disabled because system_id is not setNz,Website collector is disabled for non-cPanelFcheck_expirationzWebsite collector status: %sdecisiononz0Website collector is disabled by remote settingsz.Website collector is disabled via opt-out file domains_limit)logger max_sitesr6r7config_versionrl)rr6platformpanelserverapi_urlremote_config_versionr)rrdebugrr:r CPANEL_NAMErBrDrrrr;is_collection_disabled send_dataUNKNOWN_RHN_IDrr_get_control_panel_apacheWEBSITE_COLLECTOR_URLrBr)rr<website_collector_statusr collectorrs rfrz#CloudlinuxSummary.website_collectors ~    Y Z Z Z4    !2 2 2   K L L L44eLLL $(#A#A+#N#N 6&B&BCSU^&_&_            ;Q ? ? ?44444 sC G H(H  Hcdtjd}||j||SNrT)versionra)rX_prepare_cl_normal_statisticsrrrrs rfrzCloudlinuxSummary._get_summarysBTY[[99 **,,, v&&& recdtjd}||j||Sr)rX'_fill_dict_with_rpm_packages_statisticsrrrs rfrzz+CloudlinuxSummary._get_rpm_packages_summarysBTY[[99 44666 v&&& rec@tjtjS)z. Get version of control panel )rgetCP CP_VERSIONrdrerf_get_panel_versionz$CloudlinuxSummary._get_panel_versions    rec.|jtjd\}}|st|jd<dS|H||jd<|jdddd|jd ddd dSt |jd<dS) zN Fill dict with statistics by statistics about MySQL governor zCan't get MySQL governor modemysql_governor_statusNmysql_governor_modecBtSrc)rget_governor_versionrdrerfrzCCloudlinuxSummary._fill_mysql_governor_statistics..s <<>>rermysql_governor_versionz Can't get MySQL governor versioncNtdSNr)rget_governor_statusrdrerfrzCCloudlinuxSummary._fill_mysql_governor_statistics..s ;;==a@rezCan't get MySQL governor status)r evaluate_safer/get_gov_mode_operationERRORrr")rr_mysql_gov_modes rf_fill_mysql_governor_statisticsz1CloudlinuxSummary._fill_mysql_governor_statisticss #'/"?"?  2 +# #  E7>(2     O & &@@'1      8EDO3 4 4 4rec|jtjddd|jdddd|j|jddd |j|jdd d |jt d d d|jdd ddtjtjkr"|j|j d dd|j|j d dd|jtd dddS)zM Fill dict with statistics by statistics about control panel rcontrol_panel_namezCan't get control panel namec`dtjDS)Ncg|] \}}|| Srdrd)rname is_supporteds rf zVCloudlinuxSummary._fill_control_panel_statistics....s#nnn0dLamnTnnnre)rget_supported_cl_featuresitemsrdrerfrzBCloudlinuxSummary._fill_control_panel_statistics..s*nnE4S4U4U4[4[4]4]nnnrestr_listsupported_cl_featuresz8Can't get list of supported cl features by control panelcontrol_panel_versionzCan't get control panel versioncontrol_panel_apachezCan't get control panel apacherH nginx_runningzCan't get control panel nginxcBttjSrc)lenrcpusersrdrerfrzBCloudlinuxSummary._fill_control_panel_statistics..s3u}+?+?re users_totalzCan't get amount of usersinstalled_via_plesk_extz8Can't determine if CL was installed from Plesk Extensionlogin_via_whmcs_in_usez)Can't determine if Login via WHMCS in userz Can't if that is WP2 environmentN) rrrr:rrr(r PLESK_NAME_is_installed_via_plesk_ext_is_login_via_whmcs_in_userrs rf_fill_control_panel_statisticsz0CloudlinuxSummary._fill_control_panel_statisticss ""    *    "" n n  # F    ""  #  # -     ""  *  " ,    ""#3UOMlmmm ""#?#? Wrsss    !1 1 1 O & &0)J     ""  +  $ 7     "" ';=_     rec d}tjtjkr|Sgd}t j|ddd}t j|j}d|vr{d|dvrq|ddD]b}|ddkrTd }t| d d | d d | d d grd}nc|S)zA Determine whether the login method is via WHMCS r)z/usr/local/cpanel/bin/whmapi1&get_available_authentication_providersz--output=jsonprettyT)capture_outputrruri providers provider_namewhmcsrwhostmgrd_enabledFcpaneld_enabledwebmaild_enabledrT) rr:rrrrrrstdoutrr)rdcommandrriproviders rfr*z,CloudlinuxSummary._is_login_via_whmcs_in_uses     !2 2 2Mttt4tTTTz&-(( T>>kT&\99 L5  O,77F$LL)>' " " F rectr/tjrd}nDtjrd}n.d}n+|jddkrtjrdnd}nd}|S) z Wrapper to retrieve control panel Apache version: EA3 or EA4 for cPanel, native otherwise :return: EA3|EA4|native litespeed openlitespeedunknown_litespeedrcPanelEA4EA3native)r'rdetect_enterprise_litespeeddetect_open_litespeedris_ea4rs rfrz+CloudlinuxSummary._get_control_panel_apacheNs~ ! ! 133 -$-// -(- _1 2h > >$moo8UU5FFF rectj}||Stjttjt dt dti}||dS)z Wrapper to convert internal values from cagefs_statistics_config.get_cagefs_status function to values for statistics :return: NEnabledDisabledUnknown) r-get_cagefs_statusCAGEFS_STATUS_NOT_INSTALLEDr"CAGEFS_STATUS_NOT_INITIALIZEDNOT_INITIALIZEDrrr) cagefs_statuscagefs_status_maps rf_cagefs_status_wrapperz(CloudlinuxSummary._cagefs_status_wrapperbsX1BDD   $ @- $ BO w    !$$]I>>>rec|jtdddt|jfdddd|jfdddd d S) z= Fill dict with website isolation statistics rH%website_isolation_allowed_server_widez0Can't detect status of support website isolationc"tSrcr# per_user_statsrfrzFCloudlinuxSummary._fill_website_isolation_statistics..C &&re%website_isolation_enabled_users_totalzACan't detect total amount of users with enabled website isolationcZtdDS)Nc34K|]}t|VdSrcrS)rdomainss rfrzYCloudlinuxSummary._fill_website_isolation_statistics....s(KKG KKKKKKresumrrTsrfrzFCloudlinuxSummary._fill_website_isolation_statistics..s*CKKM4H4H4J4JKKKKKre(website_isolation_enabled_websites_totalzDCan't detect total amount of websites with enabled website isolationN)rrrhri)rrUs @rf"_fill_website_isolation_statisticsz4CloudlinuxSummary._fill_website_isolation_statisticsts "" 4  3 >    <==  "" & & & &  3 O    "" K K K K  6 R      rec|j|jddd|jdttfvr d|jd<n'|jt jddd|jtt jdddd |jtt jd dd d dS) zF Fill dict with statistics by statistics about CageFS rrMzCan't get CageFS statusNcagefs_user_modezCan't get CageFS user modeTcagefs_enabled_quantityz/Can't get quantity of users with enabled CageFSFcagefs_disabled_quantityz0Can't get quantity of users with disabled CageFS) rrrOr"rLr-get_cagefs_user_moder get_quantityrs rf_fill_cagefs_statisticsz)CloudlinuxSummary._fill_cagefs_statisticss ""  '   %    ?? + /O O O26DO. / / O & &(=",     "" ,94 @ @  % =    "" ,95 A A  & >      recD td|jD}n#tj$rYdSwxYwt |jjtfd| DS)zJ Get amount of end-users which belong to active resellers c3,K|]\}}|dk |VdSrNrdrrlvps rfrzLCloudlinuxSummary._get_amount_of_endusers_under_resellers..2YY3QTWXQXQXQXQXQXQXYYreNc3 K|]}|vV dSrcrd)rlvp_idenabled_lvp_ids rfrzLCloudlinuxSummary._get_amount_of_endusers_under_resellers..s(OO6^+OOOOOOre) rr lve_lvp_pairsrrPsetname_mapid_listr\elements)r lvp_countrns @rf'_get_amount_of_endusers_under_resellersz9CloudlinuxSummary._get_amount_of_endusers_under_resellerss YY$+2K2K2M2MYYYYYII!   44 T[199;;<<OOOO):L:L:N:NOOOOOOs04AAc td|jD}n#tj$rYdSwxYwt |S)z/ Get total amount of end-users c3,K|]\}}|dk |VdSrhrdris rfrzBCloudlinuxSummary._get_total_amount_of_endusers..rkreN)rrrorrPr\r)rrts rf_get_total_amount_of_endusersz/CloudlinuxSummary._get_total_amount_of_enduserssr YY$+2K2K2M2MYYYYYII!   44 9##%%&&&s03AAcp ttjS#tj$rYdSwxYw)z) Get amount of resellers N)r#r resellersrPrdrerf_get_amount_of_resellersz*CloudlinuxSummary._get_amount_of_resellerssB  u(()) )!    DD s "55cjtjjdddjtjjdddjtjjdddjjddd jjdd d jj dd d jfddddjdr jdddddSdjd<djd <djd<dS)zP Fill dict with statistics by varied statistics about resellers rH 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 panelreseller_limits_enabledz1Can't detect status of support of reseller limitsresellers_totalz#Can't get total amount of resellers(resellers_endusers_under_reseller_limitsz>Can't get amount of end-users which belong to active resellersresellers_endusers_totalz#Can't get total amount of end-usersc,Src)_get_resellers_with_faultsrsrfrz>CloudlinuxSummary._fill_resellers_statistics..sD3355reresellers_with_faultsz:Can't get amount of resellers with faults for the past 24hc\tttjSrc)r#listrlvp_listrdrerfrz>CloudlinuxSummary._fill_resellers_statistics..sD!3!5!56677reresellers_activez$Can't get amount of active resellersN) rrrlveis_lve10is_panel_supportedreseller_limit_supportedr{rurxrs`rf_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 & &77"6      37DO. /JNDOF G7;DO3 4 4 4rexml_cfg_providerc|jt|jjt jjt jddd|jt|jjt jddd|jfdddd |jfd dd d |jfd ddd|jfdddd|jfdddd|jt|j jt j ddd|jt|j jt j ddddS)zN Fill dict with statistics by statistics about default limits rHdefault_limit_speedzCan't get default speed limitrdefault_limit_cpu_origin_unitsz+Can't get cpu origin units of default limitc2jtjSrc)defaultsr3ncpursrfrzCCloudlinuxSummary._fill_default_limits_statistics.."$-h7<redefault_limit_ncpuzCan't get default ncpu limitc2jtjSrc)rr3iorsrfrzCCloudlinuxSummary._fill_default_limits_statistics..($-h7:redefault_limit_iozCan't get default io limitc2jtjSrc)rr3nprocrsrfrzCCloudlinuxSummary._fill_default_limits_statistics...s$-h7=redefault_limit_nproczCan't get default nproc limitc2jtjSrc)rr3eprsrfrzCCloudlinuxSummary._fill_default_limits_statistics..4rredefault_limit_epzCan't get default ep limitc2jtjSrc)rr3iopsrsrfrzCCloudlinuxSummary._fill_default_limits_statistics..:rredefault_limit_iopszCan't get default iops limitdefault_limit_vmem_mbzCan't get default vmem limitdefault_limit_pmem_mbzCan't get default pmem limitN) rrr_cpu_limit_to_percentsrr3cpur_get_cpu_limit_units_mempages_to_mbvmempmemrrs `rf_fill_default_limits_statisticsz1CloudlinuxSummary._fill_default_limits_statistics s "" + )(37 )(38    ! +  "" D-/?/H/R/V W W  , 9    "" < < < <  *    "" : : : :   (    "" = = = =  ! +    "" : : : :   (    "" < < < <  *    "" D(*:*CH*M*R S S  # *    "" D(*:*CH*M*R S S  # *      rec |jfdddd|jfdddd|jfddd d |j|jdd d d S)z Fill dict with statistics by other statistics about limits: packages_total, users_total, amount users/packages with custom limits c,tjSrc)r#packagesrsrfrzACloudlinuxSummary._fill_other_limits_statistics..SsC(122rerHpackages_totalz"Can't get total amount of packagescFtSrc)r#get_packages_with_custom_limitsrsrfrzACloudlinuxSummary._fill_other_limits_statistics..YsC(HHJJKKrepackages_with_custom_limitsz/Can't get amount of packages with custom limitscFtSrc)r#get_users_with_custom_limitsrsrfrzACloudlinuxSummary._fill_other_limits_statistics.._sC(EEGGHHreusers_with_custom_limitsz,Can't get amount of users with custom limitsusers_with_faultsz6Can't get amount of users with faults for the past 24hN)rr_get_users_with_faultsrs `rf_fill_other_limits_statisticsz/CloudlinuxSummary._fill_other_limits_statisticsLs "" 2 2 2 2   0    "" K K K K  ) =    "" H H H H  & :    ""  '   D      rectddD]}jtj||d|d\}|rdSjfddd|d d jfd d d|d d jfdd d|dd jfddd|dd jfdd d|dd jfdd d|dd jfdd d|dd jfdd d|dd jfdd d|dd jfdd d|dd jfdd d|dd dS) zV Fill dict with statistics by statistics about top packages on server rTrzCan't get top z package by usersNcdjSNrTr top_resultsrfrzACloudlinuxSummary._fill_top_packages_statistics..~s 1 *rertop_ _package_name log_messagec.tdSr rGrsrfrzACloudlinuxSummary._fill_top_packages_statistics..sJqM**rerH_package_users_numcdjptjdjptjSr)rlimitsr5rrrrsrfrzACloudlinuxSummary._fill_top_packages_statistics..s;33])9\>])9\?re_package_limit_speedc\djptjSr)rrr5rrsrfrzACloudlinuxSummary._fill_top_packages_statistics..s)11])9\>re_package_limit_cpu_origin_unitsc6djptjSr)rr5rrsrfrzACloudlinuxSummary._fill_top_packages_statistics..A-=Cre_package_limit_ncpuc6djptjSr)rr5rrsrfrzACloudlinuxSummary._fill_top_packages_statistics..A-=Are_package_limit_ioc6djptjSr)rr5rrsrfrzACloudlinuxSummary._fill_top_packages_statistics..sA-=Dre_package_limit_nprocc6djptjSr)rr5rrsrfrzACloudlinuxSummary._fill_top_packages_statistics..rre_package_limit_epc6djptjSr)rr5rrsrfrzACloudlinuxSummary._fill_top_packages_statistics..rre_package_limit_iopsc\djptjSr)rrr5rrsrfrzACloudlinuxSummary._fill_top_packages_statistics..$,,jm.B.Rl-XYYre_package_limit_vmem_mbc\djptjSr)rrr5rrsrfrzACloudlinuxSummary._fill_top_packages_statistics..rre_package_limit_pmem_mb)rrrr#_get_top_package_by_number_of_usersr)rrrr_rs` @rf_fill_top_packages_statisticsz/CloudlinuxSummary._fill_top_packages_statisticskss q!R R A"&/"?"?@!EUVV5555## GZ  j0 O & &****'q''' '    O & &****,q,,, '    O & &.q...  '    O & &9q999 '    O & &CCCC-q--- '    O & &AAAA+q+++ '    O & &DDDD.q... '    O & &AAAA+q+++ '    O & &CCCC-q--- '    O & &YYYYY0q000 '    O & &YYYYY0q000 '    [R R rect}||||||dS)zN Fill dict with statistiscs by varied statistics about limits N)r4rrrrs rf_fill_limits_statisticsz)CloudlinuxSummary._fill_limits_statisticssU-.. ,,-=>>> **+;<<< **+;<<<<.sv.x8rerlsapi_criu_service_statusrc ddS)Nrrrdrsrfrz:CloudlinuxSummary._fill_lsapi_statistics..sv.y9relsapi_criu_service_versionc ddS)N lsapiConf lsapi_criurdrsrfrz:CloudlinuxSummary._fill_lsapi_statistics..s{3LArelsapi_option_criuc ddS)Nrlsapi_with_connection_poolrdrsrfrz:CloudlinuxSummary._fill_lsapi_statistics..s{34PQrelsapi_option_connection_poolcdS)N libVersionrdrsrfrz:CloudlinuxSummary._fill_lsapi_statistics.. |4relsapi_lib_versioncdS)N modStatusrdrsrfrz:CloudlinuxSummary._fill_lsapi_statistics..s {3recdS)N modVersionrdrsrfrz:CloudlinuxSummary._fill_lsapi_statistics..rrelsapi_mod_versioncdS)N totalDomainrdrsrfrz:CloudlinuxSummary._fill_lsapi_statistics..s }5rerHlsapi_total_domain_countcdS)N domainStatrdrsrfrz:CloudlinuxSummary._fill_lsapi_statistics..rreint_dictlsapi_domain_statcdS)N controlPanelrdrsrfrz:CloudlinuxSummary._fill_lsapi_statistics..s ~6relsapi_apache_environment)rrget_raw_lsapi_inforrr")rr_rs @rf_fill_lsapi_statisticsz(CloudlinuxSummary._fill_lsapi_statisticss #'/"?"?  # *# # A @27DO. / / /  ' O & &8888+ '    O & &9999, '    O & &AAAA# '    O & &QQQQ. '    O & &4444# '    O & &3333" '    O & &4444# '    O & &5555* '    O & &4444# '    O & &6666* '     3@DO. / / /recJ|j|jddddS)Nstr_dict wmt_configz!Cant get status of wmt_api_config)rr_get_wmt_api_configrs rf_fill_wmt_settings_statisticsz/CloudlinuxSummary._fill_wmt_settings_statisticss3 ""  $j,@c     rec \ } nF#t$r9}tdt |ggic } Yd}~nd}~wwxYwt t t |z } |\ nD#t$r7}tdt |iic Yd}~nd}~wwxYw|r$ dt|ij fddddj fdd d d j fd d d dj fddddj fddddj fdd ddj j dddj fdd\}}|rt|ts2t D](}t#|\}}dj |<dj |<)dSt D]j}t#|\}}t%||dj |<t%||dj |<kdS)Nz+Error while getting WordPress statistics %sz3Error while getting WordPress plugins statistics %scloudlinux_wpos_object_cachec"tSrcrS) all_wp_pathssrfrz7CloudlinuxSummary._fill_wp_statistics..6sC %%rerHwordpress_installed_totalz,Can't get total count of installed wordpresscSrcrdobject_cache_pluginssrfrz7CloudlinuxSummary._fill_wp_statistics..<s(rerwordpress_object_cache_pluginsz&Can't get WP object cache plugins infocSrcrdadvanced_cache_pluginssrfrz7CloudlinuxSummary._fill_wp_statistics..Bs*re wordpress_advanced_cache_pluginsz(Can't get WP advanced cache plugins infocFtSrcr[rsrfrz7CloudlinuxSummary._fill_wp_statistics..HsC,335566re$wordpress_object_cache_plugins_totalz,Can't get WP object cache total plugins infocFtSrcr[rsrfrz7CloudlinuxSummary._fill_wp_statistics..NsC.557788re&wordpress_advanced_cache_plugins_totalz.Can't get WP advanced cache total plugins infocSrcrd)wp_php_versionssrfrz7CloudlinuxSummary._fill_wp_statistics..TsOrewordpress_php_versionszCan't get WP php version info4awp_sites_count_with_wp_config_php_backup_in_docrootz>Can't analyze sites with wp-config.php.backup in document rootc.Src)'_get_accelerate_wp_plugin_status_counts)rrsrfrz7CloudlinuxSummary._fill_wp_statistics..^sD@@NNrez3Can't analyze accelerate_wp_plugin status.php filesr)_prepare_wp_statisticsrBrrrrrp_prepare_wp_plugins_statisticsrr#rr-_count_sites_with_wp_config_backup_in_docrootrrr ACCELERATE_WP_PLUGIN_STATUS_KEYSrrHr) rpaths_with_wpos_object_cacherwithout_wpos_object_cacher_accelerate_wp_plugin_countsr enabled_name disabled_namerrrr s ` @@@@rf_fill_wp_statisticsz%CloudlinuxSummary._fill_wp_statistics!s UJNJeJeJgJg GL6 U U U   JCPQFF S S SJLbRT GL6 U%)\):):SA]=^=^)^$_$_! B;?;^;^)<< 8 "8"8 B B B   RTWXYTZTZ [ [ [;=r 8 "8"8"8"8"8"8 B ( m ' ')GMiIjIj(k l l l "" % % % %  ' :    "" ( ( ( (  , 4    "" * * * *  . 6    "" 6 6 6 6  2 :    "" 8 8 8 8  4 <    "" # # # #Z1IKj    ""  >  B L    04/L/L N N N N N A0 0 ,, hj)DdKK h> 5 5 .OPZ.[.[+ m03 -14 .. 5 5 ? h h .OPZ.[.[+ m034O4S4ST`bc4d4d0e0e -145P5T5TUbde5f5f1g1g .. h hs, A#/AA#B,, C-6-C((C-cd}i}d}tjD]} tj|}n?#t$r2}tdt |Yd}~Od}~wwxYw|D]p\}}|s||vrW tj tj ||||<n#t$rd||<YnwxYw||r|dz }q|S)zk Count how many sites (domains) have old wp-config.php.backup file in their document root. zwp-config.php.backupr(Can't get user's domains info, error: %sNFrT) rr$ userdomainsrBrrrrrrrr)backup_filenamedocroot_has_backupaffected_domainsuser domains_infordomaindocroots rfr(z?CloudlinuxSummary._count_sites_with_wp_config_backup_in_docrootls< 1.0MOO * *D $066      !KSQRVVTTT $0 * *"444<68gnnRW\\RY[jEkEk6l6l*733"<<<6;*7333<&g.*$)$ * s'2 A.(A))A.ACCCwp_pathscpi}tD]}t|\}}d||<d||<t}|D]}|dz dz dz } |s$n#t$rY1wxYw t |ddd5}|} d d d n #1swxYwYn#t$rYwxYwt| d krd | d d  } | s tj | } n#t$rYwxYwt| ts| D]\} } | |vr || t| ts5tD]}| |d} t'|}n#t(t*f$rd}YnwxYw|d kr#t|\}}||xxd z cc<kt|\}}||xxd z cc<ː|S) z Parse wp-content/wp-rocket-config/status.php files (JSON after the first line) and count how many unique domains have each *_status enabled/disabled. rz wp-contentzwp-rocket-configz status.phpr rreplace)rerrorsNrN rT)r)rrpis_filerrr  splitlinesr#rr rrrBrrraddrrHrr)r:countsrr-r. seen_domainswp_root status_pathr linespayloadrir8metricskeyval normalizedrs rfr$z9CloudlinuxSummary._get_accelerate_wp_plugin_status_countss "$: & &J*KJ*W*W 'L-#$F< $%F= ! !EE 1 31 3G!L03EE TK "**,,     +sWYOOO2STFFHH//11E222222222222222    5zzA~~iiabb **0022G  z'**    dD)) #'::<< 3 3\))  (((!'400; 3 3C!++c1--C'%(XX %z2'''%& '"Q*KC*P*P a|,,,1,,,,+LS+Q+Q(=}---2---- 3 3, slA A+*A+/C'B5) C5B9 9C<B9 =C C CD-- D;:D;>GG$ #G$ cB |\nC#t$r6}tdt |ggYd}~nd}~wwxYw|jfdddd|jfdddddS) Nz4Error while getting per-user WordPress statistics %sc"tSrcrS) users_with_wpsrfrz@CloudlinuxSummary._fill_per_user_wp_statistics..rVrerH$users_count_with_wordpress_installedz7Can't get total count of users with wordpress installedc"tSrcrS)users_with_wp_and_litespeedsrfrz@CloudlinuxSummary._fill_per_user_wp_statistics..sC344re0users_count_with_wordpress_and_lscache_installedzECan't get total count of users with wordpress and LiteSpeed installed)_prepare_per_user_wp_statisticsrBrrrrr)rrrNrQs @@rf_fill_per_user_wp_statisticsz.CloudlinuxSummary._fill_per_user_wp_statisticss -9=9]9]9_9_ 6M66 - - -   SUXYZU[U[ \ \ \M*, ' ' ' ' ' ' - "" & & & &  2 E    "" 4 4 4 4  > S      s A,AAcb|d|}|d|}||fS)zq Prepares dict with plugin-counter pairs e.g: {'w3-total-cache': 4, 'redis': 1, 'ls': 2} object-cacheadvanced-cache)_get_plugin_info)rr:rrs rfr'z0CloudlinuxSummary._prepare_wp_plugins_statisticss= $44^XNN!%!6!67G!R!R#%;;;re plugin_typecttdfd|D}tt}|D]}||xxdz cc<|S)Nc0g|]}t|Srd)r)rrrYs rfrz6CloudlinuxSummary._get_plugin_info..s%1n1n1n]a2EdK2X2X1n1n1nrerT)rfilterrrH)rYr:robject_plugin_counter_pairsplugins` rfrXz"CloudlinuxSummary._get_plugin_infoss#F41n1n1n1nem1n1n1n$o$opp&1#&6&6#* 5 5F ' / / /1 4 / / / /**recjgg}}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)rrHrr$r2rBrrrrappend_get_docroot_wp_inforr#) rr$paths_with_enabled_wpos_object_cache php_versions panel_usersr6r7docroot_domains_mapr8r9 docroot_infodocroot_wp_pathsdocroot_php_versions rfr&z(CloudlinuxSummary._prepare_wp_statisticss >@: "3'' moo  O OD $066     #.d"3"3 #/ @ @7>>'**@'077???. O O#88wH[\\ #/ #; &2=&A###$45554;;LIr>'**@'077???. : :#88wH[\\ |J/00144!%%d+++|$KLMMPQQQ/33D999  :999sA  B(BBr6r9rhcggtdd}fdtD}|s|Sfd|D|d< fdt||D|d<n*#t$rtdYnwxYw|dD]} t |d }n,#t$rtd d }YnwxYw|d |vr|d | t |d}n,#t$rtdd }YnwxYw|d |vr|d |D]$} || } | dkr| |d<n%|S)zM Return data about docroot's WP paths and used php versions. rb)r:rarmr`cg|]J}tj|ks"tj|vH|KSrd)rrr)rwp_pathr9rhs rfrz:CloudlinuxSummary._get_docroot_wp_info..?sZ    Wg..'99RW\\'SZ=[=[cv=v=v =v=v=vrecTg|]$}t|%Srdr joinpathrrr9s rfrz:CloudlinuxSummary._get_docroot_wp_info..Is-#V#V#VTDMM$:$:4$@$@#V#V#Vrer:cXg|]&}|t|'Srcrrrts rfrz:CloudlinuxSummary._get_docroot_wp_info..Ls@GGG#W &&t,,###reraz:Can't get WordPress sites with enabled Object Cache modulerVz0Can't get Object Cache plugin for Wordpress siteNr;rmrWz2Can't get Advanced Cache plugin for Wordpress siter`) rprrrBrrrrA_get_php_version_for_domain) rr6r9rhrir:robject_cache_pluginadvanced_cache_pluginr8r`s `` rfrdz&CloudlinuxSummary._get_docroot_wp_info1ss7958UU&        (11     #V#V#V#VX#V#V#V Z  _GGGG266G+Os7||mO<BB3GGK-+ -  re)maxsizec tjd}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_idNdomains_by_php_version)rget_system_php_inforBget_domains_php_infor[)system_php_versionrphp_selector_usagers rfrz&CloudlinuxSummary._get_system_php_infos &!&!:!. y/Brer  ssa_configzCan't get SSA configcdS)Nrrdrsrfrz8CloudlinuxSummary._fill_ssa_statistics..s ),rer ssa_versionzCan't get version of SSAcdS)Nrdrdrsrfrz8CloudlinuxSummary._fill_ssa_statistics..rrezCan't get state of SSAcdS)N agent_statusrdrsrfrz8CloudlinuxSummary._fill_ssa_statistics..s .1ressa_agent_statuszCan't get state of SSA agentc ddS)N autotracingrdrdrsrfrz8CloudlinuxSummary._fill_ssa_statistics..s -0:reautotracing_statusz"Can't get state of SSA Autotracingc ddS)Nrdisabled_users_quantityrdrsrfrz8CloudlinuxSummary._fill_ssa_statistics..s -01JKrerH#autotracing_disabled_users_quantityz1Can't get state of SSA Autotracing disabled usersc ddS)Nr rules_versionrdrsrfrz8CloudlinuxSummary._fill_ssa_statistics.. -0Areautotracing_rules_versionz'Can't get SSA Autotracing rules versionc ddS)Nrurls_processedrdrsrfrz8CloudlinuxSummary._fill_ssa_statistics..s -01ABreautotracing_urls_processedz.Can't get SSA Autotracing processed URLs countc ddS)Nr urls_selectedrdrsrfrz8CloudlinuxSummary._fill_ssa_statistics..rreautotracing_urls_selectedz-Can't get SSA Autotracing selected URLs countc ddS)Nrrejectsrdrsrfrz8CloudlinuxSummary._fill_ssa_statistics..s -0;rerautotracing_rejectsz!Can't get SSA Autotracing rejects)rr get_ssa_statsrrr")rr_rs @rf_fill_ssa_statisticsz&CloudlinuxSummary._fill_ssa_statisticss;"_::   &    ,1DOL ) F  O & &'B'B'B'BJP\^t u u u O & &,,,,e]D^    O & &'B'B'B'BE.s+E22rez+Can't get statistics about PHP interpretersselector_php_statusNr rz Can't get status of PHP selectorrselector_php_versions_installedrselector_php_versions_enabledselector_php_version_defaultz,Can't get default version of PHP interpreterselector_php_version_nativez+Can't get native version of PHP interpreterrHselector_php_enabled_uiz%Can't get state of UI of PHP selectorselector_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_interpretercLddDS)Nc4i|]\}}|t|SrdrSrvrZs rf zUCloudlinuxSummary._fill_php_selector_statistics....+s$sssGQG sssrerrphp_usage_summarysrfrzACloudlinuxSummary._fill_php_selector_statistics..+s)ss?PQi?j?p?p?r?rsssrercLddDS)Nc4i|]\}}|t|SrdrSrs rfrzUCloudlinuxSummary._fill_php_selector_statistics....1s$qqqGQG qqqreusers_by_php_versionrrsrfrzACloudlinuxSummary._fill_php_selector_statistics..1s)qq?PQg?h?n?n?p?pqqqre)rrrrrr&"_get_list_versions_of_interperters INSTALLEDrrXrZr^php_selector_is_enabledrYr[r")rr_php_interpretersrs @rf_fill_php_selector_statisticsz/CloudlinuxSummary._fill_php_selector_statisticss %)O$A$A 2 24a% % !!B C5:DO1 2 2 2  ) O & &4e<<%2     O & &?AQS\]]1 '    O & &?AQSZ[[/ '    O & &'.>     O & &'-=     O & &%e,,D)7     O & &(#0     *.)F)F&9** &G& /7MQ IJKO GHHH**ssss= $ + **qqqq; $ +6CDO1 2 2 2recJ|j|jddddS)z Fill dict with statistics about PHP handler usage across domains. Collects the count of domains using each PHP handler type (e.g. cgi, suphp, fpm, lsapi, dso). rphp_handler_domains_countz Can't get PHP handler statisticsN)rr_get_php_handler_domain_countsrs rf_fill_php_handler_statisticsz.CloudlinuxSummary._fill_php_handler_statistics9s7 ""  /  ' .      rectj}i}|D]5}|dpd}||ddz||<6|S)zY Return a mapping of PHP handler type to the number of domains using it. r|rlrrT)rrrr)rhandler_counts domain_infors rfrz0CloudlinuxSummary._get_php_handler_domain_countsFss !577)++2244 I IK!oon55BG&4&8&8!&D&Dq&HN7 # #re total_appsamount_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 rTNrd)rrs rf_get_average_apps_per_domainz.CloudlinuxSummary._get_average_apps_per_domainRs) >>6::4666reamount_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 rTNrd)rrs rf_get_average_apps_per_userz,CloudlinuxSummary._get_average_apps_per_user^s) >>4q884444reappsc4td|DS)z Get amount of running applications on server :param apps: list of applications for something selector c6g|]}|j |jdk|S)started) app_status)rapps rfrz@CloudlinuxSummary._get_amount_of_runned_apps..qs,ZZZC3>ZcnPY>Y>YC>Y>Y>YrerS)rs rf_get_amount_of_runned_appsz,CloudlinuxSummary._get_amount_of_runned_appsjs!ZZ4ZZZ[[[rect}|D]}||jxxdz cc<|dpdg}|ddS)z Get maximum amount of applications per domain :param apps: list of applications for something selector rTrrr)rdoc_root most_common)rapps_per_domainr most_commonss rf_get_max_apps_per_domainz*CloudlinuxSummary._get_max_apps_per_domainssh")) / /C CL ) ) )Q . ) ) ) )'22155A& Aq!!rect}|D]}||jxxdz cc<|dpdg}|ddS)z~ Get maximum amount of applications per user :param apps: list of applications for something selector rTrr)rr6r)r apps_per_userrrs rf_get_max_apps_per_userz(CloudlinuxSummary._get_max_apps_per_usersh  ) )C #( # # #q ( # # # #%0033?x Aq!!recVt}|D]}||jxxdz cc<|S)z Get Counter object which contains amount applications per version of interpreter :param apps: list of applications for something selector rT)rr)rapps_per_versionrs rf_get_counter_apps_per_versionz/CloudlinuxSummary._get_counter_apps_per_versionsD#99 / /C S[ ) ) )Q . ) ) ) )recx||}|dpdg}|ddS)z Get maximum amount of applications per version of interpreter :param apps: list of applications for something selector rTrr)rr)rrrrs rf_get_max_apps_per_versionz+CloudlinuxSummary._get_max_apps_per_versionsC  ==dCC(33A66B6( Aq!!reczt}|D]}||jt|S)zz Get amount of domains with applications :param apps: list of applications for something selector )rprArr#)rrZrs rf _get_amount_of_domains_with_appsz2CloudlinuxSummary._get_amount_of_domains_with_appss?%% & &C KK % % % %7||reczt}|D]}||jt|S)zx Get amount of users with applications :param apps: list of applications for something selector )rprAr6r#)rusersrs rf_get_amount_of_users_with_appsz0CloudlinuxSummary._get_amount_of_users_with_appss?  C IIch    5zzrecJ||}t|S)z Get amount of applications per each version of interpeters :param apps: list of applications for something selector )rr)rrrs rf4_get_amount_of_apps_per_each_version_of_interpreterszFCloudlinuxSummary._get_amount_of_apps_per_each_version_of_interpreterss'  ==dCC$%%%reinterpreters_statsstatecDfd|DS)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|]\}}| |Srdrd)rinterpreter_statsstatrs rfrzHCloudlinuxSummary._get_list_versions_of_interperters..s,kkk&=&7_cdi_jk!kkkrer)rrs `rfrz4CloudlinuxSummary._get_list_versions_of_interperterss-lkkkASAYAYA[A[kkkkrecFt|}|t|SgS)zI Get list of apllications on server for defined selector )r]r)r iter_appss rf_get_list_of_applicationsz+CloudlinuxSummary._get_list_of_applicationss( -[99   ?? " rec X|jD]}|jtt|d|d\}}|t |jd|zdz<P|st |jd|zdz<h|jt|j|dd|zdz|rd|dnd|jt|j |td d|zd zd |jt|j |td d|zd zd |jt|j |d |d\}|sY|jfddd|zdzd |jd|zdzdk|jd|zdz<|jt|j dd|zdzd |jtt|d|d\}}|r|||jd|zdz<|jt|jdd|zdzd|d|jt|jdd|zdzd|d|jt|jdd|zdzd|d|jt|jdd|zdzd |d|jt|j|jd|zdz|jd|zdzd!|d\}}|r|||jd|zd"z<|jt|j|jd|zdz|jd|zdzd#|d\}}|r|||jd|zd$z<|jt|jd%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_rrzCan't get status of z selectorr_versions_installedr_versions_enabledzCan't get list of z applicationsc"tSrcrS)interpreter_appssrfrz>CloudlinuxSummary._fill_selectors_statistics.. s,--rerH_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 ) SELECTORSrrrr\r"rrr&rrrrrrWrrrrrrr)rselectorr_rdefault_version_of_selectoraverage_apps_per_domainaverage_apps_per_userrs @rf_fill_selectors_statisticsz,CloudlinuxSummary._fill_selectors_statisticss o o H*./*G*G/::EhEEE++ 'G'")FS h 6 BC FK h 6 BC O & &4h??h&2>EO:x::::4     O & &?ASU^__h&)>> '    O & &?ASU\]]h&)<< '    )-(E(E6AA_v h 69[ [\-1_-J-J3OK($:=S$STOK($:=S$ST `___ .. *G* s0<]r h 69Y YZ O & &QScddh&)KK____     Uo o recddg}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-wizardrdTrr wizard_statusc,i|]}|d|dS)rrdrd)rrs rfrz.j s#```v&.&*:```rerwizard_module_)r,r"rrr6r NOT_SELECTED)rret_codestd_outstd_err parsed_jsonwizard_statisticsparsed_modulesrs rf_get_wizard_statisticsz(CloudlinuxSummary._get_wizard_statistics\ s -h7%0%N%N%N"'7 q=='00 0j)) -8-I/*``U^I_```! d dF;I;M;MfVb;c;c .7 8 8  rec|j|jd\}|jfddddtD]'|jfdddzd(dS) zX Fill dict with statistics by varied statistics about cloudlinux-wizard z,Can't get statistics about cloudlinux-wizardcdS)Nrrd)r"srfrz;CloudlinuxSummary._fill_wizard_statistics..| s %o6rerrNrcdzS)Nrrd)rr"srfrz;CloudlinuxSummary._fill_wizard_statistics.. s)*:V*CDrer)rrr$rr6)rrrr"s @@rf_fill_wizard_statisticsz)CloudlinuxSummary._fill_wizard_statisticsp s $<<  ' :    "" 6 6 6 6   #   "  F O & &DDDDD 6) '      rect}g}|D],}|t||z }-|S)zH Returns list of implemented scripts in integration.ini )r:rkeys)rscriptssections rf$_get_implemented_integration_scriptsz6CloudlinuxSummary._get_implemented_integration_scripts sL #$$ 4 4G tF7O002233 3GGrecdgd}tjts|Sd|d<||d<|S)zh Checks integration script exists and if exists get list of implemented scripts F)integration_scripts_usedintegration_scripts_specifiedTr/r0)rrrr9r-rs rf_get_integration_infoz'CloudlinuxSummary._get_integration_info sT /4VXYYw~~k** M-1)*262[2[2]2]./ recd}tj}t|j|z }t|j|z }||fS)zG Gets memory usage: total and used memory in megabytes i)psutilvirtual_memoryfloattotalused) bytes_in_mbmem mem_totalmem_useds rf_get_memory_usedz"CloudlinuxSummary._get_memory_used sH  #%%#)$${2 ??[0(""recHtj}d}d}ttjrot j|rPt|dd5}| }dddn #1swxYwY||fS)za Gets kernel info release and module version (starting from 7h) :return: z/sys/module/kmodlve/versionNr rr) rreleaserrrrrrrr r )kernel_releasekmodlve_version_filekmodlve_versionr s rf_get_kernel_infoz"CloudlinuxSummary._get_kernel_info s ")++< %gk 2 2 3rw~~FZ7[7[ 3*C'BBB 3a"#&&((.."2"2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3..s"'BBBc8ttS)zp Gets info about lve extensions usage Calculates amount of packages with lve extensions )r#rCrdrerf#_get_lve_extensions_packages_amountz5CloudlinuxSummary._get_lve_extensions_packages_amount s 355666rec d}tj|sdSt|dd5}|}dddn #1swxYwYt t|S)zk Reads /proc/sys/fs/datacycle/enable in order to check datacycle enabled parameter z/proc/sys/fs/datacycle/enableFr rrN)rrrrr r rrH)datacycle_filer ris rf$_is_kernel_datacycle_enabled_in_filez6CloudlinuxSummary._is_kernel_datacycle_enabled_in_file s 9w~~n-- 5 .# 8 8 8 $A6688>>##D $ $ $ $ $ $ $ $ $ $ $ $ $ $ $CIIs'A))A-0A-cd\}}tj|sdSt|dd5}|d}dddn #1swxYwY||vS)zR Checks if datacycle parameter was given for current boot )z /proc/cmdline datacycleFr rr N)rrrrr r split) cmdline_filerr ris rf_is_datacycle_param_was_passedz0CloudlinuxSummary._is_datacycle_param_was_passed s $@ jw~~l++ 5 ,g 6 6 6 /!6688>>##))#..D / / / / / / / / / / / / / / /T!!s:A??BBctj}d}|D]&}|ttj|z }'|S)z= Returns general amount of domains on server r)rr$r#r2) cpusers_list domains_countr6s rfr;z+CloudlinuxSummary._get_total_domains_amount sH }    : :D S!24!8!899 9MMrect}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_createall symlinks_onlyhardlinks_onlyno)r!rrHr)rsymlink_protection_enabledhardlink_protection_enableds rf%_is_link_traversal_protection_enabledz7CloudlinuxSummary._is_link_traversal_protection_enabled s %)#fjj9W.X.X*Y*Y%Z%Z"&*3vzz:Y/Z/Z+[+[&\&\# % *E 5 % #"? & $##trecd}d}d}tjdstjdr|Stjdr|S|S)Nisocldeployqcow2z/etc/cl-convert-savedz/var/log/cldeployz/etc/cloudlinux-qcow2-installr)rZr[r\s rf_get_cl_installation_sourcez-CloudlinuxSummary._get_cl_installation_source sd 7>>1 2 2 bgnnEX6Y6Y O 7>>9 : : L recttjrgjjdddjjdddjfddddtd s#jtdd djtdd djtdd djj dd djj dddjfddddjjdddjfddddjfddddjfddddjfddddjjdddttjr jfd dd!d"jt$dd#d$jt&dd%d&jjdd'd(dS))NrHlve_extension_packages_amountrr!link_traversal_protection_enabledcdSrrd kernel_infosrfrz;CloudlinuxSummary._fill_system_statistics.. s Areinstalled_kmod_lve_versionTskip_jwt_checkcldiag_cron_check_enabled cpu_amounttesting_repository_enabled base_distrozCan't detect platform for CLOSsecureboot_statusz+Can't detect whether secure boot is enabledcdSr rdrbsrfrz;CloudlinuxSummary._fill_system_statistics..7 s KNrer?cgroupzCan't get cgroup informationcdS)Nr/rdvendor_integration_infosrfrz;CloudlinuxSummary._fill_system_statistics..@ s+,FGrer/cdS)Nr0rdrosrfrz;CloudlinuxSummary._fill_system_statistics..F s+,KLrerr0cdSr rd memory_usagesrfrz;CloudlinuxSummary._fill_system_statistics..N LOrer5memory_total_mbcdSrrdrssrfrz;CloudlinuxSummary._fill_system_statistics..Q rurememory_used_mb domains_totalcTpSrc)rGrMrsrfrz;CloudlinuxSummary._fill_system_statistics..Y s$BBDDmHkHkHmHmrekernel_datacycle_usage_enabledz,Can't get kernel datacycle enabled parameter virt_typez!Can't get the virtualization typehostnamezCan't get the hostnamecloudlinux_installation_sourcezCan't get installation source)rBrrrrrrDrXrr0rr*rrget_cgroup_versionr1r<r;r%r r])rrcrtrps`@@@rf_fill_system_statisticsz)CloudlinuxSummary._fill_system_statistics s++-- %gk 2 2  O & &8/ '    O & &:3 '    O & &&&&&, '   "666  O & &-+ '    ""9e\t"TTT "" #  ( #    ""4#5umMmnnn ""  #U,?An    "" " " " "E+; #    ""  #UH6T   #'"<"<">"> "" G G G G  & #   "" L L L L  + #   ,,..  "" # # # #W.?T #    "" # # # #W.>D #    ""  *E?PT #    &gk 2 2  O & &nnnn0>     "" 5+/R    ""7E:?WXXX ""  ,  , +      recjfddddjtdddjtddd dS) Nc jptSrcrrrsrfrzKCloudlinuxSummary._fill_dict_with_rpm_packages_statistics..n DN4nrerrCan't get system ID os_versionzCan't get version of OS rpm_stat_listrz*Can't get info about client's rpm packages)rrr#rSrs`rfrz9CloudlinuxSummary._fill_dict_with_rpm_packages_statisticsl s "" 4 4 4 4   !    "">5,Habbb "" !?J@l     reparamcZtj|j|S)z Retrieve data from proc/mounts for param :return: param_value - Optional[int], if there is no value - None )r. str_to_intrr)rrs rf_get_proc_paramz!CloudlinuxSummary._get_proc_paramx s# ()?)?@@@rec Hdg}ttjr|gd|D]I}|jt |j|d|ddd|J|jtdddd 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_taskrHr{r Can't get hidepidzCan't get hidepid valueN) rrrrrrrrr<rr parametersps rf_fill_proc_params_statisticsz.CloudlinuxSummary._fill_proc_params_statistics s '  &gk 2 2            A O & &,a00 #s## Q       "" *   %      rec d}|D]9}|jt|j|dd|d|d:dS)zJ Fill dict with statistics about kmodlve parameters usage )lve_setuid_enterrHkmodlve_z Can't get "z" kmodlve parameter valueN)rrr_get_kmodlve_param_valuers rf_fill_kmodlve_params_statisticsz1CloudlinuxSummary._fill_kmodlve_params_statistics sk+   A O & &5q991;q;;;       rech|jr|jdnd}g}|; |t|n#tt f$rYnwxYwt |pd}tD]5}|j t|j |d|d|6dS)u\ Fill dict with LVE Traffic Accounting metrics from /proc/lve/list (CLOS-4341). cloudlinux-summary re-execs itself inside a transient self-LVE (see _run_self_in_lve) — that LVE shows up in /proc/lve/list while we run and would inflate counts by 1. We pass our own --lve-id so the parser skips it. rN) skip_user_idsrHr) rrrcrHrrr>NET_ACCT_METRIC_NAMESrrr __getitem__)r own_lve_idskip_idsrHrs rf_fill_net_acct_statisticsz+CloudlinuxSummary._fill_net_acct_statistics s48:GTZ^^J///4   ! J0000z*    *9ITJJJ)  D O & &+T22#T##       s"A A A ctd|jfdddd|jfdddd |jfd dd d |jfd ddd|jfdddd|jttddddS)zv Fill statistics fields from jwt token. - jwt token metrics (cl_plus existence and client_id) Frc8dnddS)Ncl_plusrrisrfrz=CloudlinuxSummary._fill_cln_jwt_information.. sDLDDdhhy$.G.GrerHrzCan't get cl_plus informationc8dnddS)Nr6rrsrfrz=CloudlinuxSummary._fill_cln_jwt_information.. sDLDDdhh{D.I.Irer6zCan't get client_id valuec8dnddS)Nis_awp_premium_allowedrrsrfrz=CloudlinuxSummary._fill_cln_jwt_information.. sDLDDdhh7OQU.V.Vrejwt_is_awp_premium_allowedz&Can't get is_awp_premium_allowed valuec8dnddS)Nis_awp_cdn_allowedrrsrfrz=CloudlinuxSummary._fill_cln_jwt_information.. sDLDDdhh7KT.R.Rrejwt_is_awp_cdn_allowedz"Can't get is_awp_cdn_allowed valuec8dnddS)Nis_trialrrsrfrz=CloudlinuxSummary._fill_cln_jwt_information.. sDLDDdhhz4.H.Hrejwt_is_trial_licensez$Can't get jwt_is_trial_license valuelicense_activezCan't get license status valueN)rBrrrrE)rris @rf_fill_cln_jwt_informationz+CloudlinuxSummary._fill_cln_jwt_information sD .uEEE "" 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@PRr     recjfddddjtddddS) za Filling stats centralized management - centralized management existence cLtjjSrc)rrrCL_PLUS_CM_DISABLED_PATHrsrfrzKCloudlinuxSummary._fill_centralized_management_statistics.. sBGNN4#@AArerHcentralized_management_disabledzCan't check CM disabling statusrcl_plus_sender_service_statusz)Can't check cl plus sender service statusN)rrrArs`rf'_fill_centralized_management_statisticsz9CloudlinuxSummary._fill_centralized_management_statistics sf "" A A A A  - -     "" %  + 7      rec2i} t}|D]H}|D]1\}}|d|g|2In9#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)rQr setdefaultrcrrPrr)r cpu_corescpu_coremetricvalueexs rfmake_flat_cpu_metricsz'CloudlinuxSummary.make_flat_cpu_metrics s: B'))I% I I%-^^%5%5IIMFE%%oVoor::AA%HHHHI I& B B B   z2Act like CageFS is disabled (unable to create LVE)T) fixed_stringmultiple_searchdata_from_filez)>&#'V%)(,'1 $$ -00@,A,A)),-()*&,-)+-CE^^ ^! ! ! ! == !sC C C"!C"c Dt}|dvrPtjtjdz }|d}d|d}nd}t j|ddd t jt j d }|j |j fS) z Scan /var/log/messages for all needed "Act like CageFS is disabled ..." messages for yesterday :return: Tuple (ret code, std_out string) )cl6cl6hrT)daysz%Y-%m-%dz/usr/share/cloudlinux/logs-at z< /var/log/messages | /bin/grep 'Act like CageFS is disabled'za/usr/bin/journalctl --since yesterday --until today | /usr/bin/grep 'Act like CageFS is disabled'TrrF)rrsrtr5stderrru) r#datetimedatetoday timedeltastrftimerrPIPEDEVNULLrr5)os_typeyesterday_date date_to_scans_cmdrs rfrz$CloudlinuxSummary._get_data_from_log s !"" o % %&]0022X5GQ5O5O5OON)22:>>LNNNN ExE N "?%   |QX%%recttjr"jjdddt jd<jttj dddd jj dd d jj dd d jj dddjfddddjfddddt!ttdtjd<n djd<dS)NrHold_way_of_integration_used*Can't detect old LVE integration mechanismlve_utils_versionF) verify_expr cl_editionzCan't get CloudLinux editionis_solo_meta_file_presentz$Can't detect solo meta file presenceis_admin_meta_file_presentz%Can't detect admin meta file presenceis_container_meta_file_presentz)Can't detect container meta file presencecjSrcrrsrfrzACloudlinuxSummary._prepare_cl_normal_statistics.. D'rer$Can't get or generate security tokenc jptSrcrrsrfrzACloudlinuxSummary._prepare_cl_normal_statistics.. rrerrr}lvemanager_version)rrrrrrLVE_UTILS_PKG_VERSIONrrget_cl_edition_is_solo_marker_exists_is_admin_marker_exists_is_container_marker_existsLVEMANAGER_PKG_VERSIONLVEMANAGER_PKG_RELEASE_fill_dict_with_statisticsrs`rfrz/CloudlinuxSummary._prepare_cl_normal_statistics s %gk 2 2  O & &0-<     0E+, "" J-% @ @ @%Wu    ""  '0KMs    ""  (%1MOv    ""  ,  , 7    "" ' ' ' '   2     "" 4 4 4 4   !    " -2H2T7M4h4hPf4h4hDO0 1 148DO0 1 '')))))rec d dd d d d}tj sdSGdd t fd } d d d i}d tj D}||D]/} |||#$rYt $r |D]}d ||<Y,wxYw| |j <| |j <| |j <tjdr d|j|<dStjdr 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/iQlve_number_of_opensxray_number_of_installationxray_number_of_visitsxray_advanced_metrics_statusNceZdZdS)ECloudlinuxSummary._fill_lvemanager_statistics..BreakOuterLoopN)r __module__ __qualname__rdrerfBreakOuterLoopr  s Drer ctj} |z}t|dd5}d}|D]} d|ddd}tj|d}| z |cxkr|krnnd|ddd} | dkr| xxd z cc<n0| d kr|xxd z cc<n| d kr|xxd z cc<nd }#ttf$rYwxYw|r  ddddS#1swxYwYdS) Nr rrFrJrNz%Y-%m-%d %H:%M:%S,%fzlvemanager-openedrTzxray-install-startedzxray-tab-clickedT) rnowrarrrKstrptimer rAttributeError)statsfilecurrent_date_timestamp file_pathr break_outer_looplinelog_timelog_date_timestamprr COLLECTING_PERIOD LOG_FOLDERLVE_NUMBER_OF_OPENSXRAY_NUMBER_OF_INSTALLSXRAY_NUMBER_OF_VISITSs rffill_statisticszFCloudlinuxSummary._fill_lvemanager_statistics..fill_statistics s#%-%6%:%:%<%<%F%F%H%H ""T)Iiw777 )1#( !!D!#&88DJJsOOBQB,?#@#@-5->-G-GRh-i-i-s-s-u-u*14EEHZssss]ssssss&)hhtzz||/A/A#/F/Fqrr/J&K&KG&*=== %&9 : : :a ? : : : :!(,B!B!B %&= > > >! C > > > >!(,>!>!> %&; < < < A < < EE<E'#E<&E''E<<FFrc<g|]}tjd||S)z^lvemanager\.log(\.\d{1,2})?$)rematch)rrs rfrzACloudlinuxSummary._fill_lvemanager_statistics.. s+qqqdIiko@p@pqTqqqrerz./opt/alt/php-xray/php/advanced_metrics.enabledrqz//opt/alt/php-xray/php/advanced_metrics.disabledrrnone) rrisdirrBlistdirsortrrr) rXRAY_ADVANCED_METRICS_STATUSrr log_fileslog_filerr rrrrrs @@@@@@rf_fill_lvemanager_statisticsz-CloudlinuxSummary._fill_lvemanager_statistics s, %3"? 7'E$w}}Z((  F     Y    ) ) ) ) ) ) ) ) ) )0*1.CQH_abc rqbj&<&<qqq ! * *H * H5555!    * * *&**D')Jt$$** *2<U3V/0/9:M/N+, 7>>J K K C?R0S,---rec~|jdddd|jdddddS) z: Fill dict with feature flags information c2dtDS)Ncg|] }|j Srdrrr s rfrzVCloudlinuxSummary._fill_feature_flags_statistics....K s777QV777rer`rdrerfrzBCloudlinuxSummary._fill_feature_flags_statistics..K s77_%6%6777rerserver_flags_availablez3Can't get information about available feature flagsc2dtDS)Nc*g|]}|j |jSrd)rqrr7s rfrzVCloudlinuxSummary._fill_feature_flags_statistics....Q s!DDD!)DQVDDDrer`rdrerfrzBCloudlinuxSummary._fill_feature_flags_statistics..Q sDD_%6%6DDDreserver_flags_enabledz1Can't get information about enabled feature flagsN)rrrs rf_fill_feature_flags_statisticsz0CloudlinuxSummary._fill_feature_flags_statisticsF sb "" 7 7  $ A    "" D D  " ?      recd}d}d}d}d}d}d}d}tj|r|}tj|r|}tj|r|}||j|<dS) z8 Fill out AccelerateWP promotion status accelerate_wp_promotion_statusenabled_for_current_serverenabled_for_all_serversskippedz,/var/lve/clflags/enable_awp_all_servers.flagz,/var/lve/clflags/enable_awp_this_server.flagz$/var/lve/clflags/skip_awp_setup.flagN)rrrr) rFIELDENABLED_FOR_CURRENT_SERVERENABLED_FOR_ALL_SERVERSSKIPPEDenable_awp_all_servers_flagenable_awp_this_server_flagskip_awp_setuprds rf(_fill_accelerate_wp_promotion_statisticsz:CloudlinuxSummary._fill_accelerate_wp_promotion_statisticsW s 1&B"";'U#&T#? 7>>5 6 6 -,F 7>>5 6 6 0/F 7>>. ) ) F!'recvjfddddjfddddtjd<t!ttd tjd <n djd <jjd d d dS)NcjSrcrrsrfrz7CloudlinuxSummary._prepare_statistics..v rrerrrc jptSrcrrsrfrz7CloudlinuxSummary._prepare_statistics..| rrerrrr}rrHrr)rrrrrrrrs`rf_prepare_statisticsz%CloudlinuxSummary._prepare_statisticss s "" ' ' ' '   2     "" 4 4 4 4   !    0E+, ! -2H2T7M4h4hPf4h4hDO0 1 148DO0 1 ""  ,  ) 8    '')))))recttjr|ttjr<|||ttjr| ttj r<| | | ttjr|ttjs2ttjsttjr|t)ds|ttjr|ttjr|||||||| |!|"|#|$|%|&|'|(|)|*dS)NTre)+rrGOVERNORrCAGEFSrer^rRESELLER_LIMITSrrrrr PHP_SELECTORr RUBY_SELECTORPYTHON_SELECTORNODEJS_SELECTORrrrLSAPIrWIZARDr( _fill_wpos_activation_statistics_fill_wpos_statisticsrr+rrrrr rr)r/rTr3r<rI_fill_apache2nginx_statisticsrs rfrz,CloudlinuxSummary._fill_dict_with_statistics s %g&6 7 7 3  0 0 2 2 2 %gn 5 5 8  ( ( * * *  3 3 5 5 5  5 5 7 7 7 %g&= > > .  + + - - - %gk 2 2 -  ( ( * * *  0 0 2 2 2  * * , , , %g&: ; ; 1  . . 0 0 0 &w'< = = .)'*ABB .*'*ABB .  + + - - -!666 ;  8 8 : : : %gm 4 4 *  ' ' ) ) ) %gn 5 5 +  ( ( * * * --/// ""$$$ &&((( ++--- ))+++ $$&&& ))+++ &&((( **,,, !!### ((***   """ ))+++ ##%%% ++--- 55777 **,,,,,recJ|j|jddddS)Nr apache2nginxz Can't parse Apache2Nginx metrics)rrget_apache2nginx_statsrs rfrZz/CloudlinuxSummary._fill_apache2nginx_statistics s5 ""  '   .      rec|jdddd|jtd\}|jfddd|rdnddS) NcJtjtSrc)rrrr rdrerfrzDCloudlinuxSummary._fill_wpos_activation_statistics.. sBGNN#BCCrerH.cmt_is_accelerate_wp_free_activation_completedz2Can't get statistic of AccelerateWP CMT activationz,Can't get AccelerateWP activation statisticsc.dS)Naccelerate_wp_free_activater)client_activationsrfrzDCloudlinuxSummary._fill_wpos_activation_statistics.. s%))*GHHre&cmt_accelerate_wp_free_activated_in_uiz;Can't get statistic of AccelerateWP CMT activation selected)rrrr)rr_rcs @rfrXz2CloudlinuxSummary._fill_wpos_activation_statistics s "" C C  < @    &*_%B%B " :& & "" "" H H H H  4MT ^ I IZ^      recD  |j|jd\} |sdSt trW ddkr? d |j fdddd d  |j fd dd d|j fd d dd|j fdd dd dr |j fdd dd dD]- dkr |j fdd d zd. dgD]& |j fdd d zd' dD]- dkr |j fdd d zd. dgD]& |j fdd d zd' d!gD] |j fd"d d# zd d$} d%} |xr#|jfd&d d#|zd |x r#|j fd'd d#|zd dgD]- dkr |j fd(d d) zd. d*iD]\ }||jd+ z<|j fd,d d-d|j fd.d d/d|j fd0d d1d2|j fd3d d4d5|j fd6d7d8d9|j fd:d7d;d<|j fd=d7d>d?|j fd@d7dAdB dCx}r+|D]\}}||jdD|<dSdSdSdS)ENz!Can't get AccelerateWP statisticsrr_features_visible_by_defaultcdS)Nrfrd wpos_statssrfrz9CloudlinuxSummary._fill_wpos_statistics.. J'DErer wpos_features_visible_by_defaultz*Can't get statistic of using AccelerateWP.features_allowed_by_defaultcdS)Nrlrdrhsrfrz9CloudlinuxSummary._fill_wpos_statistics.. rjre wpos_features_allowed_by_defaultc ddS)N enabled_sitesr6rdrhsrfrz9CloudlinuxSummary._fill_wpos_statistics..  ?3G<rerHsites_count_with_enabled_wposc ddS)N allowed_usersr6rdrhsrfrz9CloudlinuxSummary._fill_wpos_statistics.. rqreusers_count_with_allowed_wpos visible_usersc ddS)Nrvr6rdrhsrfrz9CloudlinuxSummary._fill_wpos_statistics.. sJ7@reusers_count_with_visible_wposrpr6c dS)Nrprdrrisrfrz9CloudlinuxSummary._fill_wpos_statistics.. J7?resites_count_with_enabled_ enabled_usersc dS)Nr}rdrzsrfrz9CloudlinuxSummary._fill_wpos_statistics.. r{reusers_count_with_enabled_rtc dS)Nrtrdrzsrfrz9CloudlinuxSummary._fill_wpos_statistics.. r{reusers_count_with_allowed_allowed_suitesc dS)Nrrdsuiterisrfrz9CloudlinuxSummary._fill_wpos_statistics..$ J'78?reusers_count_with_allowed_suite_enabled_suitesc dS)Nrrdrsrfrz9CloudlinuxSummary._fill_wpos_statistics..+ rreusers_count_with_enabled_suite_ _billable _non_billablecSrcrd)enabled_billablesrfrz9CloudlinuxSummary._fill_wpos_statistics..6 s 0recSrcrd)enabled_non_billablesrfrz9CloudlinuxSummary._fill_wpos_statistics..> s 4rec dS)Nrvrdrzsrfrz9CloudlinuxSummary._fill_wpos_statistics..H r{reusers_count_with_visible_ upgrade_urls upgrade_url_cdS)N4accelerate_wp_suite_enabled_premium_suite_disallowedrdrhsrfrz9CloudlinuxSummary._fill_wpos_statistics..S s #YZrercdS)N1accelerate_wp_suite_enabled_premium_suite_visiblerdrhsrfrz9CloudlinuxSummary._fill_wpos_statistics..Y s #VWrerc.dS)Nis_accelerate_wp_flag_enabledrrhsrfrz9CloudlinuxSummary._fill_wpos_statistics..`  'FGGrerz1Can't get statistic of AccelerateWP feature flag.c.dS)Nis_accelerate_wp_icon_enabledrrhsrfrz9CloudlinuxSummary._fill_wpos_statistics..f rrerz0Can't get statistic of AccelerateWP icon status.c.dS)N%is_smart_advice_notifications_enabledrrhsrfrz9CloudlinuxSummary._fill_wpos_statistics..m s 'NOOrerrzJCan't get statistic of AccelerateWP is_smart_advice_notifications_enabled.c.dS)N!is_smart_advice_reminders_enabledrrhsrfrz9CloudlinuxSummary._fill_wpos_statistics..s s 'JKKrerzFCan't get statistic of AccelerateWP is_smart_advice_reminders_enabled.c.dS)N+is_smart_advice_plugin_installation_enabledrrhsrfrz9CloudlinuxSummary._fill_wpos_statistics..y s 'TUUrerzPCan't get statistic of AccelerateWP is_smart_advice_plugin_installation_enabled.c.dS)Nis_object_cache_banners_enabledrrhsrfrz9CloudlinuxSummary._fill_wpos_statistics.. s 'HIIrerzDCan't get statistic of AccelerateWP is_object_cache_banners_enabled.r1 awp_whmcs_) rrget_wpos_statsrrrr format_metricr) rr_billable_suite_metricnon_billable_suite_metric upgrade_url whmcs_statsrIrrrrrris @@@@@rfrYz'CloudlinuxSummary._fill_wpos_statistics s"o;;   /    F j$ ' 'a @JNN8,D,D ,Q,Q~~;<<H**EEEE6@  ~~;<<H**EEEE6@  O & &<<<</<     O & &<<<</<     ~~o.. **@@@@3@ %_5  W$$**?????/&8@  %.."==  **?????/&8@  %_5  W$$**?????/&8@  $(8"==  **?????5=@  $(8"==  **?????5=@ ,1(;(;(;%/4,C,C,C)'1~~6K'L'LL#O1100009>:S+T+TT'O1144449>))s$AB (BB c6|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. rrrs rfrz(CloudlinuxSummary._get_users_with_faults  7799!<> $## 3   rec|dSd|zdzS)z/Convert memory limit from mempages to megabytesNrird)rs rfrz!CloudlinuxSummary._mempages_to_mb s =45yD  rech|dStj||pd}|dSt|dz dS)z,Convert cpu and ncpu to percents of one coreNr)lncpugY@rT)rconvert_to_kernel_formatround)rrrs rfrz(CloudlinuxSummary._cpu_limit_to_percents sE ;423diaHHH =4UU]A&&&re.c|jtt|j}d|D}t d|D}t d|Dd|_d|jD}|r%t dd |D|jS) zC Return list of tuples [users_in_package, package] Nc^g|]*}|j t|jjt(|+Srcpackagerrrrr6s rfrz?CloudlinuxSummary.get_users_amount_per_plan.. s><+ 4<;Lc0R0R++++rec3$K|] }|jV dSrc)rrs rfrz>CloudlinuxSummary.get_users_amount_per_plan.. s$$J$JdT\$J$J$J$J$J$Jrec$g|] }|dddS)Nrrd)ritems rfrz?CloudlinuxSummary.get_users_amount_per_plan.. s"*Y*Y*Y$4":*Y*Y*YreT)reversec^g|]*}|jt|jjt(|+Srcrrs rfrz?CloudlinuxSummary.get_users_amount_per_plan.. s><'z$,:KS/Q/Q''''rez0Found invalid package names in original data: %sc*g|]}|j|jfSrd)idrrs rfrz?CloudlinuxSummary.get_users_amount_per_plan.. s!GGGdgt|,GGGre) rrrrrrsortedrrr)rrusers_package_copy valid_userspackage_counts invalid_userss rfget_users_amount_per_planz+CloudlinuxSummary.get_users_amount_per_plan s   '!)$/?/E/L/L/N/N*O*O!P!P !3K %$J$Jk$J$J$JJJN#)*Y*Y.BVBVBXBX*Y*Y*Ycg#h#h#hD !1!7!>!>!@!@M   FGGGGG##re number_of_topcb |||dz S#t$rYdSwxYwr)r IndexError)rrrs rfrz5CloudlinuxSummary._get_top_package_by_number_of_users sI 112BCCMTUDUV V   44 s  ..crt|\}}|s"|t||S)z% Parse CLI arguments )rUrr2)rrrdris rfrzCloudlinuxSummary._parse_argss>5T::  7  !5!5 6 6 6 rer_rrri exit_coderKc|tj|d}|||d<t|dtj|dS)z? Print data in default format for web and exit )rrariNstatistic_enabledT)rXr1rwrx)rrirrKrs rfryz(CloudlinuxSummary._print_result_and_exitsP$$)++tLL  ++?G' ($''' rerTrrkc|dtjit|dtj|dS)z Print error and exit :param dict message: Dictionary with keys "result" as string and optional "context" as dict raTN)rrXr1rwrx)rrks rfrz!CloudlinuxSummary._error_and_exit sG  TY[[1222$''' rectjdrHtjddgdtjtjd}t j|jSdS)zD Return mod_lsapi info from switch_mod_lsapi script rz--statTFrr5rruN) rrrrrrrrr5rs rfrz$CloudlinuxSummary.get_raw_lsapi_info*sg 7>>5 6 6 (,h7!! A:ah'' ' ( (recdd}tr|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-getTFrrc4i|]\}}|t|Srd)r)rkrs rfrz9CloudlinuxSummary._get_wmt_api_config..Js$%[%[%[DAqaQ%[%[%[reN) rrrrrrrrrr5rr)r6rwmt_api_config_summarys rfr z%CloudlinuxSummary._get_wmt_api_config9s B     w G 7>>' " " *.)Z_U_UdlqA&*Z%9%9%=%=h%G%G "%[%[>>rec@tjdS)Nz/etc/cloudlinux-containerrrdrerfrz-CloudlinuxSummary._is_container_marker_existsVsw~~9:::rectjdr3tjddgddd}t j|jSdS)zL Return statistics from cloudlinux-ssa-manager get-stat API z /usr/sbin/cloudlinux-ssa-managerget-statTFrr.ruNrrrrrrrr5rs rfrzCloudlinuxSummary.get_ssa_statsZs_ 7>>< = = (3Z@t\`hmA:ah'' '  ( (rec4d}d}d}d}tj|rtj|rlt}|dkrXtj|}tj|}d}t ||z |krd}d}t jtj krmtj|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.logcl8i'rTzHAn upgrade inhibitor detected\|Workflow interrupted due to the FailPhasez'Starting stage After of phase FirstBootT)rNrNz Great SUCCESS)r-r.) rrrr#getmtimeabsrr:rrnextr&)r. leapp_logfileelevate_cpanel_logfilecldeploy_logfilecurrent_os_version leapp_mtimecldeploy_mtimemonth_in_secondsupgrade_status fail_grep_strfirst_boot_grep_str fail_grep_resfirst_boot_grep_ressuccess_grep_strgrep_res stat_results rfr/z!CloudlinuxSummary.get_leapp_statses : !>2 7>>- ( ( *RW^^>$   4j1TY^___A:ah''++F33 3 4 4rec"ddd}tdsy|j|jd\}}|T |d|ddS#t$r5}t dt|||cYd}~Sd}~wwxYw|S) z= Construct dict with Smart Advice statistics N)smart_advice_totalsmart_advice_appliedT)skip_marker_checkz!Can't get Smart Advice statisticsr6appliedzAUnexpected json response from server, field %s is missing in "%s")rrrrrrrr)rrr_sa_statsrs rfrz.CloudlinuxSummary._get_smart_advice_statisticss)-dKK $d;;; " $ = =+3!! GX#"2:72C]efo]pqqq"""(([]`ab]c]cem"MMMMMM "  sA B *BB B ci}tjdrtddd5}t j|}t ||d<t|}d|D}t ||d<t d|D|d <g|d <g|d <|D]}|d d kr9| d}|r!|d  |dG|d dkr8| d}|r!|d  |dtt|d |d <tt|d |d <t d|D|d<t d|D|d<t d|D|d<t d|D|d<t d|D|d<dddn #1swxYwYtjdrStddd5}| |d<dddn #1swxYwY|j|jd\} } | s|S| D] \} } | || < |S)zP Return statistics by parsing /var/lib/apache2nginx/server.json z!/var/lib/apache2nginx/server.jsonr rrtotal_websitesc<g|]}|d|S) proxy_reasonrrs rfrz.s)HHH!%%2G2GH1HHHretotal_proxy_passc*g|]}|ddk|S)r directiverdrs rfrz.s)8p8p8pqqQ_O`doOoOoOoOoOoreproxy_pass_due_directivefailing_directivesfailing_handlersrr proxy_detailsrc*g|]}|ddk|S)rtestrdrs rfrz.(3f3f3f!!NJ[_eJeJeAJeJeJereproxy_pass_due_testc*g|]}|ddk|S)rforcedrdrs rfrz.s(5j5j5jAAnL]aiLiLiaLiLiLireproxy_pass_due_forcedc*g|]}|ddk|S)rrrdrs rfrz.s(6l6l6lQQ~M^bkMkMkqMkMkMkreproxy_pass_due_handlerc*g|]}|ddk|S)rincludesrdrs rfrz.s)7n7n7naaP^N_cmNmNmNmNmNmreproxy_pass_due_includesc*g|]}|ddk|S)rhttprdrs rfrz.r%reproxy_pass_due_httpNz/var/lib/apache2nginx/staterz"Can't get Max Webserver statistics)rrrrrloadr#rrrrcrpr r rrget_max_webserver_statsr) rrr riwebsitesproxiedrfailing_directivefailing_handlerr_max_webserver_stat metric_name metric_values rfr]z(CloudlinuxSummary.get_apache2nginx_statss 7>>= > >' h93QQQ& hUVy||+.d))&' ..IHhHHH,/LL()588p8pG8p8p8p4q4q01.0*+,.() QQA(K77,-EE/,B,B),S!"67>>q?QRRR>*i77*+%%*@*@*Q!"45<>7 8 8 23S7KKK 2q!"!1!1g 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2'+o&C&C  ( 0' ' ## L);)A)A)C)C . . %K!-E+   s$G0H11H58H5-*J##J'*J'cd}tj|siStj|gddd}t j|jS)zE Return statistics from cmax-webserver-stats utility z,/usr/share/max_webserver/max-webserver-statsTFr)rrrrrrrr5rs rfr3z)CloudlinuxSummary.get_max_webserver_statss\ >w~~d## I N F     z!(###recd}tj|r3tj|dgddd}t j|jSdS)r z/usr/bin/clwpos-adminrTFrNrrs rfrz CloudlinuxSummary.get_wpos_stats+sd ' 7>>$   (z"# A :ah'' ' ( (recd}d}d}t|d5}|D]C}|}t|dkr*|d}|dkrd};|d krd}D d d d n #1swxYwY|r|rd S|rd S|rd SdS)z9Detect cgroup version from /proc/mounts filesystem types.z /proc/mountsFrrrNcgroup2TrmNhybridv2v1no_mount)rrKr#) _PROC_MOUNTShas_v1has_v2fhrfieldsfstypes rfrz$CloudlinuxSummary.get_cgroup_version:s &  , 1 1 1 "R " "v;;??Y&&!FFx''!F " " " " " " " " " " " " " " " "  f 8  4  4zsAA,,A03A0rc)rN)r_NrN)rT)rr r rr itertoolscompressrrrrTrSrUrrrr|r.r staticmethodrpropertyrrrrrrrrrrrrrrr&r*r3rDrJr/r[rrrrr rrrrHr rr{rrrrrzrrr+r*r)rrOr^rerrurxr{rr4rrrrrr r/r(rr r$rTr'rXrr&rprSrrdrvrrrrrrrrrrrrrrrrrrrrrr$r(r-r1r<rBrDrGrMr;rXr]rrrrrrrrrrrrrrr)r3r<rIrMrrZrXrYrrrr classmethodrrrtuplerrrobjecttypingNoReturnryrrr rrrrr/rrrr]r3rrrdrerfrrs<7" "$$$ ,E ,W-D E E ,E ,W-B C C ,E ,W-D E E IBKMFKL $ $ $@@\@X3X 88\8@@\@\ -$----^ $ $X $         \  ;;\;@S@S@@@\@:   555*###:$$\$ B B B B\LLL`\6   \  tCH~$\:+#+#+#Z444@ : :V : : : :\ : VS[8I PV ei nr    :  \ D---^  !!!!\!EEEE81 1 1 1 f\<\*(??\?"    6    B P# P P P P'x}''''hsm\;<;<;<; @Q> VZ> > > > @ >O TX    >X>OXTXXXXXv====K@K@K@K@Z   IhIhIhV 3   \ <?$t*?cSVh???\?B   *<<<+c+T+++\+Pd4j$t*d3PS8n.T(UPPPPB:s3xS7I1J:::::=="%=<@cN= c5s## $====~$!#$!#$!$!$!$!LYtGG\G,<:<:<:<:|KCKCKCKCZ      DcN   \  7 7QT 7YabeYf 7 7 7\ 7 5s 5S 5U]^aUb 5 5 5\ 5\\#\\\\\ "t " " " "\ " "T "c " " "\ "  D  W    \   "d "s " " " " t    \  T c   \ &&RV&&&&ltlClTXY\T]lll\lst\ttttl!D!!!\!&2\   ##\# / /\ /77\7 $   \  "D " " "\ "s\3\ \b b b H    AVA AAAA+ + + Z   2( ( ( T   *$4$$$\$L   @lll 0!E#sC-!$/4>\>??\?;;\;(8D>(((\(<T<<<\<|oSoSooo\o&4HTN444\4d4=====~ $Xd^ $ $ $\ $ (HTN ( ( (\ (\rercTt}|j|Src)r8rq link_xml_node)rs rfrrRs$ XXF O!!### Mre)rrOrJrrrrrrr rrrwrXrQcopyr collectionsrr functoolsrrmultiprocessingrpathlibr socketr r r r rrrrr cldetectlibrrr3rcl_proc_hidepidrclcommonrclcommon.clwpos_librrrclcommon.constrclcommon.cpapirr clcommon.librclcommon.lib.cleditionrrrclcommon.lib.cmt_utilsrclcommon.lib.constsr clcommon.sysctlr!clcommon.utilsr"r#r$r%r&r'r(r)r*r+r,clconfigr-r.r/ cldiaglibr0 cli_utilsr1r2cllimitslib_v2r3r4 clveconfigr5clwizard.modulesr6 lve_utilsr7rlveapir8vendors_api.configr9r:&cl_website_collector.website_collectorr;$cl_website_collector.feature_managerr<clsummary.net_acctr=rr>clsummary.utilsr?r@rArBrCrDrErFrGrHrIrJrKrLrMrNrOclsummary.hardware_statisticsrPrQrR!clsummary.rpm_packages_statisticsrS arg_parserUstoragerVclselect.clselectctlrWclselect.clselectstatisticsrXrYrZr[r\r]clselector.selectorlibr^ lvemanagerr_rr ImportErrorclflagsraclcagefslib.domainrhrirrrrrr"rLrrrrr)rrOrrrrrrrdrerfrs    ,,,,,,,,((((((((%%%%%%LLLLLLLLLLLLLLLLLLLL :::::: #"""""IIIIIIII&&&&&& :99999??????&&&&&&                          ONNNNNNNNN3333336666666666666666######((((((::::::========CCCCCC??????( DCCCCC444444######"888888=<<<<<@@@@@@@@@@@@@ " " "221-110 !! "'''''''   - W 3 4 4    #   $ $I#I%S/IIII.UUUUUUt9t9t9t9t9t9t9t9lss6(F))GG GGGG(( G65G6