Uname:Linux server2.hostofiraq.site 5.15.0-186-generic #196-Ubuntu SMP Sat Jun 20 16:09:34 UTC 2026 x86_64

Base Dir : /home/iscmbt-kufa-atu/public_html

User : iscmbt-kufa-atu


403WebShell
403Webshell
Server IP : 89.117.53.150  /  Your IP : 216.73.216.11
Web Server : Apache
System : Linux server2.hostofiraq.site 5.15.0-186-generic #196-Ubuntu SMP Sat Jun 20 16:09:34 UTC 2026 x86_64
User : iscmbt-kufa-atu ( 1014)
PHP Version : 8.2.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/psutil/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/psutil/__pycache__/_pslinux.cpython-310.pyc
o

���a�M�
@s�dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%ddlm&Z&ddlm'Z'ddlm(Z(ddlm)Z)ddl*m+Z+ddl*m,Z,ddl*m-Z-dd l*m.Z.dd!l*m/Z/dd"l*m0Z0ej1d#kr�ddl2Z2ndZ2gd$�Z3d%Z4ej5�6d&e�7��Z8e9ed'�Z:e9ed(�Z;e<�Z=e�>d)�Z?e�@�ZAdaBe+�r%d*nd+ZCejDd,kZEd-ZFe2du�r7e
jGZHne2�Id.d/eJe
jG�i�ZKeKjHZHe2du�rSdZLdZMd0ZNd1ZOnGd2d3�d3e2jI�ZPeQ��RePjS�ejTejUejVejWejXejYejZejZej[ej\ej]ej^d4�Z_ej`ejaejbejcejdejeejfejgejhejiejjd5�Zked6gd7��Zled8gd9��Zmed:gd;��Zned<d=�Zoed>eojpd?�Zqed@gdA��ZredBdCdD�serjp��ZtedEgdF��ZuedGgdH��ZvdIdJ�ZwdKdL�ZxdMdN�Zye"dOdP��Zze=dQfdRdS�Z{zezdT�Wne|�ye
�}�edUdV�dWdWdW�a~YnwdZzddXl�mZWn e��y:ddl�Z�e�j�ddQdY�Z�e9e�dZ��r8d�d[dZ�ZYnwedu�rLe3��d\d]�e�e�D��d^d_�Z�d`da�Z�dbdc�Z�ddde�Z�dfdg�Z�dhdi�Z�djdk�Z�dldm�Z�dndo�Z�ej5�6dp��s~ej5�6dq��r�drds�Z�ndtds�Z�ej�Z�Gdudv�dve|�Z�Gdwdx�dx�Z�e��Z�d�dzd{�Z�d|d}�Z�d~d�Z�ej�Z�d�d�d��Z�Gd�d��d��Z�d�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�Gd�d��d�e<�Z�dS)�zLinux platform implementation.�)�divisionN)�defaultdict)�
namedtuple�)�_common)�_psposix)�
_psutil_linux)�
_psutil_posix)�NIC_DUPLEX_FULL)�NIC_DUPLEX_HALF)�NIC_DUPLEX_UNKNOWN)�AccessDenied)�
NoSuchProcess)�
ZombieProcess)�debug)�decode)�get_procfs_path)�
isfile_strict)�memoize)�memoize_when_activated)�open_binary)�	open_text)�parse_environ_block)�path_exists_strict)�
supports_ipv6)�
usage_percent)�PY3)�FileNotFoundError)�PermissionError)�ProcessLookupError)�b)�
basestring)��)�PROCFS_PATH�IOPRIO_CLASS_NONE�IOPRIO_CLASS_RT�IOPRIO_CLASS_BE�IOPRIO_CLASS_IDLE�CONN_ESTABLISHED�
CONN_SYN_SENT�
CONN_SYN_RECV�CONN_FIN_WAIT1�CONN_FIN_WAIT2�CONN_TIME_WAIT�
CONN_CLOSE�CONN_CLOSE_WAIT�
CONN_LAST_ACK�CONN_LISTEN�CONN_CLOSINGz/sys/class/power_supplyz/proc/%s/smaps�proc_ioprio_get�proc_cpu_affinity_get�
SC_CLK_TCK���i �littlei�
AddressFamily�AF_LINK�r"c@seZdZdZdZdZdZdS)�
IOPriorityrrr;r"N)�__name__�
__module__�__qualname__r%r&r'r(�r@r@�1/usr/lib/python3/dist-packages/psutil/_pslinux.pyr<xs
r<)�R�S�D�T�t�Z�X�x�K�W�I�P)�01�02�03�04�05�06�07�08�09�0A�0B�svmem)�total�	available�percent�used�free�active�inactive�buffers�cached�shared�slab�sdiskio)	�
read_count�write_count�
read_bytes�write_bytes�	read_time�
write_time�read_merged_count�write_merged_count�	busy_time�	popenfile)�path�fd�position�mode�flags�pmemz"rss vms shared text lib data dirty�pfullmem)�uss�pss�swap�
pmmap_grouped)rp�rss�sizerx�shared_clean�shared_dirty�
private_clean�
private_dirty�
referenced�	anonymousry�	pmmap_extzaddr perms � �pio)rfrgrhri�
read_chars�write_chars�	pcputimes)�user�system�
children_user�children_system�iowaitcCsLt|t�s	J|��t�|�}|�d�d}|�d�r$t|�s$|dd�}|S)zWrapper around os.readlink().�r�
 (deleted)N���)�
isinstancer!�os�readlink�split�endswithr)rpr@r@rAr��s
r�cCsXtjdtjdtjdi}||tjtjBtjB@}|tj@r$|�ddd�}|�dd�}|S)zZConvert file's open() flags into a readable string.
    Used by Process.open_files().
    �r�wzw+�arzr+)r��O_RDONLY�O_WRONLY�O_RDWR�O_APPEND�replace)rt�	modes_maprsr@r@rA�file_flags_to_mode�s
r�cCs4|�dd�}d}|rd|}nd|}t�|tj�S)z�Return True if the given name refers to a root device (e.g.
    "sda", "nvme0n1") as opposed to a logical partition (e.g.  "sda1",
    "nvme0n1p1"). If name is a virtual device (e.g. "loop1", "ram")
    return True.
    �/�!Tz
/sys/block/%sz/sys/block/%s/device)r�r��access�F_OK)�name�including_virtualrpr@r@rA�is_storage_device�s

r�cCs�td|��}|����dd�}Wd�n1swYgd�}t|�}|dkr1|�d�|dkr:|�d�|d	krC|�d
�td|�adS)z�Set a namedtuple of variable fields depending on the CPU times
    available on this Linux kernel version which may be:
    (user, nice, system, idle, iowait, irq, softirq, [steal, [guest,
     [guest_nice]]])
    Used by cpu_times() function.
    �%s/statrN)r��nicer��idler��irq�softirq��steal�	�guest�
�
guest_nice�	scputimes)r�readliner��len�appendrr�)�procfs_path�f�values�fields�vlenr@r@rA�set_scputimes_ntuples	�


r�Tc	Csnz$|rt|�nt|��}|����Wd�WS1swYWdSttfy6|tur5|YS�w)z�Return file content.
    fallback: the value returned in case the file does not exist or
              cannot be read
    binary: whether to open the file in binary or text mode.
    N)rr�read�strip�IOError�OSError�_DEFAULT)�fname�fallback�binaryr�r@r@rA�cats
(��r��/procr�zuser system idle�)�prlimit)�	use_errnor�cCs�Gdd�dtj�}|�}|durt�||dt�|��}n|�}|d|_|d|_t�||t�|�t�|��}|dkrGt��}t|t	�
|���|j|jfS)Nc@s eZdZdejfdejfgZdS)zprlimit.<locals>.StructRlimit�rlim_cur�rlim_maxN)r=r>r?�ctypes�
c_longlong�_fields_r@r@r@rA�StructRlimitKs�r�rr)r��	Structure�libcr��byrefr�r��	get_errnor�r��strerror)�pid�	resource_�limitsr��current�ret�new�errnor@r@rAr�Js

�cCs"g|]
}|�d�r|��r|�qS)�RLIM)�
startswith�isupper��.0rIr@r@rA�
<listcomp>cs"r�cCs|d}||�dd�}z|d}|d}|d}Wnty%|YSwz	tdt��}Wnty:|YSwd}|� |D]}|��}|�d�rW|t|��d	�7}qBWd
�n1sbwY|t	9}||}	||}
|
t
|
d|�8}
|	|
7}	|	|t
|d|�7}	t|	�S)
a�Fallback for kernels < 3.14 where /proc/meminfo does not provide
    "MemAvailable:" column, see:
    https://blog.famzah.net/2014/09/24/
    This code reimplements the algorithm outlined here:
    https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/
        commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773

    XXX: on recent kernels this calculation differs by ~1.5% than
    "MemAvailable:" as it's calculated slightly differently, see:
    https://gitlab.com/procps-ng/procps/issues/42
    https://github.com/famzah/linux-memavailable-procfs/issues/2
    It is still way more realistic than doing (free + cached) though.
    �MemFree:�Cached:rs
Active(file):sInactive(file):�
SReclaimable:z%s/zoneinfoslowrNr;g@)�get�KeyErrorrrr�r�r��intr��PAGESIZE�min)�memsr^r��lru_active_file�lru_inactive_file�slab_reclaimabler��
watermark_low�line�avail�	pagecacher@r@rA�calculate_avail_vmemks<��
���r�cCs�g}i}tdt���}|D]}|��}t|d�d||d<qWd�n1s+wY|d}|d}z|d}WntyNd}|�d	�Ynwz|d
}Wntyed}|�d�Yn	w||�dd�7}z|d
}	Wn ty�z|d}	Wnty�d}	|�d�YnwYnwz|d}
Wnty�d}
|�d�Ynwz|d}Wn(ty�z|d|d|d}Wnty�d}|�d�YnwYnwz|d}Wnty�d}Ynw||||}
|
dkr�||}
z|d}Wnt�yt|�}Ynw|dk�rd}|�d�||k�r%|}t|||dd�}|�rIdd�	|�t
|�dk�r?dndf}t�|t
�t||||
||
||||	|�S)a�Report virtual memory stats.
    This implementation matches "free" and "vmstat -s" cmdline
    utility values and procps-ng-3.3.12 source was used as a reference
    (2016-09-18):
    https://gitlab.com/procps-ng/procps/blob/
        24fd2605c51fccc375ab0287cec33aa767f06718/proc/sysinfo.c
    For reference, procps-ng-3.3.10 is the version available on Ubuntu
    16.04.

    Note about "available" memory: up until psutil 4.3 it was
    calculated as "avail = (free + buffers + cached)". Now
    "MemAvailable:" column (kernel 3.14) from /proc/meminfo is used as
    it's more accurate.
    That matches "available" column in newer versions of "free".
    �
%s/meminfor�rNs	MemTotal:r�sBuffers:rar�rbr�sShmem:s
MemShared:rcsActive:r_s	Inactive:sInact_dirty:sInact_clean:sInact_laundry:r`sSlab:s
MemAvailable:r[��round_z6%s memory stats couldn't be determined and %s set to 0�, �was�were)rrr�r�r�r�r�r�r�joinr��warnings�warn�RuntimeWarningrY)�missing_fieldsr�r�r�r�rZr^rarbrcr_r`rdr]r�r\�msgr@r@rA�virtual_memory�s�����	����������
�	�


��r�c
Cs�i}tdt���}|D]}|��}t|d�d||d<qWd�n1s)wYz
|d}|d}WntyTt��\}}}}}}}||9}||9}Ynw||}t||dd�}	z	td	t��}Wn"ty�}
zd
t	|
�}t
�|t�d}}
WYd}
~
n[d}
~
ww|�Ld}}
|D]1}|�
d�r�t|�d�d�d
d}n|�
d�r�t|�d�d�d
d}
|dur�|
dur�n
q�d}t
�|t�d}}
Wd�n1s�wYt�||||	||
�S)zReturn swap memory metrics.r�rr�rNs
SwapTotal:s	SwapFree:r�z	%s/vmstatzP'sin' and 'sout' swap memory stats couldn't be determined and were set to 0 (%s)spswpin� r#spswpoutzK'sin' and 'sout' swap memory stats couldn't be determined and were set to 0)rrr�r�r��cext�
linux_sysinforr��strr�r�r�r�r�sswap)r�r�r�r�rZr^�_�unit_multiplierr]r\�errr��sin�soutr@r@rA�swap_memorysV������

���r
cCsrt�}t|�td|��}|����}Wd�n1swY|dttj�d�}dd�|D�}t|�S)z�Return a named tuple representing the following system-wide
    CPU times:
    (user, nice, system, idle, iowait, irq, softirq [steal, [guest,
     [guest_nice]]])
    Last 3 fields may not be available on all Linux kernel versions.
    r�NrcS�g|]}t|�t�qSr@��float�CLOCK_TICKSr�r@r@rAr�_�zcpu_times.<locals>.<listcomp>)rr�rr�r�r�r��_fields)r�r�r�r�r@r@rA�	cpu_timesSs�rcCs�t�}t|�g}td|��7}|��|D]&}|�d�r<|��}|dttj�d�}dd�|D�}t|�}|�	|�q|Wd�S1sIwYdS)zfReturn a list of namedtuple representing the CPU times
    for every CPU available on the system.
    r�scpurcSrr@rr�r@r@rAr�qrz!per_cpu_times.<locals>.<listcomp>N)
