§ ½@¾jÙã ó —dZddlZddlmZmZmZdZeddh¦«ZdZ de dee d e fd „Z dd e d ee e ffd „Z dd e deee d ee e ffd„Zedfde deee d ee e ffd„ZdS)uS Telemetry collector for LVE Traffic Accounting (CLOS-4341). Parses /proc/lve/list and produces a small set of metrics that let us answer: - does this kernel expose net accounting at all (NETO/NETI columns present)? - how many user LVEs exist and how many actually accumulated traffic? - what's the cumulative NETO/NETI volume across user LVEs on this host? /proc/lve/list contains two non-user LVE rows we exclude from all aggregates: - *default* (user_id = UINT_MAX) — kernel catch-all for processes not attached to any specific LVE (sshd, systemd, dnf, ...). Has non-zero traffic on essentially every running CL host. - *root* (user_id = 0) — LVE container for root (uid 0). Not a hosting user. After exclusion the metrics describe user hosting activity, and lves_total matches the count seen by `lvectl list` and the panel's user list. éN)ÚDictÚIterableÚOptionalz/proc/lve/listlÿÿ©Únet_acct_kernel_supportedÚnet_acct_lves_totalÚnet_acct_lves_with_trafficÚnet_acct_total_neto_bytesÚnet_acct_total_neti_bytesÚ lve_id_fieldÚexcludedÚreturncó€—| dd¦«d} t|¦«|vS#t$rYdSwxYw)zÒTrue if the LVE row's user_id is in the excluded set. LVE ids in /proc/lve/list use the form "," (e.g. "0,1002") or just "" on older kernels. Malformed rows are excluded. ú,ééÿÿÿÿT)ÚrsplitÚintÚ ValueError)r r Úuser_ids úpy/clsummary/net_acct.pyÚ_user_id_excludedr+sV€ð ×!Ò! # qÑ)Ô)¨"Ô-€GðÝ�7‰|Œ|˜xÐ'Ð'øÝ ððð؈tˆtðøøøs ž/¯ =¼=Ú supportedcó—|dddddœS)Nrr©)rs rÚ _empty_resultr8s €à%.Ø Ø&'Ø%&Ø%&ð  ð ðóÚcontentÚ skip_user_idscó†—|st¦«S| ¦«}|st¦«S|d}d|vr| dd¦«d}| d¦«} | d¦«}| d¦«}n#t$rt¦«cYSwxYwt t ¦«}|r| |¦«d}d} d} d} |dd…D]Á} |  ¦«sŒ|  d¦«} t| ¦«t||¦«krŒNt| d|¦«rŒe t| |¦«}t| |¦«}n#t$rYŒ�wxYw|dz }|dks|dkr| dz } | |z } | |z } ŒÂd|| | | dœS) uŠParse /proc/lve/list text and return the 5 net_acct metrics. Format of /proc/lve/list: :LVE...NETONETI # header ... # one row per LVE The leading ":" prefix is optional/version-dependent; we tolerate its presence and absence. NETO/NETI are cumulative byte counters; their lowercase counterparts lNETO/lNETI are limit columns and ignored here. skip_user_ids — additional user-id slots to exclude beyond the standard root/default. Used by cloudlinux-summary to skip its own transient self-LVE (created via _run_self_in_lve) which would otherwise inflate counts by 1 on every collection run. On any structural problem (no header, missing NETO/NETI columns, malformed rows) we treat the kernel as not supporting net accounting and return a zeroed result. rú:rú ÚNETOÚNETINr) rÚ splitlinesÚsplitÚindexrÚsetÚNON_USER_LVE_IDSÚupdateÚstripÚlenÚmaxrr)rrÚlinesÚheaderÚcolumnsÚneto_idxÚneti_idxÚ excluded_idsÚtotalÚ with_trafficÚsum_netoÚsum_netiÚrawÚfieldsÚnetoÚnetis rÚparse_proc_lve_listr<Bs€ð. ð݉ŒÐà × Ò Ñ Ô €EØ ð݉ŒÐà �1ŒX€Fà ˆf€}€}Ø—’˜c 1Ñ%Ô% aÔ(ˆà�lŠl˜4Ñ Ô €GðØ—=’= Ñ(Ô(ˆØ—=’= Ñ(Ô(ˆˆøÝ ððð݉ŒÐÐÐðøøøõÕ'Ñ(Ô(€LØð+Ø×Ò˜MÑ*Ô*Ð*à €EØ€LØ€HØ€Hà�Q�R�RŒyððˆØ�yŠy‰{Œ{ð Ø Ø—’˜4‘”ˆÝ ˆv‰;Œ;�#˜h¨Ñ1Ô1Ò 1Ð 1Ø Ý ˜V AœY¨ Ñ 5Ô 5ð Ø ð Ý�v˜hÔ'Ñ(Ô(ˆDÝ�v˜hÔ'Ñ(Ô(ˆDˆDøÝð ð ð Ø ˆHð øøøð �‰ ˆØ �!Š8ˆ8�t˜a’x�xØ ˜AÑ ˆLØ�DшØ�Dшˆð&'Ø$Ø&2Ø%-Ø%-ð  ð ðs$Á3*BÂB9Â8B9Å*F Æ FÆFÚpathcó<—tj |¦«st¦«S t |ddd¬¦«5}| ¦«}ddd¦«n #1swxYwYn#t $rt¦«cYSwxYwt||¬¦«S)z¯Read /proc/lve/list and return parsed metrics. Missing file (older kernels, non-CL kernels, Ubuntu without lve) yields kernel_supported=0 and zeros for the rest. Úrzutf-8Úreplace)ÚencodingÚerrorsN)r)Úosr=ÚexistsrÚopenÚreadÚOSErrorr<)r=rÚfhrs rÚcollect_net_acct_metricsrI’sÞ€õ Œ7�>Š>˜$Ñ Ô ð݉ŒÐðÝ �$˜ g°iÐ @Ñ @Ô @ð ÀBØ—g’g‘i”iˆGð ð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð øøå ððð݉ŒÐÐÐðøøøå ˜w°mÐ DÑ DÔ DÐDs5¯A/ÁA#Á A/Á#A'Á'A/Á*A'Á+A/Á/B  B )r)N)Ú__doc__rCÚtypingrrrÚ PROC_LVE_LISTÚ frozensetr)Ú METRIC_NAMESÚstrrÚboolrrr<rIrrrúrQshðððð$ € € € Ø+Ð+Ð+Ð+Ð+Ð+Ð+Ð+Ð+Ð+à € ð�9˜a ˜_Ñ-Ô-Ðð€ ð  Cð °8¸C´=ð ÀTð ð ð ð ðð˜Sð¨¨c°3¨h¬ððððð.2ðMðMØ ðMà˜H SœMÔ*ðMð ˆ#ˆsˆ(„^ðMðMðMðMðbØ-1ðEðEØ ðEà˜H SœMÔ*ðEð ˆ#ˆsˆ(„^ðEðEðEðEðEðEr