HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //opt/osm/venv/lib/python3.10/site-packages/psutil/__pycache__/_pslinux.cpython-310.pyc
o

=i1Q�
@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%ddlm&Z&ddlm'Z'ddlm(Z(ddlm)Z)gd�Z*dZ+ej,�-d e�.��d!��Z/ej,�-d e�.��d"��Z0e1ed#�Z2e1ed$�Z3e�4d%�Z5e�6�Z7ej8d&kZ9e:�Z;d'Z<e�=d(d)e>e
j?�i�Z@e@jAZAGd*d+�d+ej=�ZBeC��DeBjE�ejFejGejHejIejJejKejLejLejMejNejOejPd,�ZQejRejSejTejUejVejWejXejYejZej[ej\d-�Z]ed.gd/��Z^ed0gd1��Z_ed2gd3��Z`ed4d5�Zaed6eajbd7�Zced8gd9��Zded:d;d<�eedjb��Zfed=gd>��Zged?gd@��ZhdAdB�ZidCdD�ZjdEdF�Zke"dGdH��ZlzeldI�Wn#em�y�ZnzedJen���edKdL�dMdMdM�aoWYdZn[nndZn[nwwdNdO�ZpdPdQ�ZqdRdS�ZrdTdU�ZsdVdW�ZtdXdY�ZudZd[�Zvd\d]�Zwd^d_�Zxej,�-d`��sej,�-da��rdbdc�Zyndddc�ZyejzZzGdedf�dfem�Z{Gdgdh�dh�Z|e|�Z}d�djdk�Z~dldm�Zdndo�Z�ej�Z�d�dqdr�Z�Gdsdt�dt�Z�d�dudv�Z�dwdx�Z�dydz�Z�d{d|�Z�d}d~�Z�dd��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�Gd�d��d��Z�dS)�zLinux platform implementation.�N)�defaultdict)�
namedtuple�)�_common)�_psposix)�
_psutil_linux)�ENCODING)�NIC_DUPLEX_FULL)�NIC_DUPLEX_HALF)�NIC_DUPLEX_UNKNOWN)�AccessDenied)�
NoSuchProcess)�
ZombieProcess)�bcat)�cat)�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)ZPROCFS_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_supply�/proc/�/smaps�
/smaps_rollup�proc_ioprio_get�proc_cpu_affinity_get�
SC_CLK_TCK�littlei�
AddressFamily�AF_LINKc@seZdZdZdZdZdZdS)�
IOPriorityrr��N)�__name__�
__module__�__qualname__rrrr �r;r;�=/opt/osm/venv/lib/python3.10/site-packages/psutil/_pslinux.pyr5ds
r5)�R�S�D�T�t�Z�X�x�K�W�I�P)Z01Z02Z03Z04Z05Z06Z07Z08Z09Z0AZ0B�svmem)�total�	available�percent�used�free�active�inactive�buffers�cached�shared�slab�sdiskio)	�
read_count�write_count�
read_bytes�write_bytesZ	read_timeZ
write_timeZread_merged_countZwrite_merged_count�	busy_time�	popenfile)�path�fd�position�mode�flags�pmemz"rss vms shared text lib data dirty�pfullmem)�uss�pss�swap�
pmmap_grouped)r\�rss�sizerdZshared_cleanZshared_dirtyZ
private_cleanZ
private_dirtyZ
referencedZ	anonymousre�	pmmap_extzaddr perms � �pio)rVrWrXrYZ
read_charsZwrite_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���)�
isinstance�str�os�readlink�split�endswithr�r\r;r;r<rx�s
rxcCsXtjdtjdtjdi}||tjtjBtjB@}|tj@r$|�ddd�}|�dd�}|S)zZConvert file's open() flags into a readable string.
    Used by Process.open_files().
    �r�wzw+�arzr+)rw�O_RDONLY�O_WRONLY�O_RDWR�O_APPEND�replace)r`Z	modes_mapr_r;r;r<�file_flags_to_mode�s
r�cCs:|�dd�}d}|rd|��}nd|�d�}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/z/device)r�rw�access�F_OK)�nameZincluding_virtualr\r;r;r<�is_storage_device�s
r�cCs�t|�d���}|����dd�}Wd�n1swYgd�}t|�}|dkr2|�d�|dkr;|�d�|d	krD|�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.
    �/statrN)rm�nicernZidlerqZirqZsoftirq�Zsteal�	Zguest�
Z
guest_nice�	scputimes)r�readlinery�len�appendrr�)�procfs_path�f�values�fieldsZvlenr;r;r<�set_scputimes_ntuple�s	�


r��/proczignoring exception on import: r�zuser system idle�c
CsF|d}||�dd�}z|d}|d}|d}Wnty8}zt|jd�d��|WYd}~Sd}~wwz
tt��d	��}WntyN|YSwd}|� |D]}	|	��}	|	�d
�rk|t	|	�
�d�7}qVWd�n1svwY|t9}||}
||}|t|d|�8}|
|7}
|
|t|d
|�7}
t	|
�S)ayFallback for kernels < 3.14 where /proc/meminfo does not provide
    "MemAvailable", 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

    We use this function also when "MemAvailable" returns 0 (possibly a
    kernel bug, see: https://github.com/giampaolo/psutil/issues/1915).
    In that case this routine matches "free" CLI tool result ("available"
    column).

    XXX: on recent kernels this calculation may differ by ~1.5% compared
    to "MemAvailable:", as it's calculated slightly differently.
    It is still way more realistic than doing (free + cached) though.
    See:
    * https://gitlab.com/procps-ng/procps/issues/42
    * https://github.com/famzah/linux-memavailable-procfs/issues/2
    �MemFree:�Cached:rs
Active(file):sInactive(file):�
SReclaimable:zW is missing from /proc/meminfo; using an approximation for calculating available memoryNz	/zoneinfoslowrr6g@)
�get�KeyErrorr�argsrr�OSError�strip�
startswith�intry�PAGESIZE�min)�memsrN�fallbackZlru_active_fileZlru_inactive_fileZslab_reclaimable�errr�Z
watermark_low�line�availZ	pagecacher;r;r<�calculate_avail_vmemsD����
���r�cCs�g}i}tt��d���}|D]}|��}t|d�d||d<qWd�n1s,wY|d}|d}z|d}WntyOd}|�d	�Ynwz|d
}Wntyfd}|�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}Ynwz|d}
Wnt�yt|�}
Yn
w|
dk�rt|�}
|
dk�rd}
|�d�n|
|k�r |}
||
}t||
|dd�}|�rJd�	d�
|�t|�dk�r?dnd�}tj
|tdd �t||
||||
||||	|�S)!a7Report virtual memory stats.
    This implementation mimics procps-ng-3.3.12, aka "free" CLI tool:
    https://gitlab.com/procps-ng/procps/blob/
        24fd2605c51fccc375ab0287cec33aa767f06718/proc/sysinfo.c#L778-791
    The returned values are supposed to match both "free" and "vmstat -s"
    CLI tools.
    �/meminfor�rNs	MemTotal:r�sBuffers:rQr�rRr�sShmem:s
MemShared:rSsActive:rOs	Inactive:sInact_dirty:sInact_clean:sInact_laundry:rPsSlab:s
MemAvailable:rK�Zround_z6{} memory stats couldn't be determined and {} set to 0z, �was�werer6��
stacklevel)rrryr�r�r�r�r�r�format�joinr��warnings�warn�RuntimeWarningrI)Zmissing_fieldsr�r�r�r�rJrNrQrRrSrOrPrTr�rMrL�msgr;r;r<�virtual_memoryYs�����	�����������
�


��r�c
Cs�i}tt��d���}|D]}|��}t|d�d||d<q
Wd�n1s*wYz
|d}|d}WntyUt��\}}}}}}}||9}||9}Ynw||}t||dd�}	z
tt��d	��}Wn$ty�}
zd
|
�d�}t	j
|tdd
�d}}
WYd}
~
nad}
~
ww|�Rd}}
|D]1}|�d�r�t|�d�d�dd}n|�d�r�t|�d�d�dd}
|dur�|
dur�nq�d}|d7}t	j
|tdd
�d}}
Wd�n1s�wYt
�||||	||
�S)zReturn swap memory metrics.r�rr�rNs
SwapTotal:s	SwapFree:r�z/vmstatzM'sin' and 'sout' swap memory stats couldn't be determined and were set to 0 (�)r6r�spswpin� �spswpoutz,'sin' and 'sout' swap memory stats couldn't zbe determined and were set to 0)rrryr�r��cextZ
linux_sysinforr�r�r�r�r�rZsswap)r�r�r�r�rJrN�_Zunit_multiplierrMrLr�r��sinZsoutr;r;r<�swap_memory�sZ�������	

���r�cCstt�}t|�t|�d���}|����}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_TICKS��.0rDr;r;r<�
<listcomp>"�zcpu_times.<locals>.<listcomp>)rr�rr�ryr�r��_fields)r�r�r�r�r;r;r<�	cpu_timess�r�cCs�t�}t|�g}t|�d���7}|��|D]&}|�d�r=|��}|dttj�d�}dd�|D�}t|�}|�	|�q|Wd�S1sJwYdS)zfReturn a list of namedtuple representing the CPU times
    for every CPU available on the system.
    r�scpurcSr�r;r�r�r;r;r<r�4r�z!per_cpu_times.<locals>.<listcomp>N)
rr�rr�r�ryr�r�r�r�)r��cpusr�r�r�r��entryr;r;r<�
per_cpu_times&s

�$�r�cCs�zt�d�WStyxd}tt��d���}|D]
}|���d�r'|d7}qWd�n1s2wY|dkrmt�d�}t	t��d���}|D]}|�
d	�d}|�|�r]|d7}qKWd�n1shwY|dkrtYdS|YSw)
z0Return the number of logical CPUs in the system.�SC_NPROCESSORS_ONLNr�/cpuinfos	processorrNzcpu\dr�rj)rw�sysconf�
ValueErrorrr�lowerr��re�compilerry�match)�numr�r��searchr;r;r<�cpu_count_logical:s2���

����r�c
Cs0t�}d}d}t�|�pt�|�D]}t|��}|�|�����Wd�n1s+wYqt|�}|dkr;|Si}i}tt��d���?}|D]4}|����}|skz
|d||d<Wn	t	ygYnwi}qJ|�
d�r~|�d	d
�\}	}
t|
�||	<qJWd�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�add�readr�r�rr�r�r�ryr��sumr�)�ls�p1Zp2r\r��result�mappingZcurrent_infor��key�valuer;r;r<�cpu_count_coresWsB
����
���r�cCs�tt��d���J}d}d}d}|D]9}|�d�r!t|��d�}n|�d�r/t|��d�}n
|�d�r<t|��d�}|durJ|durJ|durJnqWd�n1sUwYd}t�||||�S)z*Return various CPU stats as a named tuple.r�Nsctxtrsintrssoftirqr)rrr�r�ryrZ	scpustats)r�Zctx_switchesZ
interruptsZsoft_interruptsr�Zsyscallsr;r;r<�	cpu_stats�s*


���r�cCsBtt��d���}dd�|D�Wd�S1swYdS)z7Return current CPU frequency from cpuinfo if available.r�cSs.g|]}|���d�rt|�dd�d��qS)scpu mhz�:r)r�r�r�ry)r�r�r;r;r<r��s��z)_cpu_get_cpuinfo_freq.<locals>.<listcomp>N)rr)r�r;r;r<�_cpu_get_cpuinfo_freq�s
�$�r�z'/sys/devices/system/cpu/cpufreq/policy0z$/sys/devices/system/cpu/cpu0/cpufreqcCs(t�}t�d�pt�d�}|jdd�d�g}tjj}t|�D]r\}}t|�t|�kr2||d}n	t||d�dd	�}|durkt||d
�dd	�}|durkd|�d�}t	|dd	�d
kre|�
t�ddd��qd}t
|��t|�d}tt||d���d}	tt||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�r�r��group)rDr;r;r<�<lambda>�szcpu_freq.<locals>.<lambda>)r�i�Zscaling_cur_freqN�r�Zcpuinfo_cur_freqz/sys/devices/system/cpu/cpuz/onlinez0
r�z!can't find current frequency fileZscaling_max_freqZscaling_min_freq)r�r��sortrwr\r��	enumerater�rrr�r�scpufreq�NotImplementedErrorr�)Z
cpuinfo_freqs�paths�ret�pjoin�ir\�currZonline_pathr�Zmax_Zmin_r;r;r<�cpu_freq�s6��r�cCsdd�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�)rr�r�r;r;r<r���zcpu_freq.<locals>.<listcomp>)r�r;r;r;r<r��sc@seZdZdS)�_Ipv6UnsupportedErrorN)r8r9r:r;r;r;r<r��sr�c@sZeZdZdZdd�Zdd�Zdd�Zedd	��Zeddd��Z	edd
d��Z
ddd�Zd
S)�NetConnectionsawA 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)�allr��tcp4r�r��udp4r�r��inetZinet4Zinet6)�socket�AF_INET�SOCK_STREAM�AF_INET6�
SOCK_DGRAM�AF_UNIX�tmap�_procfs_path)�selfrr�rr�r�r;r;r<�__init__�s$
�

zNetConnections.__init__cCs�tt�}t�|j�d|�d��D]_}zt|j�d|�d|���}Wn3ttfy,YqtyT}z|j	t	j
kr?WYd}~q|j	t	jkrOt|�WYd}~q�d}~ww|�
d�ro|dd�dd�}||�|t|�f�q|S)Nr��/fd�/fd/zsocket:[r����)r�listrw�listdirrrx�FileNotFoundError�ProcessLookupErrorr��errno�EINVAL�ENAMETOOLONGrr�r�r�)r�pid�inodesr]�inoder�r;r;r<�get_proc_inodess(��

�zNetConnections.get_proc_inodescCs@i}t�D]}z
|�|�|��WqtttfyYqw|S�N)�pids�updaterrr�PermissionError)rrrr;r;r<�get_all_inodess
�	zNetConnections.get_all_inodesc	Cs�|�d�\}}t|d�}|sdS|�d�}|tjkr5tr+t�|t�|�ddd��}nGt�|t�|��}n=t�|�}z)trPt�tj	t
jdgt
�d|��R��}nt�tj	t
jdgt
�d|��R��}Wnt
yqt�sptd��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;�asciiNrz>4Iz<4I)ryr��encoderr�
LITTLE_ENDIAN�	inet_ntop�base64�	b16decoder�struct�pack�unpackr�rr�r�addr)r,�family�ip�portr;r;r<�decode_address/s6



����zNetConnections.decode_addressNccsP�|�d�rtj�|�sdSt|���}|��t|d�D]y\}}z|��dd�\
}}	}
}}}}}}}WntyKd|�d|�d|��}
t	|
�d�w||vrY||d\}}nd	\}}|durf||krfq|t
jkrpt|}nt
j}zt�|	|�}	t�|
|�}
Wn	ty�Yqw||||	|
||fVqWd�dS1s�wYdS)
z.Parse /proc/net/tcp* and /proc/net/udp* files.�6Nrr��error while parsing �; malformed line rjr�Nr)rzrwr\�existsrr�r�ryr��RuntimeErrorrr�TCP_STATUSESr�	CONN_NONEr�r0r�)�filer-�type_r�
filter_pidr��linenor�r��laddr�raddr�statusrr�rr]r;r;r<�process_inetbsF�
����
�

��"�zNetConnections.process_inetc
cs�t|��}}|��|D]m}|��}z|dd�\}}}}}}}	Wnty:d|vr.Yqd|�d|��}
t|
��w|	|vrD||	}ndg}|D]/\}}
|durV||krVqIt|�dkr`|d	nd
}t�t|��}d
}tj	}|
||||||fVqIqWd�dS1s�wYdS)zParse /proc/net/unix files.r�rjr2r3r4Nr�r�)
rr�ryr�r6r�rZsocktype_to_enumr�r8)r9r-rr;r�r��tokensr�r:rr��pairsrr]r\r>r?r;r;r<�process_unix�s8�
��
��"�zNetConnections.process_unixcCs�t�|_|dur|�|�}|sgSn|��}t�}|j|D]R\}}}|j�d|��}|tjtjhvr>|j	|||||d�}	n	|j
||||d�}	|	D]&\}
}}}}}
}|r_t�|
|||||
�}nt�
|
|||||
|�}|�|�qIqt|�S)Nz/net/)r;)rrrr r�r
rrrr@rEr�pconnZsconnr�r)r�kindrrr�Z
proto_namer-r:r\r�r]r=r>r?Z	bound_pid�connr;r;r<�retrieve�s4
�
����
zNetConnections.retriever)r8r9r:�__doc__r
rr �staticmethodr0r@rErIr;r;r;r<r��s
2*#r�rcCs
t�|�S)z$Return system-wide open connections.)�_net_connectionsrI)rGr;r;r<�net_connections�s
rMcCs�tt��d���}|��}Wd�n1swYi}|dd�D]F}|�d�}|dks5Jt|���|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/net/devNr6r!rr)	rr�	readlines�rfind�reprr�ry�mapr�)r��lines�retdictr��colonr�r�Z
bytes_recvZpackets_recvZerrinZdropinZ_fifoinZ_frameinZ
_compressedinZ_multicastinZ
bytes_sentZpackets_sentZerroutZdropoutZ_fifooutZ_collisionsoutZ_carrieroutZ_compressedoutr;r;r<�net_io_counters�sJ
�
�
�
rUcCs�tjttjttjti}t���}i}|D]I}zt�	|�}t�
|�}t�|�\}}WntyF}z|j
t
jkr8�t|�WYd}~qd}~wwd�|�}	d|v}
t�|
|||||	�||<q|S)z)Get NIC stats (isup, duplex, speed, mtu).N�,�running)r�ZDUPLEX_FULLr	ZDUPLEX_HALFr
ZDUPLEX_UNKNOWNrrU�keysZ
net_if_mtuZnet_if_flagsZnet_if_duplex_speedr�rZENODEVrr�rZ	snicstats)Z
duplex_map�namesr�r�Zmtur`Zduplex�speedr�Zoutput_flagsZisupr;r;r<�net_if_statss.�


��

�r[FcCs�dd�}dd�}tj�t��d��r|�}ntj�d�r |�}n
t��d�}t|��i}|D]*}|\
}}}	}
}}}
}}}|sCt|�sCq.|
t9}
|t9}||	|
|||
|||f	||<q.|S)zcReturn disk I/O statistics for every disk installed on the
    system as a dict of raw tuples.
    cssJ�tt��d���}|��}Wd�n1swY|D]�}|��}t|�}|dkrK|d}t|d�}tt|dd��\
}}}	}
}}}
}}}nJ|dksS|dkrl|d}tt|dd��\}}}}	}
}}}
}}}n)|dkr�|d}tt|dd��\}}}
}d	}	}
}}}n	d
|��}t|��|||
|||	|
|||f
VqdS)N�
/diskstats�r7r6r���rArznot sure how to interpret line )rrrNryr�r�rQr�)r�rRr�r�Zflenr��reads�reads_merged�rbytes�rtime�writes�
writes_merged�wbytes�wtimer�rZr�r;r;r<�read_procfs0s8�
���
��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�)rwr�walkr\r�rr�r�ry�basenamerQr�)�block�rootr��filesr�r�r�r`rarbrcrdrerfrgrZr;r;r<�
read_sysfs^s"������z$disk_io_counters.<locals>.read_sysfsr\riz6/diskstats nor /sys/block are available on this system)rwr\r5rr�r��DISK_SECTOR_SIZE)Zperdiskrhrp�genr�rSr�r�r`rdrbrfrcrgrarerZr;r;r<�disk_io_counters+s,.
��
�rsc@s@eZdZdZddgZdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�RootFsDeviceFinderaFdisk_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�)rwrj�st_devrurv)r�devr;r;r<r
��zRootFsDeviceFinder.__init__cCs�tt��d���Y}|��dd�D]G}|��}t|�dkrq|d��r*t|d�nd}|d��r8t|d�nd}|d}||jkrX||jkrX|rXd|��Wd�SqWd�dS1sdwYdS)Nz/partitionsr6r�rrr7�/dev/)	rrrNryr��isdigitr�rurv)rr�r�r�rurvr�r;r;r<�ask_proc_partitions�s��"�z&RootFsDeviceFinder.ask_proc_partitionscCs�d|j�d|j�d�}t|��,}|D] }|�d�r2|���d�d}|r2d|��Wd�SqWd�dS1s>wYdS)Nz/sys/dev/block/r!z/ueventzDEVNAME=r6r{)rurvrr�r��
rpartition)rr\r�r�r�r;r;r<�ask_sys_dev_block�s