rr�rr�r�r�r�r�rr�)r��cpusr�r�r�r��entryr@r@rA�
per_cpu_timescs

�$�rcCs�zt�d�WStyvd}tdt���}|D]
}|���d�r&|d7}qWd�n1s1wY|dkrkt�d�}t	dt���}|D]}|�
d	�d}|�|�r[|d7}qIWd�n1sfwY|dkrrYdS|YSw)
z0Return the number of logical CPUs in the system.�SC_NPROCESSORS_ONLNr�
%s/cpuinfos	processorrNzcpu\dr�r�)r��sysconf�
ValueErrorrr�lowerr��re�compilerr��match)�numr�r��searchr@r@rA�cpu_count_logicalws2���

����rc
Cs.t�}d}d}t�|�pt�|�D]}t|��}|�|�����Wd�n1s+wYqt|�}|dkr;|Si}i}tdt���?}|D]4}|����}|sjz
|d||d<Wn	t	yfYnwi}qI|�
d�r}|�d	d
�\}	}
t|
�||	<qIWd�n1s�wYt
|���}|p�dS)z-Return the number of CPU cores in the system.z9/sys/devices/system/cpu/cpu[0-9]*/topology/core_cpus_listz?/sys/devices/system/cpu/cpu[0-9]*/topology/thread_siblings_listNrr�	cpu cores�physical id)r!r s	:r)�set�globr�addr�r�r�rrr�r�r�r��sumr�)�ls�p1�p2rpr��result�mapping�current_infor��key�valuer@r@rA�cpu_count_cores�s@
����
���r.cCs�tdt���J}d}d}d}|D]9}|�d�r t|��d�}n|�d�r.t|��d�}n
|�d�r;t|��d�}|durI|durI|durInqWd�n1sTwYd}t�||||�S)z*Return various CPU stats as a named tuple.r�Nsctxtrsintrssoftirqr)rrr�r�r�r�	scpustats)r��ctx_switches�
interrupts�soft_interruptsr��syscallsr@r@rA�	cpu_stats�s(


���r4c	Csjg}tdt���"}|D]}|���d�r"|�t|�dd�d��qWd�|S1s.wY|S)z<Return current CPU frequency from cpuinfo if available.
    rscpu mhz�:rN)rrrr�r�r
r�)r�r�r�r@r@rA�_cpu_get_cpuinfo_freq�s��
��r6z'/sys/devices/system/cpu/cpufreq/policy0z$/sys/devices/system/cpu/cpu0/cpufreqc	Cs�t�}t�d�pt�d�}|jdd�d�g}tjj}t|�D]U\}}t|�t|�kr0||}n	t||d�dd�}|durNt||d	�dd�}|durNt	d
��t
|�d}t
t||d���d}t
t||d
���d}|�t�
|||��q|S)z�Return frequency metrics for all CPUs.
        Contrarily to other OSes, Linux updates these values in
        real-time.
        z,/sys/devices/system/cpu/cpufreq/policy[0-9]*z)/sys/devices/system/cpu/cpu[0-9]*/cpufreqcSstt�d|����S)Nz[0-9]+)r�rr�group)rIr@r@rA�<lambda>��zcpu_freq.<locals>.<lambda>)r,�scaling_cur_freqN�r��cpuinfo_cur_freqz!can't find current frequency filei��scaling_max_freq�scaling_min_freq)r6r#�sortr�rpr��	enumerater�r��NotImplementedErrorr�r�r�scpufreq)	�
cpuinfo_freqs�pathsr��pjoin�irp�curr�max_�min_r@r@rA�cpu_freq�s,
�
�rJcCsdd�t�D�S)z}Alternate implementation using /proc/cpuinfo.
        min and max frequencies are not available and are set to None.
        cSsg|]	}t�|dd��qS)r�)rrBr�r@r@rAr��zcpu_freq.<locals>.<listcomp>)r6r@r@r@rArJsc@seZdZdS)�_Ipv6UnsupportedErrorN)r=r>r?r@r@r@rArLsrLc@sZeZdZdZdd�Zdd�Zdd�Zedd	��Zeddd��Z	edd
