4/BݣjddlZddlZddlZddlmZmZmZmZmZm Z ddl m Z dZ Gdde ZdS)N)DbRecoveredExceptionDbRecoverFailedExceptionPluginExecutionExceptionPluginTimeoutExceptionSameProcessPluginExecutorSeparateProcessPluginExecutor) ConfigErroriseletskcPeZdZ d dZdZedZdZd dZd Z dS) MainLoopNTc<||_||_||_d|_|g|_n||_|dd|_||_tj d|_ |rt|||_ nt||_ ||_dS)a :param config: :param lve_data: data being collected, used and modified by plugins during main loop execution. :param interval: update interval in seconds :param plugins: list of plugins :param plugin_timeout: time in seconds to let plugin be executed :param str profiling_log: if not None -- file to write profiling info :return: FNaggregation_period<z main.loop)configintervaldefault_intervaldo_exitpluginsgetrdefault_user_plugin_timeoutlogging getLoggerlogrexecutorr profiling_log)selfrrrplugin_timeout multiprocrs /builddir/build/BUILDROOT/lve-stats-4.3.2-1.el9.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/eventloop/main_loop.py__init__zMainLoop.__init__s    ( ?DLL"DL"(**-A2"F"F+9($[11  >9&-PPDMM5f==DM*cH|jdd|_dS)Nz Want to exitT)rdebugr)rs r exitz MainLoop.exit?s! ~&&& r"cvddl}||}|dd}|j}||fS)a >>> from lvestats.plugins.generic.aggregators import LveUsageAggregator >>> plugin_class = LveUsageAggregator >>> MainLoop._plugin_path_name(plugin_class) :param plugin_class: :return: Filesystem path to plugin and it's name rNz.pycz.py)inspectgetfilereplace__name__) plugin_classr'pathnames r _plugin_path_namezMainLoop._plugin_path_nameCsC |,,||FE**$Tzr"c |}t|S#t$r3}|jdt|Yd}~dSd}~wwxYw)NzError while getting info: %s)str Exceptionrr$)r stat_getter stat_valuees r get_debug_infozMainLoop.get_debug_infoRsg $Jz?? "    HNN93q66 B B B22222 s A(AAc d}|r|}d}|jrKddl}|}|sd}|jd|| t j}|jD]G}|jr6|j d|j dSt|ddrt|d|j }nt|dd} |r#||j j|||n|j |||#t $r|jd Yt$$r|jd YdSt($r|d |t,j|d |t,jd }t2|\} } |jd| | d|iYt8$r=t2|\} } |jd| | Yt:$r=t2|\} } |jd| | YEwxYw|r |dz}|dkrn|||r|jdddl} tA|jdd5} | !d| "|| } | #d$d| !d| #d$ddddn #1swxYwY|j dS)Nr z%Profiling server for %s plugin cyclesTExiting__is_user_plugin__FtimeoutzDb was corrupt, recoveredzUnable to recover databasecBttjSN)lenpsutilpidsr"r zMainLoop.run..sSEWEWr"c2tjjSr=)r?virtual_memorypercentrAr"r rBzMainLoop.run..s6;P;R;R;Zr") process_countcpumemiozPlugin %s:%s timed outdata)extrazError during execution of %s:%szUnable to init plugin %s:%szProfiling finishedza+zutf-8)encodingz"Main loop profile, internal time: )streamtimez$Main loop profile, cumulative time: cumulative)%rcProfileProfilerinfoenablerOrrr$r terminategetattrrruncallexecuterwarningr exceptionrr6r?cpu_times_percentdisk_io_countersr r.errorrr _sleeppstatsopenwriteStats sort_stats print_stats)rtimescntprofilerrRnowpluginr;loadr,r-r`fstatss r runz MainLoop.runZsm  C    OOO''))H  HMMA3 G G G OO   . )++C,& R& R<HNN9---M++---FF6#7???%fi9YZZGG%fi>>GRD (()>WUUUU --fc7CCC+H$$%@AAAH/H&&'CDDDFFF-   )-)<)<=W=W)X)X#2263KLL#223Z3Z[["11&2IJJ D "*!;!;F!C!CJD$HNN#;T4PVX\~N^^^H/!)!;!;F!C!CJD$H&&'H$PTUUUH"RRR!)!;!;F!C!CJD$H&&'DdDQQQQQR q!88 KK   ]. `  ? HMM. / / / MMMd($AAA ?Q=>>> Xa 88  ((44R888?@@@  ..::2>>>  ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? !!!!!sA0AD22$J<#J<?B/J<1AJ<6AJ<;J<BN99N=N=ctj|z }|j|z }|dkr6|j|jkr|xjdzc_tj|dS|j|jkr|xjdz c_dSdS)Nrg?)rOrrsleepr)rri time_passedpauses r r_zMainLoop._sleepsikkC'  + 199}t444 $ Ju     }t666 $ 76r")r Nr TNr=) r* __module__ __qualname__r!r% staticmethodr.r6rnr_rAr"r r r s !# "+"+"+"+H  \ I"I"I"I"V % % % % %r"r )rrOr?#lvestats.eventloop.plugin_executorsrrrrrrlvestats.lib.configr __author__objectr rAr"r rzs ,+++++  T%T%T%T%T%vT%T%T%T%T%r"