��"�z$RootFsDeviceFinder.ask_sys_dev_blockc	Cs�|j�d|j��}t�d�}|D]F}zt|�}Wn	ty!Yqw|�*|����}||krGtj	�
tj	�|��}d|��Wd�SWd�n1sQwYqdS)Nr!z/sys/class/block/*/devr{)rurvr��iglobrrr�r�rwr\rl�dirname)r�needleror9r��datar�r;r;r<�ask_sys_class_block�s$
�����z&RootFsDeviceFinder.ask_sys_class_blockc
Cs�d}|dur#z|��}Wnty"}z
t|�WYd}~nd}~ww|durDz|��}WntyC}z
t|�WYd}~nd}~ww|durez|��}Wntyd}z
t|�WYd}~nd}~ww|durqtj�|�rs|SdSdSr)r}r�rrr�rwr\r5)rr\r�r;r;r<�find�s2�������zRootFsDeviceFinder.findN)
r8r9r:rJ�	__slots__r
r}rr�r�r;r;r;r<rt�s
	rtcCs4t�}t�}|sEt|�d���.}|D]#}|��}|�d�s%|�|���q|�d�d}|dkr5|�d�qWd�n1s@wY|dkrVtj�	d�rVtj�
d�}n	tj�
|�d	��}g}t�|�}|D]/}	|	\}
}}}|
d
krvd}
|
dvr�t
���p�|
}
|s�|
r�||vr�qht�|
|||�}
|�|
�qh|S)
z8Return mounted disk partitions as a list of namedtuples.z/filesystemsZnodev�	rZzfsNr�z	/etc/mtabz/self/mounts�nonerB>Zrootfsz	/dev/root)r�rrr�r�r�ryrwr\�isfile�realpathr��disk_partitionsrtr�rZ	sdiskpartr�)rZfstypesr�r�r�ZfstypeZmounts_path�retlistZ
partitions�	partitionZdeviceZ
mountpoint�opts�ntupler;r;r<r��s>

���
r�cCs8t�t�}t�d�}|�t�d��tdd�|D��}t�d�}t�d�}|D]}|�d|�}||vr8|�	|�q'|D]�}z|d}t
t|��d	}tj
�tj
�|�d
�}t|���}	WnttfygYq;wt|ddd
�}
t|ddd
�}t|ddd
���}|
dur�zt
|
�d	}
Wnty�d}
Ynw|dur�zt
|�d	}Wnty�d}Ynw||	�	|||
|f�q;|�s�t�d�}tt|��}|D]�}ztj
�|d�}t
t|��d	}tj
�|d�}t|���}	Wnttf�y}
z
t|
�WYd}
~
q�d}
~
wwt�|d�}dd�|D�}d}d}
|D]o}tj
�||d�}t|dd
���}|dk�rBttj
�||d�dd
�}n|dk�rTttj
�||d�dd
�}
|
du�rnzt
|
�d	}
Wnt�ymd}
Ynw|du�r�z	t
|�d	}W�qt�y�d}Y�qw�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�h|]	}|�d�d�qS�r�r�ryr�r;r;r<�	<setcomp>r�z'sensors_temperatures.<locals>.<setcomp>z5/sys/devices/platform/coretemp.*/hwmon/hwmon*/temp*_*z'/sys/devices/platform/coretemp.*/hwmon/z/sys/class/hwmon/�_inputg@�@r��_maxNr�Z_crit�_labelrBz /sys/class/thermal/thermal_zone*�temp�typez/trip_point*cSs,h|]}d�tj�|��d�dd���qS)r�rr7)r�rwr\rlry)r��pr;r;r<r�_s���_type�critical�_temp�high)�collectionsrrr��extend�sortedr�r��subr�r�rrwr\r�r�rr�r�r�r�r�dict)r��	basenamesZ
basenames2�replr�Zaltname�baser\�current�	unit_namer�r��labelr�Z
trip_pathsZtrip_pointsZ
trip_pointZ	trip_typer;r;r<�sensors_temperaturess�

