B
�=�_]y � @ s� d Z ddlZddlZddlZddlZddlm mZ ddl m
Z
ddl mZ ddlm
Z
ddlmZ ddlmZ dd lmZ dd
l
mZ ddl
mZ ddl
mZ dd
l
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddlmZ ddlm Z ddlm!Z! ddlm"Z" g Z#e�rzej$e
j%ej&e
j'ej(e
j)ej*e
j+ej,e
j-ej.e
j/ej0e
j1iZ2n~e�r�ej$e
j%ej(e
j)ej*e
j+ej3e
j-ej,e
j-ej&e
j4ej5e
j'iZ2n:e�r�ej$e
j%ej(e
j)ej*e
j+ej,e
j-ej&e
j4ej5e
j'iZ2ej6e
j7ej8e
j9ej:e
j;eje
j?ej@e
jAejBe
jCejDe
jEejFe
jGejHe
jIejJe
jKejLe
jMiZNe�O� ZPejQZQeRed�ZSeRed�ZTeRed�ZUeRed�ZVeWdddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4�ZXe
d5d6d7d8d9d:d;dd?d@g�ZYe
dAdBdCdDdEdFg�ZZe
dGdHdIdJdKdLg�Z[e[Z\e
dMdBdDdNdOg�Z]e
dPdQ�Z^e
dRdS�Z_e�r^e
dTdUdVdWdXdYdZd[g�Z`ne
dTdUdVdWdXg�Z`d\d]� Zad^d_� Zbd`da� ZceS�r�dbd� Zdndcd� Zddded_ededf� Zfe�s�e�r�dgdh� Zgndidh� Zgdjdk� Zhd�dldm�ZiejjZjejkZkejlZlejmZmdndo� Zndpdq� Zoe�r$drds� Zpdtdu� Zqdvdw� Zrdxdy� Zsdzd{� Zted|d}� �Zud~d� Zve�sTe�r^d�d�� ZwnejwZwd�d�� Zxd�d�� Zyejzd�d�� �Z{G d�d�� d�e|�Z}dS )�z5FreeBSD, OpenBSD and NetBSD platforms implementation.� N)�
namedtuple)�defaultdict� )�_common)�_psposix)�_psutil_bsd)�
_psutil_posix)�AccessDenied)� conn_tmap)�conn_to_ntuple)�FREEBSD)�memoize)�memoize_when_activated)�NETBSD)�
NoSuchProcess)�OPENBSD)�
usage_percent)�
ZombieProcess)�FileNotFoundError)�PermissionError)�ProcessLookupError)�which�
per_cpu_times�proc_num_threads�proc_open_files�proc_num_fds� � � � � � � � �
� � �
� � � � � � � � � � � )�ppid�status�real_uid�
effective_uid� saved_uid�real_gid�
effective_gid� saved_gid�ttynr�create_time�ctx_switches_vol�ctx_switches_unvol�
read_io_count�write_io_count� user_time�sys_time�ch_user_time�ch_sys_time�rss�vms�memtext�memdata�memstack�cpunum�name�svmem�totalZ available�percent�used�free�active�inactive�buffers�cached�shared�wired� scputimes�user�nice�system�idle�irq�pmemrE rF �text�data�stack� pcputimes�
children_user�children_system�
pmmap_groupedz*path rss, private, ref_count, shadow_count� pmmap_extz6addr, perms path rss, private, ref_count, shadow_count�sdiskio�
read_count�write_count�
read_bytes�write_bytes� read_time�
write_timeZ busy_timec C s� t �� } | \}}}}}}}}tr�tdd��R} xJ| D ]B}
|
�d�rVt|
�� d �d }q2|
�d�r2t|
�� d �d }q2W W dQ R X || | }|| | }t|| |dd�}
t|||
||||||||�S ) z&System virtual memory as a namedtuple.z
/proc/meminfo�rbs Buffers:r i s
MemShared:N)�round_) �cextZvirtual_memr �open�
startswith�int�splitr rL )ZmemrM rP rQ rR rV rT rS rU �f�lineZavailrO rN � rv �@/opt/alt/python37/lib64/python3.7/site-packages/psutil/_psbsd.py�virtual_memory� s
"rx c C s4 t �� \} }}}}t|| dd�}t�| |||||�S )z@System swap memory as (total, used, free, sin, sout) namedtuple.r )rn )ro Zswap_memr r �sswap)rM rO rP �sin�soutrN rv rv rw �swap_memory� s r| c C s" t �� \} }}}}t| ||||�S )z+Return system per-CPU times as a namedtuple)ro � cpu_timesrW )rX rY rZ r[ r\ rv rv rw r} � s r} c C sB g } x8t �� D ],}|\}}}}}t|||||�}| �|� qW | S )z'Return system CPU times as a namedtuple)ro r rW �append)�retZcpu_trX rY rZ r[ r\ �itemrv rv rw r � s c C s. t � dkrt� gS tjr td��dt_t� gS )z'Return system CPU times as a namedtupler z&supported only starting from FreeBSD 8T)�cpu_count_logicalr} r �
__called__�NotImplementedErrorrv rv rv rw r � s
Fc C s t �� S )z0Return the number of logical CPUs in the system.)ro r� rv rv rv rw r� � s r� c C s t � dkrdS d S )Nr )r� rv rv rv rw �cpu_count_physical� s r� c C sx d} t �� }|dk rb|�d�}|dkrb|d|d � }t�|�}zt|�d��pRd} W d|�� X | stt� dkrtdS | S )z1Return the number of physical CPUs in the system.Nz �����r# zgroup/children/group/cpur ) ro Zcpu_count_phys�rfind�ETZ
fromstring�len�findall�clearr� )r �s�index�rootrv rv rw r� s
c C s� t rt�� \} }}}}nttrrt�� \} }}}}}}tdd��.}x&|D ]}|�d�rDt|�� d �}qDW W dQ R X ntr�t�� \} }}}}}}t �
| |||�S )z*Return various CPU stats as a named tuple.z
/proc/statrm s intrr N)r ro � cpu_statsr rp rq rr rs r r � scpustats) ZctxswZintrsZ
soft_intrs�syscallsZtrapsZfaultsZforksrt ru rv rv rw r� s
r� c C sP g }t �� }x>|D ]6}|\}}}}d }} t�|||||| �}
|�|
� qW |S )z�Return mounted disk partitions as a list of namedtuples.
'all' argument is ignored, see:
https://github.com/giampaolo/psutil/issues/906
N)ro �disk_partitionsr � sdiskpartr~ )�all�retlist�
partitions� partition�device�
mountpoint�fstype�opts�maxfile�maxpath�ntuplerv rv rw r� ? s
r� c C s� t � �� } i }x�| D ]�}y&t�|�}t�|�}t�|�\}}W n0 tk
rn } z|jtjkr^� W dd}~X Y qX t t
d�r�t
�|�}t
�||||�||<