🔐 Sid Gifari File Manager Pro
v8.0.5 | 2026-06-15 03:36:49 | PHP 8.1.34
📂
/ (Root)
/
opt
/
cloudlinux
/
venv
/
lib
/
python3.11
/
site-packages
/
clsummary
/
__pycache__
📍 /opt/cloudlinux/venv/lib/python3.11/site-packages/clsummary/__pycache__
🔄 Refresh
✏️
Editing: net_acct.cpython-311.pyc
Read Only
� �Ov��� � � d Z ddlZddlmZmZmZ dZ eddh� � ZdZ de dee d efd �Z dded ee ef fd�Z dd e deee d ee ef fd�Zedfde deee d ee ef fd�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 |� � |v S # t $ r Y dS w xY w)z�True if the LVE row's user_id is in the excluded set. LVE ids in /proc/lve/list use the form "<lvp_id>,<user_id>" (e.g. "0,1002") or just "<user_id>" 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 )Nr r � )r s r � _empty_resultr 8 s � �%.� �&'�%&�%&�� � � �content� skip_user_idsc � � | st � � S | � � � }|st � � S |d }d|v r|� dd� � d }|� d� � } |� d� � }|� d� � }n# t $ r t � � cY S w xY wt t � � }|r|� |� � d}d} d} d}|dd� D ]�}|� � � s�|� d� � } t | � � t ||� � k r�Nt | d |� � r�e t | | � � }t | | � � }n# t $ r Y ��w xY w|dz }|dk s|dk r| dz } | |z } ||z }��d|| | |d�S ) u� Parse /proc/lve/list text and return the 5 net_acct metrics. Format of /proc/lve/list: <version>:<TAB>LVE<TAB>...<TAB>NETO<TAB>NETI # header <lve_id><TAB>...<TAB><neto><TAB><neti> # one row per LVE The leading "<version>:" 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�maxr r )r r �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<