�

�	���
���
�
�
�

��r�cCs�t�t�}t�d�}|st�d�}tdd�|D��}|D]G}z
tt|d��}Wnty>}z
t|�WYd}~qd}~wwt	t
j�t
j�
|�d����}t	|dd	d
���}||�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�r�r�r;r;r<r��r�zsensors_fans.<locals>.<setcomp>r�Nr�r�rBr�)r�rrr�r�r�rr�rrrwr\r�r�r�r�rZsfanr�)r�r�r�r�r�r�r�r;r;r<�sensors_fans�s"



��r�cs�t���fdd�}dd�t�t�D�}|sdStj�tt|��}||d|d�}||d|d	�}||d
|d�}||d�}|dur]|dur]zd
||}Wnty\d}Ynwtt	|ddd��}|dkrmdSd}|tj�td�tj�td��}	|	dur�|	dk}nt	|ddd��
���}
|
dkr�d}n|
dvr�d}|r�tj
}n6|dur�|dur�zt|t|�d�}Wn!ty�tj}Ynw|dur�t|d�}|dkr�tj}ntj}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	sP|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)rr�r�r�)r�r\r���nullr;r<�
multi_bcat�s��z#sensors_battery.<locals>.multi_bcatcSs&g|]}|�d�sd|��vr|�qS)ZBAT�battery)r�r�r�r;r;r<r��s��z#sensors_battery.<locals>.<listcomp>Nz/energy_nowz/charge_nowz
/power_nowz/current_nowz/energy_fullz/charge_fullz/time_to_empty_nowgY@r�z	/capacityrr�z
AC0/onlinez	AC/onliner�/statusrBZdischargingF>�fullZchargingTi�<r)�objectrwr�POWER_SUPPLY_PATHr\r�r��ZeroDivisionErrorr�rr�r�rZPOWER_TIME_UNLIMITED�absZPOWER_TIME_UNKNOWNZsbattery)r�ZbatsrnZ
energy_nowZ	power_nowZenergy_fullZ
time_to_emptyrLZ
power_pluggedZonliner?Zsecsleftr;r�r<�sensors_battery�s`
���

��r�c	CsHg}t��}|D]}|\}}}}}t�||pd|||�}|�|�q|S)z:Return currently connected users as a list of namedtuples.N)r��usersrZsuserr�)	r�Zrawlist�itemrm�tty�hostnameZtstampr�ntr;r;r<r��sr�cCsvt��d�}t|��'}|D]}|�d�r't|����d�Wd�Sq
d|��}t|��1s4wYdS)zAReturn the system boot time expressed in seconds since the epoch.r�sbtimerNzline 'btime' not found in )rrr�r�r�ryr6)r\r�r�r�r;r;r<�	boot_time
s

�
�r�cCs t��t�}dd�t�|�D�S)z7Returns a list of PIDs currently running on the system.cSsg|]
}|��rt|��qSr;)r|r�r�r;r;r<r�szpids.<locals>.<listcomp>)rr$rrwrr{r;r;r<rsrc	Cs�t�|�sdSzBt��d|�d�}t|��*}|D]}|�d�r5t|��d�}||kWd�WSqd|��}t|��1sBwYWdSttfyY|t	�vYSw)zcCheck for the existence of a unix PID. Linux TIDs are not
    supported (always return False).
    Fr�r�sTgid:rNz'Tgid' line not found in )
r�
pid_existsrrr�r�ryr�r�r)rr\r�r�Ztgidr�r;r;r<r� s"




�
�	�r�c	Cs�i}t�}t�D]W}z t|�d|�d���}|��}Wd�n1s$wYWnttfy5YqtyE}zt|�|�d}~ww|�d�}||dd��	�}t
|d�}|||<q|S)zsObtain a {pid: ppid, ...} dict for all running processes in
    one shot. Used to speed up Process.children().
    r�r�N�)r6r)rrrr�rrrrrOryr�)	r�r�rr�r�r��rparZdset�ppidr;r;r<�ppid_mapAs&

��
��

r�cst����fdd��}|S)zlDecorator which translates bare OSError and OSError exceptions
    into NoSuchProcess and AccessDenied.
    c
s�|j|j}}z�|g|�Ri|��WSty%}zt||�|�d}~wty:}z
|��t||�|�d}~wty]}z|��tj	�
|j�d|�d��sXt||�|��d}~ww)Nr�r�)r�_namerrr�_raise_if_zombier
rrwr\r5r)rr��kwargsrr�r���funr;r<�wrapper\s"����z wrap_exceptions.<locals>.wrapper)�	functools�wraps)r�r�r;r�r<�wrap_exceptionsWsr�c@s�eZdZdZgd�Zdd�Zdd�Zdd�Zd	d
�Ze	fdd�Z
eed
d���Z
eedd���Zeedd���Zdd�Zdd�Zedd��Zedd��Zedd��Zedd��Zedd ��Zej�d!e���d"��rped#d$��Zed%d&��Zed'd(��Zedid*d+��Zedjd-d.��Zed/d0��Z e!s�e"r�d1d2�Z#ee$�%d3�e$�%d4�e$�%d5�fd6d7��Z&ed8d9��Z'ne Z'e"r�ed:d;��Z(ed<d=��Z)ee$�%d>�fd?d@��Z*ee$�%dA�fdBdC��Z+edDdE��Z,edFdG��Z-edHdI��Z.e/�redJdK��Z0e$�%dL�fdMdN�Z1edOdP��Z2e3�redQdR��Z4edSdT��Z5e6e7dU��redidVdW��Z8edXdY��Z9edZd[��Z:edkd]d^��Z;ed_d`��Z<edadb��Z=ee$�%dc�fddde��Z>ee$�%df�fdgdh��Z?d)S)l�ProcesszLinux process implementation.)�_cache�_ctimer��_ppidrrcCs$||_d|_d|_d|_t�|_dSr)rr�r�r�rr)rrr;r;r<r
~s
zProcess.__init__cCsXzt|j�d|j�d��}Wn
tyYdSw|�d�}||d|d�}|dkS)Nr�r�Fr�r6r7�Z)rrrr�rO)rr�r�r?r;r;r<�
_is_zombie�s�
zProcess._is_zombiecCs|��r
t|j|j|j��dSr)r�rrr�r��rr;r;r<r��s�zProcess._raise_if_zombiecCst�|j�d|j���dS)z+Raise NSP if the process disappeared on us.r�N)rwrjrrr�r;r;r<�_raise_if_not_alive�szProcess._raise_if_not_alivec	CsRzt|�WSttfy(tj�|j�d|j���r'|��|t	ur'|YS�wrw)
rxrrrwr\�lexistsrrr��UNSET)rr\r�r;r;r<�	_readlink�s
�zProcess._readlinkcCs�t|j�d|j�d��}|�d�}||�d�d|�}||dd���}i}||d<|d	|d
<|d|d<|d|d
<|d|d<|d|d<|d|d<|d|d<|d|d<|d|d<z	|d|d<W|Sty}td�d	|d<Y|Sw)aYParse /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 subtract 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.
        r�r�r��(rr6Nr�rr?r�r��ttynr��utime��stime�
�children_utimer^�children_stime��create_time�$�cpu_num�'�blkio_ticksz&can't get blkio_ticks, set iowait to 0)rrrrOr�ry�
IndexErrorr)rr�r�r�r�r�r;r;r<�_parse_stat_file�s.
�
�zProcess._parse_stat_filecCsDt|j�d|j�d���}|��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.
        r�r�N)rrrr��rr�r;r;r<�_read_status_file�s$�zProcess._read_status_filecCsHt|j�d|j�d���}|����Wd�S1swYdS)Nr�r-)rrrr�r�r�r;r;r<�_read_smaps_file�s