d��Z
ddd�Zd
S)�ConnectionsawA wrapper on top of /proc/net/* files, retrieving per-process
    and system-wide open connections (TCP, UDP, UNIX) similarly to
    "netstat -an".

    Note: in case of UNIX sockets we're only able to determine the
    local endpoint/path, not the one it's connected to.
    According to [1] it would be possible but not easily.

    [1] http://serverfault.com/a/417946
    cCs�dtjtjf}dtjtjf}dtjtjf}dtjtjf}dtjdf}|||||f||f|f|f||f|f|f|f||||f||f||fd�|_d|_dS)N�tcp�tcp6�udp�udp6�unix)�allrN�tcp4rOrP�udp4rQrR�inet�inet4�inet6)�socket�AF_INET�SOCK_STREAM�AF_INET6�
SOCK_DGRAM�AF_UNIX�tmap�_procfs_path)�selfrTrOrUrQrRr@r@rA�__init__ s$
�

zConnections.__init__cCs�tt�}t�d|j|f�D]\}ztd|j||f�}Wn3ttfy'YqtyO}z|j	t	j
kr:WYd}~q|j	t	jkrJt|�WYd}~q�d}~ww|�
d�rj|dd�dd�}||�|t|�f�q|S)N�%s/%s/fd�%s/%s/fd/%szsocket:[r�r7)r�listr��listdirr`r�rrr�r��EINVAL�ENAMETOOLONGrr�r�r�)rar��inodesrq�inoderr@r@rA�get_proc_inodes7s(��

�zConnections.get_proc_inodescCs@i}t�D]}z
|�|�|��WqtttfyYqw|S�N)�pids�updaterkrrr)rarir�r@r@rA�get_all_inodesQs
�	zConnections.get_all_inodesc	Cs�|�d�\}}t|d�}|sdStr|�d�}|tjkr7tr-t�|t�	|�ddd��}nFt�|t�	|��}n<t�	|�}z)trRt�tj
tjdgt�
d|��R��}nt�tj
tjdgt�
d|��R��}Wn
tyrt�sqt��wt�||�S)	a�Accept an "ip:port" address as displayed in /proc/net/*
        and convert it into a human readable form, like:

        "0500000A:0016" -> ("10.0.0.5", 22)
        "0000000000000000FFFF00000100007F:9E49" -> ("::ffff:127.0.0.1", 40521)

        The IP address portion is a little or big endian four-byte
        hexadecimal number; that is, the least significant byte is listed
        first, so we need to reverse the order of the bytes to convert it
        to an IP address.
        The port is represented as a two-byte hexadecimal number.

        Reference:
        http://linuxdevcenter.com/pub/a/linux/2000/11/16/LinuxAdmin.html
        �:�r@�asciiNr7z>4Iz<4I)r�r�r�encoderYrZ�
LITTLE_ENDIAN�	inet_ntop�base64�	b16decoder\�struct�pack�unpackrrrLr�addr)r{�family�ip�portr@r@rA�decode_addressas8



����zConnections.decode_addressNccsF�|�d�rtj�|�sdSt|td���}|��t|d�D]r\}}z|��dd�\
}}	}
}}}}}}}Wnt	yFt
d|||f��w||vrT||d\}
}nd\}
}|dura||
kraq|tjkrkt
|}ntj}zt�|	|�}	t�|
|�}
Wn	ty�Yqw||||	|
||
fVqWd�dS1s�wYdS)	z.Parse /proc/net/tcp* and /proc/net/udp* files.�6N��	bufferingrr�z,error while parsing %s; malformed line %s %rr�Nr7)r�r�rp�existsr�BIGFILE_BUFFERINGr�r@r�r�RuntimeErrorrYr[�TCP_STATUSESr�	CONN_NONErMrrL)�filer|�type_ri�
filter_pidr��linenor�r�laddr�raddr�statusrjr�rqr@r@rA�process_inet�sB�����

��"�zConnections.process_inetc
cs�t|td��z}|��|D]j}|��}z|dd�\}}}}}}}	Wnty8d|vr0Yqtd||f��w|	|vrB||	}
ndg}
|
D]0\}}|durT||krTqGt|�dkr_|d	}
nd
}
t�t	|��}d
}tj
}||||
|||fVqGqWd�dS1s�wYdS)zParse /proc/net/unix files.r�r�r�z)error while parsing %s; malformed line %rr�Nr�r7�)rr�r�r�rr�r�r�socktype_to_enumr�r�)r�r|rir�r�r��tokensrr�rj�pairsr�rqrpr�r�r@r@rA�process_unix�s@����

��"�zConnections.process_unixcCs||jvrtd|d�dd�|jD��f��t�|_|dur(|�|�}|s'gSn|��}t�}|j|D]Q\}}}d|j|f}|tj	tj
fvrS|j|||||d�}	n	|j||||d�}	|	D]&\}
}}}}}
}|rtt
�|
|||||
�}nt
�|
|||||
|�}|�|�q^q4t|�S)Nz+invalid %r kind argument; choose between %sr�cSsg|]}t|��qSr@)�reprr�r@r@rAr��r9z(Connections.retrieve.<locals>.<listcomp>z	%s/net/%s)r�)r_rr�rr`rkror"rYrZr\r�r�r�pconn�sconnr$re)ra�kindr�rir��
proto_namer|r�rpr&rqr�r�r��	bound_pid�connr@r@rA�retrieve�s@
�
�
�����zConnections.retrieverl)r=r>r?�__doc__rbrkro�staticmethodrr�r�r�r@r@r@rArMs
2'%rMrVcCs
t�|�S)z$Return system-wide open connections.)�_connectionsr�)r�r@r@rA�net_connectionss
r�cCs�tdt���}|��}Wd�n1swYi}|dd�D]F}|�d�}|dks4Jt|���|d|���}||dd�����}tt|�\}}}	}
}}}
}}}}}}}}}|||||	||
|f||<q#|S)zsReturn network I/O statistics for every network interface
    installed on the system as a dict of raw tuples.
    z
%s/net/devNr;rprr)	rr�	readlines�rfindr�r�r��mapr�)r��lines�retdictr��colonr�r��
bytes_recv�packets_recv�errin�dropin�fifoin�framein�compressedin�multicastin�
bytes_sent�packets_sent�errout�dropout�fifoout�
collisionsout�
carrierout�
compressedoutr@r@rA�net_io_counters
s<
�
�
�r�c	Cs�tjttjttjti}t���}i}|D]?}zt	�
|�}t	�|�}t�|�\}}Wnt
yF}z|jtjkr8�t|�WYd}~qd}~wwt�|||||�||<q|S)z)Get NIC stats (isup, duplex, speed, mtu).N)r�DUPLEX_FULLr
�DUPLEX_HALFr�DUPLEX_UNKNOWNrr��keys�
cext_posix�
net_if_mtu�net_if_is_running�net_if_duplex_speedr�r��ENODEVrr�	snicstats)	�
duplex_map�namesr�r��mtu�isup�duplex�speedrr@r@rA�net_if_stats/s&�


��r�FcCs�dd�}dd�}tj�dt��r|�}ntj�d�r|�}ntdt���i}|D]*}|\
}}}}	}
}}}
}}|s?t|�s?q*|	t9}	|
t9}
|||	|
|||
||f	||<q*|S)zcReturn disk I/O statistics for every disk installed on the
    system as a dict of raw tuples.
    cssB�tdt���}|��}Wd�n1swY|D]�}|��}t|�}|dkrJ|d}t|d�}tt|dd��\
}}}	}
}}}
}}}nG|dksR|dkrk|d}tt|dd��\}}}}	}
}}}
}}}n&|dkr�|d}tt|dd��\}}}
}d	}	}
}}}ntd
|��|||
|||	|
|||f
VqdS)N�%s/diskstats�r"r;r#��r�rz!not sure how to interpret line %r)rrr�r�r�r�r�r)r�r�r�r��flenr��reads�reads_merged�rbytes�rtime�writes�
writes_merged�wbytes�wtimerrnr@r@rA�read_procfsRs6�
�����z%disk_io_counters.<locals>.read_procfscss��t�d�D]^}t�tj�d|��D]Q\}}}d|vrqttj�|d���}|������}Wd�n1s8wYtj�	|�}t
t|dd��\
}}}	}
}}}
}}}||||	|
|
||||f
VqqdS)N�
/sys/block�statr�)r�rf�walkrpr�rr�r�r��basenamer�r�)�block�rootr�filesr�r�r�r�r�r�r�r�r�r�r�rnr@r@rA�
read_sysfs}s"������z$disk_io_counters.<locals>.read_sysfsr�r�zC%s/diskstats nor /sys/block filesystem are available on this system)r�rpr�rrAr��DISK_SECTOR_SIZE)�perdiskr�r��genr�rr�r�r�r�r�r�r�r�r�rnr@r@rA�disk_io_countersNs0+
���
�r�c@s@eZdZdZddgZdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�RootFsDeviceFinderaEdisk_partitions() may return partitions with device == "/dev/root"
    or "rootfs". This container class uses different strategies to try to
    obtain the real device path. Resources:
    https://bootlin.com/blog/find-root-device/
    https://www.systutorials.com/how-to-find-the-disk-where-root-is-on-in-bash-on-linux/
    �major�minorcCs(t�d�j}t�|�|_t�|�|_dS)Nr�)r�r��st_devr�r�)ra�devr@r@rArb��zRootFsDeviceFinder.__init__cCs�tdt���X}|��dd�D]F}|��}t|�dkrq|d��r)t|d�nd}|d��r7t|d�nd}|d}||jkrV||jkrV|rVd|Wd�SqWd�dS1sbwYdS)Nz
%s/partitionsr;r#rrr"�/dev/%s)	rrr�r�r��isdigitr�r�r�)rar�r�r�r�r�r�r@r@rA�ask_proc_partitions�s
��"�z&RootFsDeviceFinder.ask_proc_partitionscCs�d|j|jf}t|��+}|D]}|�d�r.|���d�d}|r.d|Wd�SqWd�dS1s:wYdS)Nz/sys/dev/block/%s:%s/ueventzDEVNAME=r;r�)r�r�rr�r��
rpartition)rarpr�r�r�r@r@rA�ask_sys_dev_block�s


��"�z$RootFsDeviceFinder.ask_sys_dev_blockc	Cs�d|j|jf}t�d�}|D]E}zt|�}Wn	ty Yqw|�)|����}||krEtj	�
tj	�|��}d|Wd�SWd�n1sOwYqdS)Nz%s:%sz/sys/class/block/*/devr�)r�r�r#�iglobrrr�r�r�rpr��dirname)ra�needler�r�r��datar�r@r@rA�ask_sys_class_block�s$
�����z&RootFsDeviceFinder.ask_sys_class_blockc
Cs�d}|dur%z|��}Wnttfy$}z
t|�WYd}~nd}~ww|durHz|��}WnttfyG}z
t|�WYd}~nd}~ww|durkz|��}Wnttfyj}z
t|�WYd}~nd}~ww|durwtj�|�ry|SdSdSrl)	r�r�r�rr�r�r�rpr�)rarprr@r@rA�find�s2�������zRootFsDeviceFinder.findN)
r=r>r?r��	__slots__rbr�r�r�r�r@r@r@rAr��s
	r�c	Cs<t�}t�}td|��.}|D]#}|��}|�d�s"|�|���q|�d�d}|dkr2|�d�qWd�n1s=wY|dkrStj�	d�rStj�
d�}ntj�
d	|�}g}t�|�}|D]7}	|	\}
}}}|
d
krrd}
|
dvr}t
���p||
}
|s�|
dks�||vr�qdd}
}t�|
||||
|�}|�|�qd|S)
z8Return mounted disk partitions as a list of namedtuples.z%s/filesystems�nodev�	r�zfsNr�z	/etc/mtabz%s/self/mounts�noner�)z	/dev/root�rootfs)r"rrr�r�r$r�r�rp�isfile�realpathr�disk_partitionsr�r�r�	sdiskpartr�)rS�fstypesr�r�r��fstype�mounts_path�retlist�
partitions�	partition�device�
mountpoint�opts�maxfile�maxpath�ntupler@r@rAr��sB

���
�r�cCs@t�t�}t�d�}|�t�d��ttdd�|D���}t�d�}t�d�}|D]}|�	d|�}||vr:|�
|�q)|D]�}z|d}tt|��d	}t
j�t
j�|�d
�}t|dd�}	WntttfyjYq=wt|d
dd�}
t|ddd�}t|dddd�}|
dur�zt|
�d	}
Wnty�d}
Ynw|dur�zt|�d	}Wnty�d}Ynw||	�
|||
|f�q=|�s�t�d�}tt|��}|D]�}zt
j�|d�}tt|��d	}t
j�|d�}t|dd�}	Wntttf�y
}
z
t|
�WYd}
~
q�d}
~
wwt�|d�}tdd�|D��}d}d}
|D]n}t
j�||d�}t|ddd�}|dk�rFtt
j�||d�dd�}n|dk�rXtt
j�||d�dd�}
|
du�rrzt|
�d	}
Wnt�yqd}
Ynw|du�r�z	t|�d	}W�q!t�y�d}Y�q!w�q!||	�
d||
|f�q�t|�S)a�Return hardware (CPU and others) temperatures as a dict
    including hardware name, label, current, max and critical
    temperatures.

    Implementation notes:
    - /sys/class/hwmon looks like the most recent interface to
      retrieve this info, and this implementation relies on it
      only (old distros will probably use something else)
    - lm-sensors on Ubuntu 16.04 relies on /sys/class/hwmon
    - /sys/class/thermal/thermal_zone* is another one but it's more
      difficult to parse
    z/sys/class/hwmon/hwmon*/temp*_*z&/sys/class/hwmon/hwmon*/device/temp*_*cS�g|]	}|�d�d�qS�rr�r�r�r@r@rAr�7rKz(sensors_temperatures.<locals>.<listcomp>z5/sys/devices/platform/coretemp.*/hwmon/hwmon*/temp*_*z'/sys/devices/platform/coretemp.*/hwmon/z/sys/class/hwmon/�_inputg@�@r�F�r��_maxNr;�_crit�_labelr��r�r�z /sys/class/thermal/thermal_zone*�temp�typez/trip_point*cSs,g|]}d�tj�|��d�dd���qS)rrr")r�r�rpr�r�)r��pr@r@rAr�ws
���_type�critical�_temp�high)�collectionsrrer#�extend�sortedr"rr�subr�r
r�r�rpr�r�r�r�rr�dict)r��	basenames�
basenames2�replr��altname�baserpr��	unit_namerr�labelr�
trip_paths�trip_points�
trip_point�	trip_typer@r@rA�sensors_temperatures$s�

�

�	���
���
�
�
�

��r,cCs�t�t�}t�d�}|st�d�}ttdd�|D���}|D]H}z
tt|d��}Wntt	fyB}z
t
|�WYd}~qd}~wwttj�
tj�|�d�dd	�}t|d
ddd�}||�t�||��qt|�S)
a�Return hardware fans info (for CPU and other peripherals) as a
    dict including hardware label and current speed.

    Implementation notes:
    - /sys/class/hwmon looks like the most recent interface to
      retrieve this info, and this implementation relies on it
      only (old distros will probably use something else)
    - lm-sensors on Ubuntu 16.04 relies on /sys/class/hwmon
    z/sys/class/hwmon/hwmon*/fan*_*z%/sys/class/hwmon/hwmon*/device/fan*_*cSrr
