'e~ddlmZddlZddlZddlZddlmZmZmZddlm Z m Z m Z ddl m Z dZGddeZdS) )absolute_importN)SeparateProcessPluginExecutorSameProcessPluginExecutorDbRecoverFailedException)DbRecoveredExceptionPluginExecutionExceptionPluginTimeoutException) 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.2.1-1.el7.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.exit7s! ~&&& 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_name;sC |,,||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_infoJsg $Jz?? "    HNN93q66 B B B22222 s A(AAc d}|r|}d}|jrMddl}|}|sd}|jd|z| t j}|jD]c}|jr6|j d|j dSt|ddrt|d|j }nt|dd} |r#||j j|||n|j |||#t $r|jd Yt$$r|jd YdSt($rd t*|z}|d |t0j|d |t0jd} |j|d| iYt8$r9|jdt*|zYt:$r_} t*|d\} } |jd| d| dt=| dYd} ~ ]d} ~ wwxYw|r |dz}|dkrn|||r|jdddl } tC|jd5}|"d| #||}|$d%d|"d|$d%ddddn #1swxYwY|j dS)Nr z%Profiling server for %d plugin cyclesTExiting__is_user_plugin__FtimeoutzDb was corrupt, recoveredzUnable to recover databasezPlugin %s:%s timed outcBttjSN)lenpsutilpidsr#r!zMainLoop.run..{sSEWEWr#c2tjjSr>)r@virtual_memorypercentrBr#r!rCzMainLoop.run..}s6;P;R;R;Zr#) process_countcpumemiodata)extrazError during execution of %s:%szUnable to init plugin z: z ()zProfiling finishedza+z"Main loop profile, internal time: )streamtimez$Main loop profile, cumulative time: cumulative)&rcProfileProfilerinfoenablerPrrr%r terminategetattrrruncallexecuterwarningr exceptionr r r/r7r@cpu_times_percentdisk_io_counterserrorrr r2_sleeppstatsopenwriteStats sort_stats print_stats)rtimescntprofilerrSnowpluginr<messageloadcer-r.rafstatss r!runz MainLoop.runRs  C    OOO''))H  HMMACG H H H OO   - )++C,% d% d<HNN9---M++---FF6#7???%fi9YZZGG%fi>>GdD (()>WUUUU --fc7CCC+H$$%@AAAH/H&&'CDDDFFF-   69S9STZ9[9[[G)-)<)<=W=W)X)X#2263KLL#223Z3Z[["11&2IJJ D HNN764.NAAAH/H&&'H8KeKeflKmKm'mnnnH"ddd!)!;!;F!C!CA!FJD$H&&&dddTXTXTXZ]^`ZaZaZaZa'bccccccccd q!88 KK   [- ^  ? HMM. / / / MMMd($// ?1=>>> Xa 88  ((44R888?@@@  ..::2>>>  ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? !!!!!sF2AD44$K#KB-K1>K2 K;AKK7BOOOctj|z }|j|z }|dkr6|j|jkr|xjdzc_tj|dS|j|jkr|xjdz c_dSdS)Nrg?)rPrrsleepr)rrj time_passedpauses r!r`zMainLoop._sleepsikkC'  + 199}t444 $ Ju     }t666 $ 76r#)rNrTNr>) r+ __module__ __qualname__r"r& staticmethodr/r7rqr`rBr#r!r r s !# "+"+"+"+H  \ H"H"H"H"T % % % % %r#r ) __future__rrPr@r#lvestats.eventloop.plugin_executorsrrrrrr lvestats.lib.configr __author__objectr rBr#r!r~s'&&&&& CCCCCCCCCCvvvvvvvvvv++++++  S%S%S%S%S%vS%S%S%S%S%r#