$�zProcess._read_smaps_filecC�(|j�|�|j�|�|j�|�dSr)r�Zcache_activater�r�r�r;r;r<�
oneshot_enter�rzzProcess.oneshot_entercCr�r)r�Zcache_deactivater�r�r�r;r;r<�oneshot_exit�rzzProcess.oneshot_exitcC�t|��d�S)Nr�)rr�r�r;r;r<r���zProcess.namecC�|j|j�d|j�d�dd�S)Nr�z/exerBr��r�rrr�r;r;r<�exe���zProcess.execCs�t|j�d|j�d���}|��}Wd�n1swY|s(|��gS|�d�r/dnd}|�|�r<|dd�}|�|�}|dkrTt|�dkrTd|vrT|�d�}|S)Nr�z/cmdlinerrrjrr)rrrr�r�rzryr�)rr�r��sep�cmdliner;r;r<r��s
�


zProcess.cmdlinecCsNt|j�d|j�d���}|��}Wd�t|�S1swYt|�S)Nr�z/environ)rrrr�r)rr�r�r;r;r<�environs

��zProcess.environcCs8t|��d�}t��}z||WStyYdSw)Nr�)r�r�rZget_terminal_mapr�)rZtty_nrr
r;r;r<�terminals
�zProcess.terminalr,�/ioc	
Cs|j�d|j�d�}i}t|��,}|D]!}|��}|r4z	|�d�\}}Wn	ty-Yqwt|�||<qWd�n1s?wY|sO|�d�}t|��zt|d|d|d|d|d	|d
�WSt	y�}z|j
d�d|�d
|��}t|�d�d}~ww)Nr�r�s: z file was emptyssyscrssyscws
read_bytesswrite_bytessrcharswcharrz field was not found in z; found fields are )rrrr�ryr�r�r6rkr�r�)	r�fnamer�r�r�r�r�r�r�r;r;r<�io_counters'sF
����
���
��zProcess.io_counterscCsh|��}t|d�t}t|d�t}t|d�t}t|d�t}t|d�t}t|||||�S)Nr�r�r�r�r�)r�r�r�rl)rr�r�r�r�r�rqr;r;r<r�JszProcess.cpu_timescCr�)zWhat CPU the process is on.r��r�r�r�r;r;r<r�Tr�zProcess.cpu_numNcCst�|j||j�Sr)rZwait_pidrr�)r�timeoutr;r;r<�waitYszProcess.waitFcCs6|jdurt|��d�t|_|r|jS|jt�S)Nr�)r�r�r�r�r�)r�	monotonicr;r;r<r�]s
�zProcess.create_timec	Csxt|j�d|j�d���}dd�|����dd�D�\}}}}}}}Wd�n1s-wYt|||||||�S)Nr�z/statmcss�|]	}t|�tVqdSr)r�r�r�r;r;r<�	<genexpr>|s�
�z&Process.memory_info.<locals>.<genexpr>rA)rrrr�ryra)	rr�ZvmsrgrS�text�libr�Zdirtyr;r;r<�memory_infons
��zProcess.memory_infocCs�d}}}t|j�d|j�d���>}|D]3}|�d�r)|t|��d�d7}q|�d�r9t|��d�d}q|�d�rHt|��d�d}qWd�n1sSwY|||fS)	Nrr�r.sPrivate_rr��Pss:�Swap:)rrrr�r�ry)rrcrdrer�r�r;r;r<�_parse_smaps_rollup�s 	�


