Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
ó �àfc@s^ddlZddlZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ddl m Z mZmZmZmZmZddl mZmZmZmZmZmZddlZdefd „ƒYZed „Zeed „Zeed „Z eed „Z!d„Z"d„Z#d„Z$dS(iÿÿÿÿN(tget_cp(tcriu_settings_malfunctions(tlsapi_settings_malfunctions(tliblsapi_malfunctions(t cpanel_whmapitplesk_bin_php_handlertdump_loaded_modulest dump_lsapit query_stringst rpm_query(tget_da_domainstget_da_php_optionstread_da_configt liblsapi_pathtpretty_version_keyst count_domainstModLsapiStatExceptioncBseZRS((t__name__t __module__(((s//usr/share/lve/modlscapi/user/mod_lsapi_stat.pyRscCsmd }i}tƒ}yŽ|jdkrRtjjdƒrItƒ|d\} } |j| tƒƒji|j| tƒƒ| 6ƒqóW|rYt j |||ƒ} | }nxK|jƒD]=\}}|jtj t| ƒj |jƒƒtƒƒƒqfWWn;t tfk råtd jtjƒjd ƒƒƒ‚nXt|| |ƒS( sY Collect mod_lsapi statistics for cPanel EA4 through WHM API :param lsapi_only: return only lsapi domains statistics if True, or full statistics if False :param with_selector: take into account the statistics of php selector :return: if lsapi_only return lsapi domains per version stat dict( `version`: `domains_num`, ... ) else return full statistics per handler stat dict( `handler`: {`version`: `domains_num`, ... } ... ) tphp_get_vhost_versionstversionstversiontvhosttaccounttphp_get_handlerstversion_handlerstcurrent_handlerts (R&RR5t setdefaulttsettaddtkeyst iteritemsR'tselector_usage_libtea4_selector_checktfromkeyst differencetKeyErrort TypeErrorRtjoint tracebackt format_exctsplitR(t lsapi_onlyt with_selectortdomains_per_versiont handlers_statt domain_userst vhosts_dataR9t handlers_datathR<t all_versionstverthandlerts_checked_version_handlerstv((s//usr/share/lve/modlscapi/user/mod_lsapi_stat.pyR Ys*    . 7 6 9(cCs¬d}d}tƒ}ytdƒ}tg|D]!}d|jdƒkr.|^q.ƒ}x¹|D]±}|jdƒ} dj|jdƒjdƒd ƒ} tgtd d| ƒD]} | jd ƒ^q¯ƒ} d | krôd } |jd | ƒ}n|jd | ƒ} | || t fullVersiont.iÿÿÿÿs get-usagetdomaintcustomRZs css'|]\}}|t|ƒfVqdS(N(tlen(t.0tkRZ((s//usr/share/lve/modlscapi/user/mod_lsapi_stat.pys ±stlsapi(R&RtsortedR5RJRMR@R#RDtplesk_selector_checkRHRItAttributeErrortSelectorStatExceptionRRKRLRC(RNROt handler_tmpltcustom_versiontdomain_version_statt all_handlersRUtlsphp_handlersRXt handler_idt php_versiontdtdomainst version_idt result_stat((s//usr/share/lve/modlscapi/user/mod_lsapi_stat.pyR!Šs,  4 %4 ( cCsÞd}tƒ}yxtƒ}|dd}|dd}|dd}|dd}t|ƒ} t|ƒ} tƒ} tƒ} g| jƒD]} | j| ƒ^qŠ|dkrÐi| | 6}i| | 6||i|| | 6tƒ| 6||tttfk rÇtd jtjƒjd ƒƒƒ‚nXt|| | g|ƒS( sN Collect lsapi domains statistics fro DirectAdmin :param lsapi_only: return only lsapi domains statistics if True, or full statistics if False :param with_selector: take into account the statistics of php selector :return: if lsapi_only return lsapi domains per version stat dict( `version`: `domains_num`, ... ) else return full statistics per handler stat dict( `handler`: {`version`: `domains_num`, ... } ... ) s>/usr/local/directadmin/data/users/{user}/domains/{domain}.confiR8iRXtnotuserR`t php1_selectR>s (R&R RR R@R+R'RCR#R tgetintR5RAt ConfigParsert NoOptionErrorRDtda_selector_checkRHRIRhRRJRKRLRMR(RNROtdomain_conf_patht handler_statt php_optionstphp1_vertphp2_vert php1_handlert php2_handlert php1_labelt php2_labelt user_domainstjoinedRZt version_statRvRrR`t config_patht conf_parsertglobal_sectiont php_settingR8tselector_updated((s//usr/share/lve/modlscapi/user/mod_lsapi_stat.pyR"¶sV      &     " (cCs™djtjdƒƒ}y2tjdddgdtjdtjƒd}Wntjk rfd }nXii|d6|r�|jd ƒd nd d 6d6S(sÆ Get criu service info :return: dict( `criu`: dict( `status`: running/stopped, `version`: version ) ) R>s/usr/sbin/criu -Vs /sbin/servicetcriutstatuststdouttstderrtrunningtstoppedt is not installedR8(RJt exec_commandt subprocesst check_calltPIPEtSTDOUTtCalledProcessErrorRM(t criu_versiontcriu_service_status((s//usr/share/lve/modlscapi/user/mod_lsapi_stat.pyR)s (  cCs¦tƒ}tƒ}|jddƒ}ttƒdƒ}ii|jddƒd6|jddƒd6d6|jddƒd6|r…|n td ƒd 6|sžd nd d 6S(sl Retrieve lsapi configuration: - crui - connection pool and versions of module and library :return: dict( lsapiConf: dict( lsapi_with_connection_pool: on/off, lsapi_criu: on/off ), modVersion: version, libVersion: version ) t lsapi_moduletliblsapi_versiont lsapi_criutofftlsapi_with_connection_poolt lsapiConfR8t modVersiontliblsapit libVersiontdisabledtenabledt modStatusN(RRR5RRR R (t apache_conftapache_modulest mod_statusR�((s//usr/share/lve/modlscapi/user/mod_lsapi_stat.pyR(s  cs—tƒ‰‡fd†}djd|ddd|ddƒ}|d }|t|d ƒ|t|ƒ|t|ƒˆsd S|jiˆd 6ƒd S( s÷ Detect configuration malfunctions and update resulting statistics dict accordingly For now only criu malfunctions are presented See malfunctions in dashboard_malfunctions.py module :param stats_dict: resulting statistics dict cs-yˆj||ƒWntk r(nXdS(N(tappendRH(t malfunc_dicttkey(t malfunctions(s//usr/share/lve/modlscapi/user/mod_lsapi_stat.pytadd_malfunctionIs s {opt}_{serv}toptR¡RžtservR�RŽR§R¤NR®(R[R#RRRR'(t stats_dictR¯t criu_settingstlsapi_settings((R®s//usr/share/lve/modlscapi/user/mod_lsapi_stat.pyR,@s    (%RR-RKR•RyR”tlve_diagnosticRtdashboard_malfunctionsRRRt stat_utilsRRRRRR R R R R RRRDt ExceptionRtFalseR5R/R R!R"R)R(R,(((s//usr/share/lve/modlscapi/user/mod_lsapi_stat.pyts(      ..  71,O  !