rr�r@r@rAr��rKz sensors_fans.<locals>.<listcomp>rNr�Frrr�r)rrrer#rr"r�r�r�r�rr�rpr�r�r�r�sfanr )r�r!r%r�rr&r'r@r@rA�sensors_fans�s&



���r.cs�t���fdd�}dd�t�t�D�}|sdStj�tt|�d�}||d|d�}||d	|d
�}||d|d�}||d
�}|dur_|dur_zd||}Wnty^d}Ynwtt	|ddd��}|dkrodSd}|tj�td�tj�td��}	|	dur�|	dk}nt	|dddd��
�}
|
dkr�d}n|
dvr�d}|r�tj}n4|dur�|dur�z
t||d�}Wn!ty�tj
}Ynw|dur�t|d�}|dkr�tj
}ntj
}t�|||�S)aReturn battery information.
    Implementation note: it appears /sys/class/power_supply/BAT0/
    directory structure may vary and provide files with the same
    meaning but under different names, see:
    https://github.com/giampaolo/psutil/issues/966
    c	sL|D]!}t|�d�}|�kr#zt|�WSty"|YSwqdS)zvAttempt to read the content of multiple files which may
        not exist. If none of them exist return None.
        r;N)r�r�r)rDrpr���nullr@rA�	multi_cat�s��z"sensors_battery.<locals>.multi_catcSs&g|]}|�d�sd|��vr|�qS)�BAT�battery)r�rr�r@r@rAr��s�z#sensors_battery.<locals>.<listcomp>Nrz/energy_nowz/charge_nowz
/power_nowz/current_nowz/energy_fullz/charge_fullz/time_to_empty_nowgY@r�z	/capacityr7r;z
AC0/onlinez	AC/onlinerz/statusr�Fr�discharging)�charging�fullTi�<)�objectr�rf�POWER_SUPPLY_PATHrpr�r�ZeroDivisionErrorr�r�rr�POWER_TIME_UNLIMITED�POWER_TIME_UNKNOWN�sbattery)r1�batsr��
energy_now�	power_now�energy_full�
time_to_emptyr\�
power_plugged�onliner��secsleftr@r/rA�sensors_battery�sn
�����

��rFc
Cs\g}t��}|D]#}|\}}}}}}|sq|dvrd}t�||p!d|||�}	|�|	�q|S)z:Return currently connected users as a list of namedtuples.)z:0.0z:0�	localhostN)r�usersr�suserr�)
r�rawlist�itemr��tty�hostname�tstamp�user_processr��ntr@r@rArHsrHcCsvdt�}t|��(}|D]}|�d�r*t|����d�}|a|Wd�Sqtd|��1s4wYdS)zAReturn the system boot time expressed in seconds since the epoch.r�sbtimerNzline 'btime' not found in %s)rrr�r
r�r��	BOOT_TIMEr�)rpr�r�r�r@r@rA�	boot_time(s


���rRcCsdd�t�tt���D�S)z7Returns a list of PIDs currently running on the system.cSsg|]
}|��rt|��qSr@)r�r�r�r@r@rAr�=szpids.<locals>.<listcomp>)r�rfr rr@r@r@rArm;�rmc	Cs�t�|�sdSz=dt�|f}t|��'}|D]}|�d�r3t|��d�}||kWd�WSqtd|��1s=wYWdSttfyT|t	�vYSw)zcCheck for the existence of a unix PID. Linux TIDs are not
    supported (always return False).
    F�%s/%s/statussTgid:rNz'Tgid' line not found in %s)
r�
pid_existsrrr�r�r�r�EnvironmentErrorrm)r�rpr�r��tgidr@r@rArU@s 




���rUc
Cs�i}t�}t�D]E}ztd||f��}|��}Wd�n1s"wYWnttfy3Yqw|�d�}||dd���}t|d�}|||<q|S)zsObtain a {pid: ppid, ...} dict for all running processes in
    one shot. Used to speed up Process.children().
    �
%s/%s/statN�)r;r)	rrmrr�rrr�r�r�)r�r�r�r�r��rpar�dset�ppidr@r@rA�ppid_map`s 

���

r]cst����fdd��}|S)zlDecorator which translates bare OSError and IOError exceptions
    into NoSuchProcess and AccessDenied.
    cs�z�|g|�Ri|��WStyt|j|j��ty't|j|j��tyAtj�	d|j
|jf�s@t|j|j���w)N�%s/%s)rr
r��_namerrrr�rpr�r`)ra�args�kwargs��funr@rA�wrapperzs�z wrap_exceptions.<locals>.wrapper)�	functools�wraps)rcrdr@rbrA�wrap_exceptionsvs
rgc@sdeZdZdZgd�Zdd�Zdd�Zeedd���Z	eed	d
���Z
eedd���Zd
d�Zdd�Z
edd��Zdd�Zedd��Zedd��Zedd��Zej�de���r^edd��Zedd��Zed d!��Zed\d#d$��Zed%d&��Zed'd(��Zer�ee�d)�e�d*�e�d+�fd,d-��Z neZ er�ed.d/��Z!ed0d1��Z"ee�d2�fd3d4��Z#ee�d5�fd6d7��Z$ed8d9��Z%ed:d;��Z&ed<d=��Z'e(r�ed>d?��Z)e�d@�fdAdB�Z*edCdD��Z+e,r�edEdF��Z-edGdH��Z.e/d"ur�ed\dIdJ��Z0edKdL��Z1edMdN��Z2ed]dPdQ��Z3edRdS��Z4edTdU��Z5ee�dV�fdWdX��Z6ee�dY�fdZd[��Z7d"S)^�ProcesszLinux process implementation.)r�r_�_ppidr`�_cachecCs||_d|_d|_t�|_dSrl)r�r_rirr`)rar�r@r@rArb�szProcess.__init__cCst�d|j|jf�dS)z+Raise NSP if the process disappeared on us.r^N)r�r�r`r��rar@r@rA�
_assert_alive�szProcess._assert_alivecCs�td|j|jf��}|��}Wd�n1swY|�d�}||�d�d|�}||dd���}i}||d<|d|d	<|d|d
<|d|d<|d
|d<|d|d<|d|d<|d|d<|d|d<|d|d<|d|d<|S)aZParse /proc/{pid}/stat file and return a dict with various
        process info.
        Using "man proc" as a reference: where "man proc" refers to
        position N always substract 3 (e.g ppid position 4 in
        'man proc' == position 1 in here).
        The return value is cached in case oneshot() ctx manager is
        in use.
        rXNrY�(rr;r�rr�r\r#�ttynr��utime��stime�
�children_utimer��children_stime��create_time�$�cpu_num�'�blkio_ticks)rr`r�r�r�r�r�)rar�r�rZr�r�r�r@r@rA�_parse_stat_file�s&
�
zProcess._parse_stat_filecCs@td|j|jf��}|��Wd�S1swYdS)z�Read /proc/{pid}/stat file and return its content.
        The return value is cached in case oneshot() ctx manager is
        in use.
        rTN)rr`r�r��rar�r@r@rA�_read_status_file�s$�zProcess._read_status_filecCsHtd|j|jftd��}|����Wd�S1swYdS)Nz%s/%s/smapsr�)rr`r�r�r�r�r}r@r@rA�_read_smaps_file�s�
$�zProcess._read_smaps_filecC�(|j�|�|j�|�|j�|�dSrl)r|�cache_activater~rrkr@r@rA�
oneshot_enter�r�zProcess.oneshot_entercCr�rl)r|�cache_deactivater~rrkr@r@rA�oneshot_exit�r�zProcess.oneshot_exitcCs|��d}trt|�}|S)Nr�)r|rr)rar�r@r@rAr��szProcess.namec	Cs�ztd|j|jf�WSttfy8tj�d|j|jf�r#YdSt|j�s/t	|j|j
��t|j|j
|j��t
yEt|j|j
��w)Nz	%s/%s/exer^r�)r�r`r�rrr�rp�lexistsrUrr_rrirr
rkr@r@rA�exe�s
�zProcess.execCs�td|j|jf��}|��}Wd�n1swY|s"gS|�d�r)dnd}|�|�r6|dd�}|�|�}|dkrNt|�dkrNd|vrN|�d�}|S)Nz
%s/%s/cmdliner�r�r7r)rr`r�r�r�r�r�)rar�r��sep�cmdliner@r@rAr��s
�


zProcess.cmdlinecCsJtd|j|jf��}|��}Wd�t|�S1swYt|�S)Nz
%s/%s/environ)rr`r�r�r)rar�r�r@r@rA�environs

��zProcess.environcCs8t|��d�}t��}z||WStyYdSw)Nrn)r�r|r�get_terminal_mapr�)ra�tty_nrr_r@r@rA�terminals
�zProcess.terminalz/proc/%s/ioc
Cs�d|j|jf}i}t|��,}|D]!}|��}|r2z	|�d�\}}Wn	ty+Yqwt|�||<qWd�n1s=wY|sJtd|��zt|d|d|d|d|d|d	�WSt	yw}ztd
|d||f��d}~ww)Nz%s/%s/ios: z%s file was emptyssyscrssyscws
read_bytesswrite_bytessrcharswcharz1%r field was not found in %s; found fields are %rr)
r`r�rr�r�rr�r�r�r�)rar�r�r�r�r�r-rr@r@rA�io_counterss@
��������zProcess.io_counterscCsh|��}t|d�t}t|d�t}t|d�t}t|d�t}t|d�t}t|||||�S)Nrprrrtrur{)r|r
rr�)rar�rprrrtrur�r@r@rAr<szProcess.cpu_timescC�t|��d�S)zWhat CPU the process is on.ry�r�r|rkr@r@rAryFszProcess.cpu_numNcCst�|j||j�Srl)r�wait_pidr�r_)ra�timeoutr@r@rA�waitKszProcess.waitcCs&t|��d�}tpt�}|t|S)Nrw)r
r|rQrRr)ra�ctime�btr@r@rArwOs
zProcess.create_timec	Csttd|j|jf��}dd�|����dd�D�\}}}}}}}Wd�n1s+wYt|||||||�S)Nz%s/%s/statmcSsg|]}t|�t�qSr@)r�r�r�r@r@rAr�irz'Process.memory_info.<locals>.<listcomp>r�)rr`r�r�r�ru)	rar��vmsr{rc�text�libr��dirtyr@r@rA�memory_infoZs

��zProcess.memory_infos\nPrivate.*:\s+(\d+)s\nPss\:\s+(\d+)s\nSwap\:\s+(\d+)c	Csj|��}|��}ttt|�|���d}ttt|�|���d}ttt|�|���d}t||||f�S)Nr�)r�rr%r�r��findallrv)	ra�_private_re�_pss_re�_swap_re�	basic_mem�
smaps_datarwrxryr@r@rA�memory_full_infops
zProcess.memory_full_infocCsPdd�}|��}|sgS|�d�}g}|�d�}|g}|||�D]�\}}|�dd�}z
|\}	}
}}}
}WntyH|dg\}	}
}}}
}Ynw|sNd}ntrTt|�}|��}|�d	�rgt|�sg|dd
�}|�	t|	�t|
�||�
dd�|�
dd�|�
d
d�|�
dd�|�
dd�|�
dd�|�
dd�|�
dd�|�
dd�|�
dd�f
�q |S)aPReturn process's mapped memory regions as a list of named
            tuples. Fields are explained in 'man proc'; here is an updated
            (Apr 2012) version: http://goo.gl/fmebo

            /proc/{PID}/smaps does not exist on kernels < 2.6.14 or if
            CONFIG_MMU kernel configuration option is not enabled.
            c	ss��i}|D]@}|�dd�}|d�d�s!|��|fV|�|�qzt|d�d||d<WqtyE|d�d�r?Yqtd|��w|��|fVdS)N�rr5rr�sVmFlags:z#don't know how to interpret line %r)r�r��popr�r�rr�)r��
current_blockr�r�r�r@r@rA�
get_blocks�s"���z'Process.memory_maps.<locals>.get_blocks�
rNr�r�z[anon]r�r�sRss:sSize:sPss:s
Shared_Clean:s
Shared_Dirty:sPrivate_Clean:sPrivate_Dirty:sReferenced:s
Anonymous:sSwap:)rr�r�rrrr�r�rr�r�)rar�r�r�r&�
first_liner��header�hfieldsr{�perms�offsetr�rjrpr@r@rA�memory_maps�sN	

��
�









�
zProcess.memory_mapsc	CsTztd|j|jf�WSttfy)t|j�s t|j|j��t|j|j|j	��w)Nz	%s/%s/cwd)
r�r`r�rrrUrr_rrirkr@r@rA�cwd�s
�zProcess.cwdsctxt_switches:\t(\d+)cCsF|��}|�|�}|std|j|jf��t�t|d�t|d��S)Nz�'voluntary_ctxt_switches' and 'nonvoluntary_ctxt_switches'lines were not found in %s/%s/status; the kernel is probably older than 2.6.23rr)r~r�rAr`r�r�pctxswr�)ra�	_ctxsw_rer��ctxswr@r@rA�num_ctx_switches�s
���zProcess.num_ctx_switchessThreads:\t(\d+)cCs|��}t|�|�d�S�Nr)r~r�r�)ra�_num_threads_rer�r@r@rA�num_threads�szProcess.num_threadsc	Cs�t�d|j|jf�}|��g}d}|D]a}d|j|j|f}zt|��}|����}Wd�n1s6wYWntyGd}Yqw||�	d�dd�}|�
d�}t|d�t}	t|d	�t}
t
�t|�|	|
�}|�|�q|r}|��|S)
Nz
%s/%s/taskFz%s/%s/task/%s/statTrYr;rrorq)r�rfr`r�r?rr�r�rr�r�r
rr�pthreadr�r�rl)ra�
thread_idsr�
hit_enoent�	thread_idr�r��str�rprrrr@r@rA�threads�s4
�
���
zProcess.threadscC�t�|j�Srl)r��getpriorityr�rkr@r@rA�nice_getszProcess.nice_getcCst�|j|�Srl)r��setpriorityr�)rar-r@r@rA�nice_setszProcess.nice_setcCr�rl)rr5r�rkr@r@rA�cpu_affinity_get"szProcess.cpu_affinity_getsCpus_allowed_list:\t(\d+)-(\d+)cCsR|��}|�|�}|r ttt|dd�t|dd�d��Stttt����S)Nrr)r~r�re�ranger�r�r)ra�_rer�rr@r@rA�_get_eligible_cpus&s

*zProcess._get_eligible_cpusc
Cs�z
t�|j|�WdSttfyN}z6t|t�s|jtjkrI|��}t	t
tt����}|D]}||vr<td||f��||vrHtd||f��q.�d}~ww)Nz(invalid CPU number %r; choose between %sz0CPU number %r is not eligible; choose between %s)
r�proc_cpu_affinity_setr�r�rr�r�rgr��tupler�r�r)rarr�
eligible_cpus�all_cpus�cpur@r@rA�cpu_affinity_set0s.�������zProcess.cpu_affinity_setcCs,t�|j�\}}tdurt|�}t�||�Srl)rr4r��enumr<r�pionice�ra�ioclassr-r@r@rA�
ionice_getFszProcess.ionice_getcCsP|durd}|r|ttfvrtd|��|dks|dkr td��t�|j||�S)Nrz%r ioclass accepts no valuer�zvalue not in 0-7 range)r(r%rr�proc_ioprio_setr�r�r@r@rA�
ionice_setMszProcess.ionice_setc
Cs�|jdkr	td��z#|durt|j|�WSt|�dkr#tdt|���t|j||�WdStyM}z|jtjkrHt|j�rHt	|j|j
|j���d}~ww)Nrz)can't use prlimit() against PID 0 processr;z4second argument must be a (soft, hard) tuple, got %s)r�rr�r�r�r�r��ENOSYSrUrr_ri)rar�r�rr@r@rA�rlimitYs$
����zProcess.rlimitcCs$|��d}tr|��}t�|d�S)Nr��?)r|rr�
PROC_STATUSESr�)ra�letterr@r@rAr�sszProcess.statusc
Cs~g}t�d|j|jf�}d}|D]�}d|j|j|f}zt|�}Wn5ttfy/d}YqtyW}z|jtj	krBWYd}~q|jtj
krRt|�WYd}~q�d}~ww|�d�r�t
|�r�d|j|j|f}z+t|��}t|����d�}	t|����dd�}
Wd�n1s�wYWnty�d}Yqwt|
�}t|t|�t|	�||
�}|�|�q|r�|��|S)	NrcFrdTr�z%s/%s/fdinfo/%srr�)r�rfr`r�r�rrr�r�rgrhrr�rrr�r�r�r�ror�rl)
rarr�r�rqr�rprr��posrtrsrr@r@rA�
open_files{sR��
�
����
�zProcess.open_filesrVcCst�||j�}|��|Srl)r�r�r�rl)rar�r�r@r@rA�connections�szProcess.connectionscCstt�d|j|jf��S)Nrc)r�r�rfr`r�rkr@r@rA�num_fds�rSzProcess.num_fdscCr�)Nr\r�rkr@r@rAr\�szProcess.ppidsUid:\t(\d+)\t(\d+)\t(\d+)cC�6|��}|�|�d\}}}t�t|�t|�t|��Sr�)r~r�r�puidsr�)ra�_uids_rer��real�	effective�savedr@r@rA�uids��zProcess.uidssGid:\t(\d+)\t(\d+)\t(\d+)cCr�r�)r~r�r�pgidsr�)ra�_gids_rer�r�r�r�r@r@rA�gids�r�zProcess.gidsrl�rV)8r=r>r?r�r�rbrlrgrr|r~rr�r�r�r�r�r�r�r�rpr��getpidr�rryr�rwr��	HAS_SMAPSrrr�r�r�r�r�r�r�r��HAS_CPU_AFFINITYr�r�r��HAS_PROC_IO_PRIORITYr�r�r�r�r�r�r�r�r\r�r�r@r@r@rArh�s�!



	

	



�
C

�





�



	

/

rhrlr�)F)�r��
__future__rrvrr�rer#r�rrYrx�sys�	tracebackr�rrr�rrrrr	r�r
rrr
rrrrrrrrrrrrrr�_compatrrrrr r!�version_infor��__extra__all__r9rpr�r�r��hasattrr�r�r8r�rr�getpagesizer�rQr��	byteorderrtr��	AF_PACKETr:�IntEnumr�r9r%r&r'r(r<�globalsrn�__members__�STATUS_RUNNING�STATUS_SLEEPING�STATUS_DISK_SLEEP�STATUS_STOPPED�STATUS_TRACING_STOP�
STATUS_ZOMBIE�STATUS_DEAD�STATUS_WAKE_KILL�
STATUS_WAKING�STATUS_IDLE�
STATUS_PARKEDr�r)r*r+r,r-r.r/r0r1r2r3r�rYrerorurrvrzr�r�r�r�r�r�r�r�r��	Exception�	print_excr�r��resource�ImportErrorr��CDLLr�r�dirr�r�r
rrrr.r4r6rJ�net_if_addrsrLrMr�r�r�r��
disk_usager�r�r�r,r.rFrHrRrmrUr]rgrhr@r@r@rA�<module>sj






�
�����
���


�
��
�	4z:*
�
!o
%
_
J-q a 

Youez - 2016 - github.com/yon3zu
LinuXploit