H:jrddlZddlZddlZddlZddlmZmZmZmZm Z m Z ddl m Z dZ GddeZdS)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-5.0.4-1.el8.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_nameDsC |,,||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_infoSsg $Jz?? "    HNN93q66 B B B22222 s A(AAc Xd}|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} tAj!|jt@j"t@j#zt@j$zt@j%zd} tAj&| dd5} | '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 finishediazutf-8)encodingz"Main loop profile, internal time: )streamtimez$Main loop profile, cumulative time: cumulative)+rcProfileProfilerinfoenablerPrrr$r terminategetattrrruncallexecuterwarningr exceptionrr6r?cpu_times_percentdisk_io_countersr r.errorrr _sleeppstatsosopenO_WRONLYO_APPENDO_CREAT O_NOFOLLOWfdopenwriteStats sort_stats print_stats)rtimescntprofilerrSnowpluginr;loadr,r-rafdfstatss r runz MainLoop.run[s  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. / / / MMM+r{2RZ?"-O  B2sW555 ?=>>> Xa 88  ((44R888?@@@  ..::2>>>  ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? !!!!!sA0AD22$J<#J<?B/J<1AJ<6AJ<;J<(BPP  P ctj|z }|j|z }|dkr6|j|jkr|xjdzc_tj|dS|j|jkr|xjdz c_dSdS)Nrg?)rPrrsleepr)rrp time_passedpauses r r`zMainLoop._sleepsikkC'  + 199}t444 $ Ju     }t666 $ 76r")r Nr TNr=) r* __module__ __qualname__r!r% staticmethodr.r6rvr`rAr"r r r s !# "+"+"+"+H  \ L"L"L"L"\ % % % % %r"r )rrbrPr?#lvestats.eventloop.plugin_executorsrrrrrrlvestats.lib.configr __author__objectr rAr"r rs ,+++++  W%W%W%W%W%vW%W%W%W%W%r"