���
zProcess._parse_smaps_rollups\nPrivate.*:\s+(\d+)s\nPss\:\s+(\d+)s\nSwap\:\s+(\d+)cCsZ|��}ttt|�|���d}ttt|�|���d}ttt|�|���d}|||fS)Nr�)r�r�rQr��findall)rZ_private_reZ_pss_reZ_swap_reZ
smaps_datarcrdrer;r;r<�_parse_smaps�s

zProcess._parse_smapsc	Csdtrz	|��\}}}Wnttfy|��\}}}Ynw|��\}}}|��}t||||f�Sr)�HAS_PROC_SMAPS_ROLLUPrrrrrrb)rrcrdreZ	basic_memr;r;r<�memory_full_info�s�zProcess.memory_full_infocCsXdd�}|��}|s|��gS|�d�}g}|�d�}|g}|||�D]�\}}|�dd�}z
|\}	}
}}}
}WntyL|dg\}	}
}}}
}Ynw|sRd}nt|�}|��}|�d	�rit|�si|dd
�}t|	�t|
�||�	dd�|�	dd�|�	d
d�|�	dd�|�	dd�|�	dd�|�	dd�|�	dd�|�	dd�|�	dd�f
}|�
|�q$|S)a�Return process's mapped memory regions as a list of named
            tuples. Fields are explained in 'man proc'; here is an updated
            (Apr 2012) version: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/proc.txt?id=b76437579d1344b612cf1851ae610c636cec7db0.

            /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]F}|�dd�}|d�d�s!|��|fV|�|�qzt|d�d||d<WqttfyK|d�d�rAYqd|��}t|�d�w|��|fVdS)N�rr�rr�sVmFlags:z!don't know how to interpret line )ryrz�popr�r�r�r�r�)rR�
current_blockr�r�r�r�r;r;r<�
get_blocks�s �

�z'Process.memory_maps.<locals>.get_blocks�
rNr	rBz[anon]rsrtsRss:sSize:rs
Shared_Clean:s
Shared_Dirty:sPrivate_Clean:sPrivate_Dirty:sReferenced:s
Anonymous:r)r�r�ryr
r�rr�rzrr�r�)rrr�rRr��
first_liner�headerZhfieldsr,Zperms�_offset�_devZ_inoder\r�r;r;r<�memory_maps�sP


��









�zProcess.memory_mapscCr�)Nr�z/cwdrBr�r�r�r;r;r<�cwdr�zProcess.cwdsctxt_switches:\t(\d+)cCsP|��}|�|�}|sd|j�d|j�d�}t|��t�t|d�t|d��S)NzR'voluntary_ctxt_switches' and 'nonvoluntary_ctxt_switches'lines were not found in r�z1/status; the kernel is probably older than 2.6.23rr)r�rrrr�rZpctxswr�)rZ	_ctxsw_rer�Zctxswr�r;r;r<�num_ctx_switchess
���zProcess.num_ctx_switchessThreads:\t(\d+)cCs|��}t|�|�d�S�Nr)r�r�r)rZ_num_threads_rer�r;r;r<�num_threads&szProcess.num_threadsc
Cst�|j�d|j�d��}|��g}d}|D]g}|j�d|j�d|�d�}zt|��}|����}Wd�n1s<wYWn
tt	fyOd}Yqw||�
d�dd�}|�d	�}t|d
�t
}	t|d�t
}
t�t|�|	|
�}|�|�q|r�|��|S)Nr�z/taskFz/task/r�Tr�r6r�r�r�)rwrrrr�rr�r�rrr�ryr�r�rZpthreadr�r�r�)rZ
thread_idsr��
hit_enoentZ	thread_idr�r��str�r�r�r�r;r;r<�threads,s0
���
zProcess.threadscC�t�|j�Sr)r�Zproc_priority_getrr�r;r;r<�nice_getGszProcess.nice_getcCst�|j|�Sr)r�Zproc_priority_setr)rr�r;r;r<�nice_setPszProcess.nice_setcCrr)r�r0rr�r;r;r<�cpu_affinity_getWszProcess.cpu_affinity_getsCpus_allowed_list:\t(\d+)-(\d+)cCsR|��}|�|�}|r ttt|dd�t|dd�d��Stttt����S)Nrr)r�rr�ranger�r�r�)r�_rer�r�r;r;r<�_get_eligible_cpus[s

*zProcess._get_eligible_cpusc
Cs�z
t�|j|�WdSttfyX}z@t|t�s|jtjkrS|��}t	t
tt����}|D]$}||vrAd|�d|��}t|�d�||vrRd|�d|��}t|�|�q.�d}~ww)Nzinvalid CPU z; choose between zCPU number z! is not eligible; choose between )
r�Zproc_cpu_affinity_setrr�r�rurrr �tuplerr�r�)rr�r�Z
eligible_cpusZall_cpus�cpur�r;r;r<�cpu_affinity_setfs.��
��
���zProcess.cpu_affinity_setcCs$t�|j�\}}t|�}t�||�Sr)r�r/rr5rZpionice)r�ioclassr�r;r;r<�
ionice_get�szProcess.ionice_getcCs^|durd}|r|tjtjhvr|�d�}t|��|dks!|dkr'd}t|��t�|j||�S)Nrz ioclass accepts no valuerAzvalue not in 0-7 range)r5r rr�r�Zproc_ioprio_setr)rr$r�r�r;r;r<�
ionice_set�s�
zProcess.ionice_set�prlimitc
Cs�|jdkrd}t|��z&|durt�|j|�WSt|�dkr'd|��}t|��t�|j||�WdStyH}z|jtjkrC|���d}~ww)Nrz)can't use prlimit() against PID 0 processr6z2second argument must be a (soft, hard) tuple, got )	rr��resourcer'r�r�rZENOSYSr�)rZ	resource_Zlimitsr�r�r;r;r<�rlimit�s&
����zProcess.rlimitcCs |��d}|��}t�|d�S)Nr?�?)r�r�
PROC_STATUSESr�)r�letterr;r;r<r?�szProcess.statusc
Cs�g}t�|j�d|j�d��}d}|D]�}|j�d|j�d|��}zt|�}Wn5ttfy4d}Yqty\}z|jtj	krGWYd}~q|jtj
krWt|�WYd}~q�d}~ww|�d�r�t
|�r�|j�d|j�d|��}z+t|��}t|����d�}	t|����dd�}
Wd�n1s�wYWn
ttfy�d}Yqwt|
�}t|t|�t|	�||
�}|�|�q|r�|��|S)	Nr�rFrTz/fdinfo/rr�)rwrrrrxrrr�rrrrr�rrr�r�ryr�r[r�r�)
rr�rorr]r9r\r�r��posr`r_r�r;r;r<�
open_files�sN��
����
�zProcess.open_filesrcCst�||j�}|��|Sr)rLrIrr�)rrGr�r;r;r<rM�szProcess.net_connectionscCstt�|j�d|j�d���S)Nr�r)r�rwrrrr�r;r;r<�num_fds�szProcess.num_fdscCr�)Nr�r�r�r;r;r<r��szProcess.ppidsUid:\t(\d+)\t(\d+)\t(\d+)cC�6|��}|�|�d\}}}t�t|�t|�t|��Sr)r�rrZpuidsr�)rZ_uids_rer��real�	effective�savedr;r;r<�uids��zProcess.uidssGid:\t(\d+)\t(\d+)\t(\d+)cCr0r)r�rrZpgidsr�)rZ_gids_rer�r1r2r3r;r;r<�gids�r5zProcess.gidsr�F�r)@r8r9r:rJr�r
r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�rwr\r5�getpidr�r�r�r�r�rr�HAS_PROC_SMAPSrr�r�rrrrrrrrr�HAS_CPU_AFFINITYrr r#�HAS_PROC_IO_PRIORITYr%r&�hasattrr(r)r?r.rMr/r�r4r6r;r;r;r<r�rs�	%




	
"
	

�
G
�




�




/

r�r8r7)�rJr'r��enumrr�r�rwr�r(rr)�sysr�rrrBrrrr�rr	r
rrr
rrrrrrrrrrrrrrrZ__extra__all__r�r\r5r9r:rr=r<r;r�r�Zgetpagesizer��	byteorderr%r�r�rq�IntEnumr��	AF_PACKETr3r4r5�globalsr�__members__ZSTATUS_RUNNINGZSTATUS_SLEEPINGZSTATUS_DISK_SLEEPZSTATUS_STOPPEDZSTATUS_TRACING_STOPZ
STATUS_ZOMBIEZSTATUS_DEADZSTATUS_WAKE_KILLZ
STATUS_WAKINGZSTATUS_IDLEZ
STATUS_PARKEDr+r!r"r#r$r%r&r'r(r)r*r+r7rIrUr[rar�rbrfr�rirkrlrxr�r�r��	Exceptionr�r�r�r�r�r�r�r�r�r�r�r�Znet_if_addrsr�r�rLrMrUr[�
disk_usagersrtr�r�r�r�r�r�rr�r�r�r�r;r;r;r<�<module>s2




������
���

��?<*
�
'o
/!
i
K,v_!