Your IP : 18.117.104.132


Current Path : /opt/imunify360/venv/lib64/python3.11/site-packages/psutil/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/psutil/__pycache__/_pslinux.cpython-311.pyc

�

]�Dg�@�
�	�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#krddl2Z2ndZ2gd$�Z3d%Z4ej5�6d&ej7��z��Z8e9ed'��Z:e9ed(��Z;e<��Z=ej>d)��Z?ej@��ZAdaBe0rd*nd+ZCejDd,kZEd-ZFe2�e
jGZHn(e2jId.d/eJe
jG��i��ZKeKjHZHe2�	dZLdZMd0ZNd1ZOn5Gd2�d3e2jI��ZPeQ���RePjS��ejTejUejVejWejXejYejZejZej[ej\ej]ej^d4�Z_ej`ejaejbejcejdejeejfejgejhejiejjd5�Zked6gd7���Zled8gd9���Zmed:gd;���Zned<d=��Zoed>eojpd?z��Zqed@gdA���ZredBdCdD�serjp��z��ZtedEgdF���ZuedGgdH���ZvdI�ZwdJ�ZxdK�ZyedL���Zze=dMfdN�Z{	ezdO��n1#e|$r)e
j}��edPdQ��dRdRdR��a~YnwxYwdZ	ddSl�mZn1#e�$r)ddl�Z�e�j�ddM�T��Z�e9e�dU��rd|dV�ZYnwxYwe�(e3��dW�e�e��D����dX�Z�dY�Z�dZ�Z�d[�Z�d\�Z�d]�Z�d^�Z�d_�Z�ej5�6d`��sej5�6da��rdb�Z�n!ej5�6dc��rdd�Z�nde�Z�ej�Z�Gdf�dge|��Z�Gdh�di��Z�e���Z�d}dk�Z�dl�Z�dm�Z�ej�Z�d~do�Z�d~dp�Z�dq�Z�dr�Z�ds�Z�dt�Z�du�Z�dv�Z�dw�Z�dx�Z�dy�Z�Gdz�d{e<��Z�dS)zLinux platform implementation.�)�divisionN)�defaultdict)�
namedtuple�)�_common)�_psposix)�
_psutil_linux)�
_psutil_posix)�AccessDenied)�debug)�decode)�get_procfs_path)�
isfile_strict)�memoize)�memoize_when_activated)�NIC_DUPLEX_FULL)�NIC_DUPLEX_HALF)�NIC_DUPLEX_UNKNOWN)�
NoSuchProcess)�open_binary)�	open_text)�parse_environ_block)�path_exists_strict)�
supports_ipv6)�
usage_percent)�
ZombieProcess)�b)�
basestring)�FileNotFoundError)�PermissionError)�ProcessLookupError)�PY3)��)�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��eZdZdZdZdZdZdS)�
IOPriorityrrr<r#N)�__name__�
__module__�__qualname__r&r'r(r)���F/opt/imunify360/venv/lib64/python3.11/site-packages/psutil/_pslinux.pyr>r>ws&���������������rCr>)�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)rs�rss�sizer{�shared_clean�shared_dirty�
private_clean�
private_dirty�
referenced�	anonymousr|�	pmmap_extzaddr perms � �pio)rirjrkrl�
read_chars�write_chars�	pcputimes)�user�system�
children_user�children_system�iowaitc��t|t��s
J|���tj|��}|�d��d}|�d��rt
|��s
|dd�}|S)zWrapper around os.readlink().�r�
 (deleted)N���)�
isinstancer�os�readlink�split�endswithr)rss rDr�r��s���d�J�'�'�-�-��-�-�'�
�;�t���D��:�:�f���a� �D��}�}�\�"�"��+=�d�+C�+C���D�S�D�z���KrCc�(�tjdtjdtjdi}||tjtjztjzz}|tjzr|�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)rw�	modes_maprvs   rD�file_flags_to_moder��sw����c�2�;��R�Y��E�I��U�b�k�B�K�7�"�)�C�D�E�D��r�{��)��|�|�C��a�(�(���<�<��d�#�#�D��KrCc��|�dd��}d}|rd|z}nd|z}tj|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_virtualrss   rD�is_storage_devicer��sO���<�<��S�!�!�D����-���%���%��,��
�9�T�2�7�#�#�#rCc��td|z��5}|������dd�}ddd��n#1swxYwYgd�}t|��}|dkr|�d��|dkr|�d��|d	kr|�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�vlens     rD�set_scputimes_ntupler�s��
�Y��,�	-�	-�*�������#�#�%�%�a�b�b�)��*�*�*�*�*�*�*�*�*�*�*����*�*�*�*�
K�
K�
K�F��v�;�;�D��q�y�y��
�
�g�����q�y�y��
�
�g�����r�z�z��
�
�l�#�#�#��;��/�/�I�I�Is�/A�A�ATc�
�	|rt|��nt|��5}|������cddd��S#1swxYwYdS#tt
f$r|tur|cYS�wxYw)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�s    rD�catr�s����#)�
?�[��
�
�
�y��/?�/?�	$�1��6�6�8�8�>�>�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	$�	$���W������8�#�#��O�O�O��	���s4� A"�&A�A"�A�A"�A�A"�"B�B�/procr�zuser system idle�)�prlimit)�	use_errnor�c��Gd�dtj��}|��}|�0t�||dtj|����}ne|��}|d|_|d|_t�||tj|��tj|����}|dkr5tj��}t|tj
|�����|j|jfS)Nc�2�eZdZdejfdejfgZdS)�prlimit.<locals>.StructRlimit�rlim_cur�rlim_maxN)r?r@rA�ctypes�
c_longlong�_fields_rBrCrD�StructRlimitr�Js+������'��):�;�'��):�;�=���rCr�rr)r��	Structure�libcr��byrefr�r��	get_errnor�r��strerror)�pid�	resource_�limitsr��current�ret�new�errnos        rDr�r�Is���
=�
=�
=�
=�
=�v�/�
=�
=�
=�#�l�n�n�G��~��l�l�3�	�4���g�9N�9N�O�O���#�l�n�n��%�a�y���%�a�y����l�l���F�L��$5�$5�v�|�G�7L�7L�N�N���a�x�x��(�*�*���e�R�[��%7�%7�8�8�8��$�g�&6�7�7rCc�d�g|]-}|�d���|����+|��.S)�RLIM)�
startswith�isupper��.0rLs  rD�
<listcomp>r�bs6��F�F�F�q����f�!5�!5�F�!�)�)�+�+�F��F�F�FrCc��|d}||�dd��z}	|d}|d}|d}n#t$r|cYSwxYw	tdt��z��}n#t$r|cYSwxYwd}|5|D]U}|���}|�d��r*|t|���d	��z
}�V	d
d
d
��n#1swxYwY|tz}||z
}	||z}
|
t|
dz|��z}
|	|
z
}	|	|t|dz|��z
z
}	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)�memsrar��lru_active_file�lru_inactive_file�slab_reclaimabler��
watermark_low�line�avail�	pagecaches           rD�calculate_avail_vmemr�js���.���D��d�h�h�z�1�-�-�-�H���/�0�� �!3�4��� 0�1������������������
��(9�(9�9�:�:�����������������M�	
�6�6��	6�	6�D��:�:�<�<�D����v�&�&�
6���T�Z�Z�\�\�!�_�!5�!5�5�
��	6�6�6�6�6�6�6�6�6�6�6�6����6�6�6�6�
�X��M��=� �E��"3�3�I�
��Y��]�M�2�2�2�I�	�Y��E�	�
��$4�s�$:�M� J� J�
J�J�E��u�:�:�s4�<�A�
A�A.�.A=�<A=�AC*�*C.�1C.c
��g}i}tdt��z��5}|D]7}|���}t|d��dz||d<�8	ddd��n#1swxYwY|d}|d}	|d}n'#t$rd}|�d	��YnwxYw	|d
}||�dd��z
}n'#t$rd}|�d��YnwxYw	|d
}	nA#t$r4	|d}	n'#t$rd}	|�d��YnwxYwYnwxYw	|d}
n'#t$rd}
|�d��YnwxYw	|d}nS#t$rF	|d|dz|dz}n'#t$rd}|�d��YnwxYwYnwxYw	|d}n#t$rd}YnwxYw||z
|z
|z
}
|
dkr||z
}
	|d}n#t$rt|��}YnwxYw|dkrd}|�d��||kr|}t||z
|d���}|rJd�	|���dt|��dkrdnd�d�}tj|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:rdr�r�resShmem:s
MemShared:rfsActive:rbs	Inactive:sInact_dirty:sInact_clean:sInact_laundry:rcsSlab:s
MemAvailable:r^��round_�, z) memory stats couldn't be determined and �was�werez	 set to 0)rrr�r�r�r�r�r�r�joinr��warnings�warn�RuntimeWarningr\)�missing_fieldsr�r�r�r�r]rardrerfrbrcrgr`r�r_�msgs                 rD�virtual_memoryr
�sI�� �N�
�D�	�\�O�$5�$5�5�	6�	6�4�!��	4�	4�D��Z�Z�\�\�F�!�&��)�n�n�t�3�D����O�O�	4�4�4�4�4�4�4�4�4�4�4�4����4�4�4�4�
���E����D�)��{�#�����)�)�)������i�(�(�(�(�(�)����0��j�!��	�$�(�(�+�Q�/�/�/�����(�(�(������h�'�'�'�'�'�(����,��i������,�,�,�	,��-�(�F�F���	,�	,�	,��F��!�!�(�+�+�+�+�+�	,������,����(��j�!�����(�(�(������h�'�'�'�'�'�(����
.���%�����.�.�.�	.��_�%��_�%�&��&�'�(�
�H���	.�	.�	.��H��!�!�*�-�-�-�-�-�	.������
.������H�~�����������������4�<�&� �7�*�D��a�x�x��t�|��+��%�&�����+�+�+�$�T�*�*����+����
�q�y�y������k�*�*�*�
�u�}�}����U�U�]�U�1�=�=�=�G��+��I�I�n�%�%�%�%���(�(�A�-�-�E�E�6�9�9�;��	�
�c�>�*�*�*����w��d���7�F�F�D�B�B�Bs��;A+�+A/�2A/�B�!B4�3B4�8C�!C>�=C>�D�
E	�D�E	�!E�E	�E�E	�E	�
E�!E:�9E:�>F�
G�F-�,G�-!G�G�G�G�G�G$�$G3�2G3�
H�H2�1H2c�D�i}tdt��z��5}|D]7}|���}t|d��dz||d<�8	ddd��n#1swxYwY	|d}|d}n5#t$r(tj��\}}}}}}}||z}||z}YnwxYw||z
}t||d���}		td	t��z��}|5dx}
}|D]�}|�d
��r/t|�d��d��dzdz}
nC|�d
��r.t|�d��d��dzdz}|
�|�n!��d}tj
|t��dx}
}ddd��n#1swxYwYnG#t$r:}
dt|
��z}tj
|t��dx}
}Yd}
~
nd}
~
wwxYwtj||||	|
|��S)zReturn swap memory metrics.rrrrNs
SwapTotal:s	SwapFree:rz	%s/vmstatspswpin� r$spswpoutzK'sin' and 'sout' swap memory stats couldn't be determined and were set to 0zP'sin' and 'sout' swap memory stats couldn't be determined and were set to 0 (%s))rrr�r�r��cext�
linux_sysinforr�rr	r
r��strr�sswap)r�r�r�r�r]ra�_�unit_multiplierr`r_�sin�soutr�errs              rD�swap_memoryrs���
�D�	�\�O�$5�$5�5�	6�	6�4�!��	4�	4�D��Z�Z�\�\�F�!�&��)�n�n�t�3�D����O�O�	4�4�4�4�4�4�4�4�4�4�4�4����4�4�4�4� ��]�#���L�!����� � � �37�3E�3G�3G�0��1�a��E�4��
�� �������� ����
�4�<�D��D�%��2�2�2�G����o�&7�&7�7�8�8���	�	���C�$��
�
���?�?�9�-�-�?��d�j�j��.�.�q�1�2�2�Q�6��=�C�C��_�_�Z�0�0�?��t�z�z�$�/�/��2�3�3�a�7�$�>�D��?�t�'7��E��
8���
�c�>�2�2�2����d�%	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�������5�7:�3�x�x�@���
�c�>�*�*�*����d�d�d�d�d�d���������4�=���d�G�S�$�?�?�?sN�;A)�)A-�0A-�5B�/B8�7B8�G�3B7F6�6F:�=F:�
H�0H�Hc�N�t��}t|��td|z��5}|������}ddd��n#1swxYwY|dttj��dz�}d�|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�Nrc�<�g|]}t|��tz��SrB��float�CLOCK_TICKSr�s  rDr�zcpu_times.<locals>.<listcomp>^s#��
5�
5�
5��e�A�h�h��$�
5�
5�
5rC)rr�rr�r�r�r��_fields)r�r�r�r�s    rD�	cpu_timesr Rs���"�#�#�K���%�%�%�	�Y��,�	-�	-�&�������#�#�%�%��&�&�&�&�&�&�&�&�&�&�&����&�&�&�&�
�A�c�)�+�,�,�q�0�0�
1�F�
5�
5�f�
5�
5�
5�F��f��s�'A#�#A'�*A'c��t��}t|��g}td|z��5}|���|D]y}|�d��rb|���}|dt
tj��dz�}d�|D��}t|�}|�	|���z|cddd��S#1swxYwYdS)zfReturn a list of namedtuple representing the CPU times
    for every CPU available on the system.
    r�scpurc�<�g|]}t|��tz��SrBrr�s  rDr�z!per_cpu_times.<locals>.<listcomp>ps#��A�A�A�Q�%��(�(�[�0�A�A�ArCN)
rr�rr�r�r�r�r�rr�)r��cpusr�r�r�r��entrys       rD�
per_cpu_timesr%bs%��"�#�#�K���%�%�%�
�D�	�Y��,�	-�	-�
��	�
�
�����	#�	#�D����v�&�&�
#���������#�i�&7�"8�"8�1�"<� <�=��A�A�&�A�A�A��!�6�*�����E�"�"�"���
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�
s�BC�C�Cc�N�	tjd��S#t$�rd}tdt	��z��5}|D].}|����d��r|dz
}�/	ddd��n#1swxYwY|dkr�tjd��}tdt	��z��5}|D]7}|�
d	��d}|�|��r|dz
}�8	ddd��n#1swxYwY|dkrYdS|cYSwxYw)
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��searchs    rD�cpu_count_logicalr1vs�����z�/�0�0�0��������
���(9�(9�9�
:�
:�	�a��
�
���:�:�<�<�*�*�<�8�8���1�H�C��
�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��!�8�8��Z��)�)�F��9��'8�'8�8�9�9�
!�Q��!�!�D��:�:�c�?�?�1�-�D��|�|�D�)�)�!��q����!�
!�
!�
!�
!�
!�
!�
!�
!�
!�
!�
!����
!�
!�
!�
!��!�8�8��4�4��
�
�
�-���s]��+D$�2B�4D$�B	�D$�B	�;D$�;D�?D$�D	�D$�D	�	D$�D$�#D$c�P�t��}d}d}tj|��ptj|��D]b}t|��5}|�|��������ddd��n#1swxYwY�ct
|��}|dkr|Si}i}tdt��z��5}|D]�}|������}|s&	|d||d<n#t$rYnwxYwi}�P|�
d��r+|�d	d
��\}	}
t|
��||	<��	ddd��n#1swxYwYt|�����}|pdS)z2Return the number of physical 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)r4r3s	:r)�set�globr�addr�r�r�rr+r�r�r�r��sumr�)�ls�p1�p2rsr��result�mapping�current_infor��key�values           rD�cpu_count_physicalrA�s0��

���B�
E�B�	J�B��	�"�
�
�.���2���%�%��
��
�
�	%�!��F�F�1�6�6�8�8�>�>�#�#�$�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%��
��W�W�F�
��{�{��
��G��L�	�\�O�$5�$5�5�	6�	6�3�!��	3�	3�D��:�:�<�<�%�%�'�'�D��
3��$�\�2��L��8�9�9�������D�����!����?�?�#A�B�B�3�!%���F�A�!6�!6�J�C��(+�E�
�
�L��%��	3�3�3�3�3�3�3�3�3�3�3�3����3�3�3�3�"����!�!�
"�
"�F��>�T�sI�:B�B	�B	�-E8�D�E8�
D$�!E8�#D$�$AE8�8E<�?E<c�2�tdt��z��5}d}d}d}|D]�}|�d��r(t|���d��}ny|�d��r(t|���d��}n<|�d��r't|���d��}|�|�|�n��ddd��n#1swxYwYd}tj||||��S)z*Return various CPU stats as a named tuple.r�Nsctxtrsintrssoftirqr)rrr�r�r�r�	scpustats)r��ctx_switches�
interrupts�soft_interruptsr��syscallss      rD�	cpu_statsrH�sR��	�Y��!2�!2�2�	3�	3�
�q����
����		�		�D����w�'�'�
7�"�4�:�:�<�<��?�3�3�������)�)�
7� ������a��1�1�
�
�����,�,�
7�"%�d�j�j�l�l�1�o�"6�"6���'�O�,G�"�.����
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��H����j�/�8�=�=�=s�C
C5�5C9�<C9z'/sys/devices/system/cpu/cpufreq/policy0z$/sys/devices/system/cpu/cpu0/cpufreqc	�6�d�}g}tt����D]�}||��}|s�tjj}t||d��d���}|�,t||d��d���}|�t
d���t|��dz}tt||d������dz}tt||d	������dz}|�tj
|||������|S)
z�Return frequency metrics for all CPUs.
        Contrarily to other OSes, Linux updates these values in
        real-time.
        c�f�d|zd|zfD]%}tj�|��r|cS�&dS)Nz(/sys/devices/system/cpu/cpufreq/policy%sz%/sys/devices/system/cpu/cpu%s/cpufreq)r�rs�exists)r/�ps  rD�get_pathzcpu_freq.<locals>.get_path�sR��@�3�F�=��C�E�
�
���7�>�>�!�$�$���H�H�H��
�
rC�scaling_cur_freqN�r��cpuinfo_cur_freqz!can't find current frequency filei��scaling_max_freq�scaling_min_freq)�ranger1r�rsrr��NotImplementedErrorr�r�r�scpufreq)rMr��nrs�pjoin�curr�max_�min_s        rD�cpu_freqr[�s=��
	�	�	����(�*�*�+�+�	;�	;�A��8�A�;�;�D��
���G�L�E��u�u�T�#5�6�6��F�F�F�D��|��5�5��'9�:�:�T�J�J�J���<�-�;�=�=�=��t�9�9�t�#�D��s�5�5��'9�:�:�;�;�<�<�t�C�D��s�5�5��'9�:�:�;�;�<�<�t�C�D��J�J�w�'��d�D�9�9�:�:�:�:��
rCz
/proc/cpuinfoc	�n�g}tdt��z��5}|D]x}|����d��rO|�dd��\}}|�t
jt|��dd�����y	ddd��n#1swxYwY|S)z}Alternate implementation using /proc/cpuinfo.
        min and max frequencies are not available and are set to None.
        r(scpu mhz�:rr�N)	rrr+r�r�r�rrUr)r�r�r�r?r@s     rDr[r[�s����
���(9�(9�9�
:�
:�	G�a��
G�
G���:�:�<�<�*�*�:�6�6�G�!%���D�!�!4�!4�J�C���J�J�w�/��e���b�"�E�E�F�F�F��
G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G����	G�	G�	G�	G�
�
s�A<B*�*B.�1B.c��gS)zGDummy implementation when none of the above files are present.
        rBrBrCrDr[r[s	���	rCc��eZdZdS)�_Ipv6UnsupportedErrorN)r?r@rArBrCrDr`r`s�������DrCr`c�r�eZdZdZd�Zd�Zd�Zed���Zed
d���Z	ed
d���Z
d
d	�ZdS)�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�L�dtjtjf}dtjtjf}dtjtjf}dtjtjf}dtjdf}|||||f||f|f|f||f|f|f|f||||f||f||fd�|_d|_dS)N�tcp�tcp6�udp�udp6�unix)�allrd�tcp4rerf�udp4rgrh�inet�inet4�inet6)�socket�AF_INET�SOCK_STREAM�AF_INET6�
SOCK_DGRAM�AF_UNIX�tmap�_procfs_path)�selfrjrerkrgrhs      rD�__init__zConnections.__init__ s����v�~�v�'9�:������);�<���v�~�v�'8�9������):�;������-���$��d�D�1��$�<��G��G��$�<��G��G��G��4��t�,��D�\��D�\�
�
��	�!����rCc���tt��}tj|j�d|�d���D]�}	t|j�d|�d|����}|�d��r<|dd�dd�}||�|t|��f���q#ttf$rY��t$r }|jtj
krYd}~���d}~wwxYw|S)Nr��/fd�/fd/zsocket:[r�r8)r�listr��listdirrvr�r�r�r�rr!r�r��EINVAL)rwr��inodesrt�inoders      rD�get_proc_inodeszConnections.get_proc_inodes7s���T�"�"���*�4�+<�+<�+<�c�c�c�B�C�C�	9�	9�B�
9� �$�2C�2C�2C�S�S�S�"�"�!M�N�N���#�#�J�/�/�9�!�!�"�"�I�c�r�c�N�E��5�M�(�(�#�s�2�w�w��8�8�8���&�'9�:�
�
�
����
�
�
��9���,�,��H�H�H�H������	
�����
s#�B%�%C!�8	C!�C�C�C!c��i}t��D]H}	|�|�|�����,#ttt
f$rY�EwxYw|S�N)�pids�updater�rr!r )rwrr�s   rD�get_all_inodeszConnections.get_all_inodesMss�����6�6�	�	�C�

��
�
�d�2�2�3�7�7�8�8�8�8��%�'9�?�K�
�
�
���
�����
s�(=�A�Ac
�(�|�d��\}}t|d��}|sdStr|�d��}|tjkr`tr1t	j|tj	|��ddd���}n�t	j|tj	|����}n�tj	|��}	trCt	jtj
tjdgtj
d|���R���}nBt	jtj
tjdgtj
d|���R���}n$#t$rt��st ��wxYwt#j||��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
        �:�rB�asciiNr8z>4Iz<4I)r�r�r"�encoderorp�
LITTLE_ENDIAN�	inet_ntop�base64�	b16decoderr�struct�pack�unpackr*rr`r�addr)r��family�ip�ports    rD�decode_addresszConnections.decode_address]s���"�:�:�c�?�?���D��4��}�}���	��2��	$����7�#�#�B��V�^�#�#��
D��%�f�f�.>�r�.B�.B�4�4�R�4�.H�I�I����%�f�f�.>�r�.B�.B�C�C����!�"�%�%�B�
� �G��)�����E�E�F�M�%��,D�,D�E�E�E�G�G�B�B� �)�����E�E�F�M�%��,D�,D�E�E�E�G�G�B����
�
�
�$����/�/��
�����|�B��%�%�%s
�BE�!E<Nc#�
K�|�d��r!tj�|��sdSt	|t
���5}|���t|d��D]�\}}	|���dd�\
}}	}
}}}}}}}n&#t$rtd|�d|�d|�����wxYw||vr||d	\}
}nd
\}
}|�||
kr�x|tjkrt|}ntj}	t �|	|��}	t �|
|��}
n#t$$rY��wxYw||||	|
||
fV���	ddd��dS#1swxYwYdS)z.Parse /proc/net/tcp* and /proc/net/udp* files.�6N��	bufferingrr��error while parsing �; malformed line r�r�Nr8)r�r�rsrKr�BIGFILE_BUFFERINGr��	enumerater�r*�RuntimeErrorrorq�TCP_STATUSESr�	CONN_NONErbr�r`)�filer��type_r�
filter_pidr��linenor�r�laddr�raddr�statusr�r�rts               rD�process_inetzConnections.process_inet�s6�����=�=����	�b�g�n�n�T�&:�&:�	��F�
�t�'8�
9�
9�
9� 	I�Q�
�J�J�L�L�L� )�!�Q���
I�
I����1��
�
���S�b�S�)�B�A�u�e�V�Q��1�a��E�E��!�1�1�1�&�,� �D�D�&�&�&�$�$�0�1�1�1�1�����F�?�?�%�U�m�A�.�G�C���&�G�C���)�j�C�.?�.?���� 2�2�2�!-�f�!5���!(�!2��!� +� :� :�5�&� I� I�� +� :� :�5�&� I� I����0�!�!�!� ��!�����v�u�e�U�F�C�H�H�H�H�H�=
I� 	I� 	I� 	I� 	I� 	I� 	I� 	I� 	I� 	I� 	I� 	I� 	I���� 	I� 	I� 	I� 	I� 	I� 	IsO�*E8�:'B"�!E8�"#C�AE8�6E�
E8�
E�E8�E�E8�8E<�?E<c
#�0K�t|t���5}|���|D]�}|���}	|dd�\}}}}}}}	n)#t$rd|vrY�:td|�d|�����wxYw|	|vr	||	}
ndg}
|
D]f\}}|�||kr�t
|��d	kr	|d
}
nd}
tjt|����}d}tj
}||||
|||fV��g��	ddd��dS#1swxYwYdS)zParse /proc/net/unix files.r�r�r�r�r�r�Nr�r8�)rr�r�r�r*r�r�r�socktype_to_enumr�r�)r�r�rr�r�r��tokensrr�r��pairsr�rtrsr�r�s                rD�process_unixzConnections.process_unix�s������t�'8�
9�
9�
9�!	L�Q�
�J�J�L�L�L��
L�
L��������)�28��1��+�/�A�q�!�Q��q�%�%��!�)�)�)��$��� ��&�,� �D�D�$�$�(�)�)�)�	)�����F�?�?�#�5�M�E�E�'�L�E�$�L�L�G�C��!�-�*��2C�2C� ��v�;�;�!�+�+�#)�"�:�D�D�#%�D� '� 8��U��� D� D��!#��!(�!2��!�6�5�$��v�s�K�K�K�K�K�L�#
L�!	L�!	L�!	L�!	L�!	L�!	L�!	L�!	L�!	L�!	L�!	L�!	L����!	L�!	L�!	L�!	L�!	L�!	Ls6�-D�A�D�B�(D�*B�A=D�D�Dc���||jvr7td|�dd�d�|jD���������t��|_|�|�|��}|sgSn|���}t��}|j|D]�\}}}|j�d|��}|tj	tj
fvr|�|||||���}	n|�||||���}	|	D]U\}
}}}}}
}|rtj|
|||||
��}ntj|
|||||
|��}|�|���V��t#|��S)Nzinvalid z kind argument; choose between rc�,�g|]}t|����SrB)�reprr�s  rDr�z(Connections.retrieve.<locals>.<listcomp>�s��0L�0L�0L�Q��a���0L�0L�0LrCz/net/)r�)rur*rrrvr�r�r5rorprrr�r�r�pconn�sconnr7r|)rw�kindr�rr��
proto_namer�r�rsr9rtr�r�r��	bound_pid�conns                rD�retrievezConnections.retrieve�s����t�y� � ��*� $���d�i�i�0L�0L�$�)�0L�0L�0L�&M�&M�&M�O�P�P�
P�+�-�-����?��)�)�#�.�.�F��
��	�
��(�(�*�*�F��e�e��)-��4��	�	�%�J���"&�"3�"3�"3�Z�Z�@�D��&�.�&�/�:�:�:��&�&��&�%��C�'�A�A����&�&��&�&�S�'�:�:��FH�
�
�B��F�E�5�%����<�"�=��V�U�E�5�)/�1�1�D�D�#�=��V�U�E�5�)/��<�<�D�����
�
�
�
�
��C�y�y�rCr�)r?r@rA�__doc__rxr�r��staticmethodr�r�r�r�rBrCrDrbrbs�������	�	�!�!�!�.���,��� �0&�0&��\�0&�d�%I�%I�%I��\�%I�N�#L�#L�#L��\�#L�J�����rCrbrlc�6�t�|��S)z$Return system-wide open connections.)�_connectionsr�)r�s rD�net_connectionsr�s��� � ��&�&�&rCc��tdt��z��5}|���}ddd��n#1swxYwYi}|dd�D]�}|�d��}|dksJt	|�����|d|����}||dzd�������}tt|��\}}}	}
}}}
}}}}}}}}}|||||	||
|f||<��|S)zsReturn network I/O statistics for every network interface
    installed on the system as a dict of raw tuples.
    z
%s/net/devNr<r�rr)	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�
compressedouts                       rD�net_io_countersr�sj��
�<�/�"3�"3�3�	4�	4������
�
���������������������G��a�b�b�	�9�9���
�
�3�����q�y�y�y�$�t�*�*�y�y�y��F�U�F�|�!�!�#�#���e�a�i�j�j�!�'�'�)�)�/�/�1�1��&�c�6�*�*�!	��	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�#�Z��|�����9���
�
��Ns�A�A�Ac���tjttjttjti}t�����}i}|D]�}	tj
|��}tj|��}tj|��\}}tj|||||��||<�c#t$r }|jt jkr�Yd}~��d}~wwxYw|S)z)Get NIC stats (isup, duplex, speed, mtu).N)r�DUPLEX_FULLr�DUPLEX_HALFr�DUPLEX_UNKNOWNrr��keys�
cext_posix�
net_if_mtu�net_if_is_running�net_if_duplex_speedr�	snicstatsr�r��ENODEV)	�
duplex_map�namesr�r��mtu�isup�duplex�speedrs	         rD�net_if_statsr�+s����"�O��"�O��%�'9�;�J�
���"�"�$�$�E�
�C��
P�
P��		P��'��-�-�C��/��5�5�D� �4�T�:�:�M�F�E� �)�$�
�6�0B�E�3�O�O�C��I�I���	�	�	��y�E�L�(�(��)�(�(�(�(�����	�����Js�?B=�=
C'�C"�"C'Fc��d�}d�}tj�dt��z��r|��}nHtj�d��r|��}nt	dt��z���i}|D]C}|\
}}}}	}
}}}
}}|st|��s�!|	tz}	|
tz}
|||	|
|||
||f	||<�D|S)zcReturn disk I/O statistics for every disk installed on the
    system as a dict of raw tuples.
    c3�K�tdt��z��5}|���}ddd��n#1swxYwY|D�]}|���}t	|��}|dkrF|d}t|d��}t
t
|dd���\
}}}	}
}}}
}}}n�|dks|dkr2|d}t
t
|dd���\}}}}	}
}}}
}}}nM|dkr5|d}t
t
|dd���\}}}
}d	x}	x}
x}x}}ntd
|z���|||
|||	|
|||f
V���
dS)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�wtimerrqs                rD�read_procfsz%disk_io_counters.<locals>.read_procfsLs�����"�~��(9�(9�9�
:�
:�	"�a��K�K�M�M�E�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"��	;�	;�D��Z�Z�\�\�F��v�;�;�D��r�z�z��a�y���F�1�I����69�#�v�a��d�|�6L�6L�4��v�u�f�m��E�1�i�������t�r�z�z��a�y��69�#�v�a��d�|�6L�6L�4���f�e�V�]��E�1�i��������a�y��03�C������0D�0D�-��v�v�v�KL�L��L��L��L�}�y�y� �!D�t�!K�L�L�L�������u���	�;�
;�
;�
;�
;�+	;�	;s�A�A�	Ac3�\K�tjd��D�]}tjtj�d|����D]�\}}}d|vr�ttj�|d����5}|���������}ddd��n#1swxYwYtj�	|��}tt|dd���\
}}}	}
}}}
}}}||||	|
|
||||f
V��ސ�dS)N�
/sys/block�statr�)r�r}�walkrsrrr�r�r��basenamer�r�)�block�rootr�filesr�r�r�r�r�r�r�r�r�r�r�rqs                rD�
read_sysfsz$disk_io_counters.<locals>.read_sysfsws}�����Z��-�-�
	F�
	F�E�"$�'�"�'�,�,�|�U�*K�*K�"L�"L�	
F�	
F���a����&�&���r�w�|�|�D�&�9�9�:�:�6�a��V�V�X�X�^�^�-�-�3�3�5�5�F�6�6�6�6�6�6�6�6�6�6�6����6�6�6�6��w�'�'��-�-��36�s�F�3�B�3�K�3H�3H�1���f�e�V�]��E�1�i��U�F�F�F�E��l�M�9�F�F�F�F�F�	
F�
	F�
	Fs�9C	�	C
�C
r�r�zC%s/diskstats nor /sys/block filesystem are available on this system)r�rsrKrrTr��DISK_SECTOR_SIZE)�perdiskr�r�genr�r$r�r�r�r�r�r�r�r�r�rqs                rD�disk_io_countersrHs-��);�);�);�VF�F�F�
�w�~�~�n��'8�'8�8�9�9�*��k�m�m���	�����	%�	%�*��j�l�l���!�
�&�(�(�
)�*�*�	*��G��A�A��(-�	&��u�f�f�f�e�U�L��9��	�0��6�6�	�
��"�"���"�"�������u�%�}�i�A���
�
��NrCc	�L�t��}t��}td|z��5}|D]�}|���}|�d��s(|�|������S|�d��d}|dkr|�d����	ddd��n#1swxYwY|dkr?tj�	d��r tj�
d��}n"tj�
d	|z��}g}tj|��}|D]P}	|	\}
}}}|
d
krd}
|s|
dks||vr�dx}
}tj|
||||
|��}|�|���Q|S)z8Return mounted disk partitions as a list of namedtuples.z%s/filesystems�nodev�	r�zfsNr�z	/etc/mtabz%s/self/mounts�noner�)r5rrr�r�r7r�r�rs�isfile�realpathr�disk_partitionsr�	sdiskpartr�)ri�fstypesr�r�r��fstype�mounts_path�retlist�
partitions�	partition�device�
mountpoint�opts�maxfile�maxpath�ntuples                rDrr�s����e�e�G�!�#�#�K�	�#�k�1�	2�	2�	'�a��	'�	'�D��:�:�<�<�D��?�?�7�+�+�
'����D�J�J�L�L�)�)�)�)����D�)�)�!�,���U�?�?��K�K��&�&�&��	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'��g���"�'�.�.��"=�"=���g�&�&�{�3�3����g�&�&�'7�+�'E�F�F���G��%�k�2�2�J��
�
�	�+4�(��
�F�D��V����F��	���|�|�v�W�4�4�� � ��'��"�6�:�v�t�#*�G�5�5�����v������Ns�B
C	�	C
�C
c	��tjt��}tjd��}|�tjd����tt
d�|D������}tjd��}tjd��}|D]1}|�	d|��}||vr|�
|���2|D�]@}	|dz}tt|����dz}tj�tj�|��d	��}t|d
���}	n#t"t$t&f$rY��wxYwt|dzd
���}
t|dzd
���}t|dzdd
���}|
�&	t|
��dz}
n#t&$rd
}
YnwxYw|�&	t|��dz}n#t&$rd
}YnwxYw||	�
|||
|f����B|�s0tjd��}tt
|����}|D�]�}	tj�|d��}tt|����dz}tj�|d��}t|d
���}	n9#t"t$t&f$r}
t)d|
�d|����Yd
}
~
��d
}
~
wwxYwtj|dz��}t
d�|D����}d
}d
}
|D]�}tj�||dz��}t|dd
���}|dkr3ttj�||dz��d
���}n8|dkr2ttj�||dz��d
���}
|
�&	t|
��dz}
n#t&$rd
}
YnwxYw|�&	t|��dz}��#t&$rd
}Y��wxYw��||	�
d||
|f�����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*_*c�D�g|]}|�d��d��S�rr�r�r�s  rDr�z(sensors_temperatures.<locals>.<listcomp>��&��?�?�?��A�G�G�C�L�L��O�?�?�?rCz5/sys/devices/platform/coretemp.*/hwmon/hwmon*/temp*_*z'/sys/devices/platform/coretemp.*/hwmon/z/sys/class/hwmon/�_inputg@�@r�F�r��_maxNrO�_crit�_labelr��r�r�z /sys/class/thermal/thermal_zone*�temp�typez	ignoring z
 for file z/trip_point*c��g|]O}d�tj�|���d��dd�����PS)rrr#)rr�rsrr�)r�rLs  rDr�z(sensors_temperatures.<locals>.<listcomp>%sf��J�J�J�9:� #�x�x��� � ��#�#�)�)�#�.�.�q��s�3� 5� 5�J�J�JrC�_type�critical�_temp�high)�collectionsrr|r6�extend�sortedr5r,r-�subr�rr�r�rsr�dirnamer�r�r*r�dict)r��	basenames�
basenames2�replr��altname�basersr��	unit_namer/r-�labelr�
trip_paths�trip_points�
trip_point�	trip_types                  rD�sensors_temperaturesrA�s����
!�$�
'�
'�C��	�;�<�<�I����T�Y�G�H�H�I�I�I��s�?�?�Y�?�?�?�@�@�A�A�I���?�A�A�J�
�:�?�@�@�D��#�#���(�(�.��5�5���)�#�#����T�"�"�"��� @� @��	��(�?�D��C��I�I�&�&��/�G��7�<�<������ 5� 5�v�>�>�D��D��/�/�/�I�I����*�-�		�		�		�
�H�		�����4�&�=�4�0�0�0���t�g�~��5�5�5���D�8�O�b��?�?�?����
��T�{�{�V�+�����
�
�
�����
������
 � ��?�?�V�3�����
 �
 �
 �����
 ����	�I����u�g�t�X�>�?�?�?�?��(A��I�@�A�A�	��3�y�>�>�*�*�	��$	A�$	A�D�
��w�|�|�D�&�1�1����D�	�	�*�*�V�3���w�|�|�D�&�1�1����U�3�3�3�	�	���W�j�1�
�
�
���3�3�3���=�>�>�>����������
������4�.�#8�9�9�J��J�J�>H�J�J�J�K�K�K��H��D�)�
(�
(�
��w�|�|�D�*�w�*>�?�?����r�%�@�@�@�	��
�*�*�"�2�7�<�<��j�7�6J�#K�#K�,0� 2� 2� 2�H�H��&�(�(��r�w�|�|�D�*�w�2F�G�G�(,�.�.�.�D��#�$�$�T�{�{�V�3����%�$�$�$�#����$�����'�(�#(��?�?�V�#;����%�(�(�(�#'����(����(�
�	�N�!�!�2�w��h�"?�@�@�@�@���9�9�st�A2E�E*�)E*�-G�G�G�G(�(G7�6G7�A0K�K;�K6�6K;�O2�2P�P�P�P)�(P)c���tjt��}tjd��}|stjd��}t	td�|D������}|D]�}	t
t|dz����}n;#ttf$r'}tjd|zt��Yd}~�Vd}~wwxYwttj�tj�|��d��d�	��}t|d
zdd���}||�t%j||������t)|��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*_*c�D�g|]}|�d��d��Sr r!r�s  rDr�z sensors_fans.<locals>.<listcomp>Tr"rCr#zignoring %rNr�Fr$r'r�r()r0rr|r6r2r5r�r�r�r�rr	r
r�rsrr4r�r�sfanr5)r�r6r:r�rr;r<s       rD�sensors_fansrECs\���
!�$�
'�
'�C��	�:�;�;�I��G��I�E�F�F�	��s�?�?�Y�?�?�?�@�@�A�A�I��	<�	<��	��#�d�X�o�.�.�/�/�G�G����!�	�	�	��M�-�#�-�~�>�>�>��H�H�H�H�����	���������R�W�_�_�T�%:�%:�F�C�C�$�&�&�&�	��D�8�O�b��?�?�?���I����g�l�5�'�:�:�;�;�;�;���9�9�s�/B�C� C�Cc�F��t����fd�}d�tjt��D��}|sdStj�tt
|��d��}||dz|dz��}||dz|dz��}||d	z|d
z��}||dz��}|�|�	d|z|z}n;#t$rd
}Yn-wxYwtt|dzd�����}|dkrdSd}|tj�td��tj�td����}	|	�|	dk}n6t|dzdd����
��}
|
dkrd}n|
dvrd}|r
tj}nj|�5|�3	t||zdz��}nO#t$rtj
}Yn7wxYw|�%t|dz��}|dkrtj
}ntj
}tj|||��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���|D]@}t|����}|�kr'|���rt|��n|cS�AdS)zvAttempt to read the content of multiple files which may
        not exist. If none of them exist return None.
        rON)r��isdigitr�)�pathsrsr��nulls   �rD�	multi_catz"sensors_battery.<locals>.multi_catls\����	:�	:�D��d�T�*�*�*�C��d�{�{�#&�;�;�=�=�9�s�3�x�x�x�c�9�9�9���trCc�h�g|]/}|�d��sd|���v�-|��0S)�BAT�battery)r�r+r�s  rDr�z#sensors_battery.<locals>.<listcomp>vsG��$�$�$�!����U�8K�8K�$�������"�"�
�"�"�"rCNrz/energy_nowz/charge_nowz
/power_nowz/current_nowz/energy_fullz/charge_fullz/time_to_empty_nowgY@r�z	/capacityr8rOz
AC0/onlinez	AC/onliner�/statusr�Fr(�discharging)�charging�fullTi�<)�objectr�r}�POWER_SUPPLY_PATHrsrr2�ZeroDivisionErrorr�r�r+r�POWER_TIME_UNLIMITED�POWER_TIME_UNKNOWN�sbattery)
rK�batsr�
energy_now�	power_now�energy_full�
time_to_emptyr_�
power_plugged�onliner��secsleftrJs
            @rD�sensors_batteryrbcs�����8�8�D������$�$�r�z�"3�4�4�$�$�$�D����t��7�<�<�)�6�$�<�<��?�;�;�D����}���}����J��	��|���~����I��)��~���~����K��I�d�%9�9�:�:�M���:�#9�	��j�(�;�6�G�G�� �	�	�	��G�G�G�	�����c�$��,�r�:�:�:�;�;���b�=�=��4�
�M�
�Y�
����&��5�5�
����&��4�4�6�6�F����!��
�
��T�I�%��5�A�A�A�G�G�I�I���]�"�"�!�M�M�
�+�
+�
+� �M��.��/���	�	�I�$9�	2��:�	�1�D�8�9�9�H�H�� �	2�	2�	2��1�H�H�H�	2����	�	"��}�r�)�*�*���a�<�<��1�H���-����G�X�}�=�=�=s$�=C�C�C�(F>�>G�Gc��g}tj��}|D]C}|\}}}}}}|s�|dvrd}tj||pd|||��}	|�|	���D|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��nts
          rDrere�s����G��j�l�l�G��
�
��9=�6��c�8�V�\�3��	���~�%�%�"�H�
�]�4����h���
D�
D�����r������NrCc�L�dt��z}t|��5}|D]b}|�d��rKt|������d��}|a|ccddd��S�ctd|z���#1swxYwYdS)zAReturn the system boot time expressed in seconds since the epoch.r�sbtimerNzline 'btime' not found in %s)rrr�rr�r��	BOOT_TIMEr�)rsr�r�r�s    rD�	boot_timerp�s�����(�(�(�D�	�T�	�	�3�a��	�	�D����x�(�(�
��D�J�J�L�L�.�.�0�0��3�4�4���	��
�
�3�3�3�3�3�3�3�3�
��*�T�1�3�3�	3�
3�3�3�3����3�3�3�3�3�3s�AB�B�B� Bc�p�d�tjtt������D��S)z7Returns a list of PIDs currently running on the system.c�T�g|]%}|����t|����&SrB)rHr�r�s  rDr�zpids.<locals>.<listcomp>�s+��L�L�L�q��	�	���L�C��F�F�L�L�LrC)r�r}rrrBrCrDr�r��s.��L�L�B�J�q��):�):�';�';�<�<�L�L�L�LrCc��tj|��sdS	t���d|�d�}t|��5}|D]R}|�d��r;t|���d��}||kccddd��S�Std|z���#1swxYwYdS#ttf$r|t��vcYSwxYw)zcCheck for the existence of a unix PID. Linux TIDs are not
    supported (always return False).
    Fr�rOsTgid:rNz'Tgid' line not found in %s)
r�
pid_existsrrr�r�r�r*�EnvironmentErrorr�)r�rsr�r��tgids     rDrtrt�s[����s�#�#�!��u�	!�&5�%6�%6�%6�%6����<�D��T�"�"�
G�a��+�+�D����x�0�0�+�"�4�:�:�<�<��?�3�3�� $�s�{�*�*�

G�
G�
G�
G�
G�
G�
G�
G�+�
!�!>��!E�F�F�F�
G�
G�
G�
G����
G�
G�
G�
G�
G�
G��!�*�-�	!�	!�	!��$�&�&�=� � � �	!���s;�#B0�AB#�B0�B#�#B'�'B0�*B'�+B0�0!C�Cc��i}t��}t��D]�}	t|�d|�d���5}|���}ddd��n#1swxYwY|�d��}||dzd����}t
|d��}|||<��#ttf$rY��wxYw|S)zsObtain a {pid: ppid, ...} dict for all running processes in
    one shot. Used to speed up Process.children().
    r��/statN�)r<r)	rr�rr�r�r�r�rr!)r�r�r�r��data�rpar�dset�ppids        rD�ppid_mapr~s!��
�C�!�#�#�K��v�v����	��[�[�[�#�#�#�>�?�?�
 �1��v�v�x�x��
 �
 �
 �
 �
 �
 �
 �
 �
 �
 �
 ����
 �
 �
 �
 ��:�:�d�#�#�D���q��	�	�?�(�(�*�*�D��t�A�w�<�<�D��C��H�H��"�#5�6�	�	�	�
�D�	�����Js4�B2�A�B2�A	�B2�A	� B2�2C�Cc�F��tj����fd���}|S)zlDecorator which translates bare OSError and IOError exceptions
    into NoSuchProcess and AccessDenied.
    c�X��	�|g|�Ri|��S#t$rt|j|j���t$rt|j|j���t$rJtj�	|j
�d|j����st|j|j����wxYw)Nr�)r rr��_namer!rrr�rsrKrv)rw�args�kwargs�funs   �rD�wrapperz wrap_exceptions.<locals>.wrapper%s����	��3�t�-�d�-�-�-�f�-�-�-���	5�	5�	5��t�x���4�4�4�!�	6�	6�	6����$�*�5�5�5� �	�	�	��7�>�>�T�->�->�->����"I�J�J�
:�#�D�H�d�j�9�9�9�
�	���s
��BB))�	functools�wraps)r�r�s` rD�wrap_exceptionsr�!s:����_�S�����������NrCc��eZdZdZgd�Zd�Zd�Zeed�����Z	eed�����Z
eed�����Zd�Zd	�Z
ed
���Zd�Zed���Zed
���Zed���Zej�dej��z��red���Zed���Zed���Zed5d���Zed���Zed���Zer:eejd��ejd��ejd��fd���Z neZ ered���Z!ed���Z"eejd��fd���Z#eejd��fd ���Z$ed!���Z%ed"���Z&ed#���Z'e(r)ed$���Z)ejd%��fd&�Z*ed'���Z+e,red(���Z-ed)���Z.e/�ed5d*���Z0ed+���Z1ed,���Z2ed6d.���Z3ed/���Z4ed0���Z5eejd1��fd2���Z6eejd3��fd4���Z7dS)7�ProcesszLinux process implementation.)r�r��_ppidrv�_cachec�V�||_d|_d|_t��|_dSr�)r�r�r�rrv)rwr�s  rDrxzProcess.__init__;s+�������
���
�+�-�-����rCc�L�tj|j�d|j����dS)z+Raise NSP if the process disappeared on us.r�N)r�r�rvr��rws rD�
_assert_alivezProcess._assert_aliveAs,��	��4�,�,�,�d�h�h�7�8�8�8�8�8rCc�.�t|j�d|j�d���5}|���}ddd��n#1swxYwY|�d��}||�d��dz|�}||dzd����}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.
        r�rxNry�(rr<r�rr�r}r$�ttynr��utime��stime�
�children_utimer��children_stime��create_time�$�cpu_num�'�blkio_ticks)rrvr�r�r��findr�)rwr�rzr{r�r�r�s       rD�_parse_stat_filezProcess._parse_stat_fileGsn����):�):�):�D�H�H�H�E�
F�
F�	�!��6�6�8�8�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�z�z�$�����D�I�I�d�O�O�a�'��,�-���d�Q�h�i�i��&�&�(�(������F���q�	��H�
��Q�i��F���a�y��G���b�z��G���b�z��G�� &�r�
���� &�r�
����#�B�Z��M������I��#�B�Z��M���
��A�A�Ac��t|j�d|j�d���5}|���cddd��S#1swxYwYdS)z�Read /proc/{pid}/stat file and return its content.
        The return value is cached in case oneshot() ctx manager is
        in use.
        r�rON)rrvr�r��rwr�s  rD�_read_status_filezProcess._read_status_filejs����4�+<�+<�+<�d�h�h�h�G�
H�
H�	�A��6�6�8�8�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�A�A�Ac���t|j�d|j�d�t���5}|������cddd��S#1swxYwYdS)Nr�z/smapsr�)rrvr�r�r�r�r�s  rD�_read_smaps_filezProcess._read_smaps_filets����$�*;�*;�*;�T�X�X�X�F�#4�6�6�6�	$�9:��6�6�8�8�>�>�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	$�	$s�&A�A�!Ac��|j�|��|j�|��|j�|��dSr�)r��cache_activater�r�r�s rD�
oneshot_enterzProcess.oneshot_enter{sM����,�,�T�2�2�2���-�-�d�3�3�3���,�,�T�2�2�2�2�2rCc��|j�|��|j�|��|j�|��dSr�)r��cache_deactivater�r�r�s rD�oneshot_exitzProcess.oneshot_exit�sM����.�.�t�4�4�4���/�/��5�5�5���.�.�t�4�4�4�4�4rCc�f�|���d}trt|��}|S)Nr�)r�r"r
)rwr�s  rDr�zProcess.name�s0���$�$�&�&�v�.���	 ��$�<�<�D��rCc��	t|j�d|j�d���S#ttf$r�t
j�|j�d|j����rYdSt|j��st|j|j
���t|j|j
|j���t$rt|j|j
���wxYw)Nr�z/exer�)r�rvr�rr!r�rs�lexistsrtrr�rr�r rr�s rD�exezProcess.exe�s���	5��4�+<�+<�+<�d�h�h�h�G�H�H�H��!�#5�6�
	J�
	J�
	J��w���$�*;�*;�*;�T�X�X�F�G�G�
J��r�r�!�$�(�+�+�J�'���$�*�=�=�=�'���$�*�d�j�I�I�I��	5�	5�	5��t�x���4�4�4�	5���s�!�?C�#A2Cc��t|j�d|j�d���5}|���}ddd��n#1swxYwY|sgS|�d��rdnd}|�|��r
|dd�}|�|��}|dkr,t
|��dkrd|vr|�d��}|S)Nr�z/cmdliner�r�r8r)rrvr�r�r�r�r�)rwr�rz�sep�cmdlines     rDr�zProcess.cmdline�s��
�$�*;�*;�*;�T�X�X�X�F�
G�
G�	�1��6�6�8�8�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��	��I��
�
�f�-�-�6�f�f�3���=�=����	�����9�D��*�*�S�/�/���&�=�=�S��\�\�Q�.�.�3�$�;�;��j�j��o�o�G��r�c��t|j�d|j�d���5}|���}ddd��n#1swxYwYt	|��S)Nr�z/environ)rrvr�r�r)rwr�rzs   rD�environzProcess.environ�s���
�$�*;�*;�*;�T�X�X�X�F�
G�
G�	�1��6�6�8�8�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�"�4�(�(�(r�c��t|���d��}tj��}	||S#t$rYdSwxYw)Nr�)r�r�r�get_terminal_mapr�)rw�tty_nrrus   rD�terminalzProcess.terminal�s_���T�*�*�,�,�W�5�6�6���(�*�*��	���<����	�	�	��4�4�	���s�A�
A�Az/proc/%s/ioc	� �|j�d|j�d�}i}t|��5}|D]T}|���}|r<	|�d��\}}t|��||<�D#t$rY�PwxYw�U	ddd��n#1swxYwY|std|z���	t|d|d|d|d|d	|d
��S#t$r"}t
|d�d|�d
|�����d}~wwxYw)Nr�z/ios: z%s file was emptyssyscrssyscws
read_bytesswrite_bytessrcharswcharrz field was not found in z; found fields are )
rvr�rr�r�r�r*r�r�r�)rwr�r�r�r�r�r@rs        rD�io_counterszProcess.io_counters�s���"&�"3�"3�"3�T�X�X�X�>�E��F��U�#�#�
6�q��
6�
6�D��:�:�<�<�D��6�6�*.�*�*�U�*;�*;�K�D�%�
,/�u�:�:�F�4�L�L��	 *�%�%�%�$�H�%����6�
6�
6�
6�
6�
6�
6�
6�
6�
6�
6�
6�
6����
6�
6�
6�
6��
@�"�#6��#>�?�?�?�
E���8�$��8�$��=�)��>�*��8�$��8�$�
�����
E�
E�
E� �-0��V�V�V�U�U�U�F�F�"D�E�E�E�����
E���sM�B	�A+�B	�+
A8�5B	�7A8�8B	�	B
�B
�)7C!�!
D
�+D�D
c�r�|���}t|d��tz}t|d��tz}t|d��tz}t|d��tz}t|d��tz}t|||||��S)Nr�r�r�r�r�)r�rrr�)rwr�r�r�r�r�r�s       rDr zProcess.cpu_times�s����&�&�(�(���f�W�o�&�&��4���f�W�o�&�&��4���v�&6�7�8�8�;�F���v�&6�7�8�8�;�F���v�m�,�-�-��;�����~�~�v�N�N�NrCc�P�t|���d��S)zWhat CPU the process is on.r��r�r�r�s rDr�zProcess.cpu_num�s#���4�(�(�*�*�9�5�6�6�6rCNc�B�tj|j||j��Sr�)r�wait_pidr�r�)rw�timeouts  rD�waitzProcess.wait�s��� ���7�D�J�?�?�?rCc��t|���d��}tp
t��}|tz|zS)Nr�)rr�rorpr)rw�ctime�bts   rDr�zProcess.create_time�s@���d�+�+�-�-�m�<�=�=���
%�)�+�+����#�r�)�)rCc	��t|j�d|j�d���5}d�|������dd�D��\}}}}}}}ddd��n#1swxYwYt|||||||��S)Nr�z/statmc�<�g|]}t|��tz��SrB)r�r�r�s  rDr�z'Process.memory_info.<locals>.<listcomp>s#��E�E�E�q��Q���(�"�E�E�ErCr�)rrvr�r�r�rx)	rwr��vmsr~rf�text�librz�dirtys	         rD�memory_infozProcess.memory_infos����$�*;�*;�*;�T�X�X�X�F�
G�
G�	F�1�E�E�A�J�J�L�L�,>�,>�,@�,@��!��,D�E�E�E�
5�C��f�d�C��u�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F��C��f�d�C��u�=�=�=s�AA-�-A1�4A1s\nPrivate.*:\s+(\d+)s\nPss\:\s+(\d+)s\nSwap\:\s+(\d+)c��|���}|���}ttt|�|������dz}ttt|�|������dz}ttt|�|������dz}t
||||fz�S)Nr)r�r�r8r�r��findallry)	rw�_private_re�_pss_re�_swap_re�	basic_mem�
smaps_datarzr{r|s	         rD�memory_full_infozProcess.memory_full_infos����(�(�*�*�I��.�.�0�0�J��c�#�{�2�2�:�>�>�?�?�@�@�4�G�C��c�#�w���z�:�:�;�;�<�<�t�C�C��s�3�� 0� 0�� <� <�=�=�>�>��E�D��Y�#�s�D�)9�9�:�:rCc��d�}|���}|sgS|�d��}g}|�d��}|g}|||��D�]�\}}|�dd��}	|\}	}
}}}
}n#t$r|dgz\}	}
}}}
}YnwxYw|sd}nXtrt|��}|���}|�d��rt|��s
|dd	�}|�	t|	��t|
��||�
d
d��|�
dd��|�
dd��|�
d
d��|�
dd��|�
dd��|�
dd��|�
dd��|�
dd��|�
dd��f
�����|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.
            c3��K�i}|D]�}|�dd��}|d�d��s.|���|fV�|�|���a	t	|d��dz||d<��#t
$r0|d�d��rY��td|z���wxYw|���|fV�dS)N�rr]rrsVmFlags:z#don't know how to interpret line %r)r�r��popr�r�r*r�)r��
current_blockrzr�r�s     rD�
get_blocksz'Process.memory_maps.<locals>.get_blocksEs*������!�I�I�D�!�Z�Z��a�0�0�F�!�!�9�-�-�d�3�3�
I�,�0�0�2�2�D�9�9�9�9�%�,�,�T�2�2�2�2�I�.1�&��)�n�n�t�.C�D����O�O��)�I�I�I�%�a�y�3�3�K�@�@�I� (��&0�2A�CG�2H�'I�'I�!I�I����%�(�(�*�*�D�1�1�1�1�1�1s�)!B�%C�2C�
rNr�r�z[anon]r�r�sRss:sSize:sPss:s
Shared_Clean:s
Shared_Dirty:sPrivate_Clean:sPrivate_Dirty:sReferenced:s
Anonymous:sSwap:)r�r�r�r*r"r
r�r�rr�r�)rwr�rzr�r9�
first_liner��header�hfieldsr��perms�offset�devr�rss               rD�memory_mapszProcess.memory_maps<s+��
2�
2�
2�(�(�(�*�*�D��
��	��J�J�u�%�%�E��B����1���J�'�L�M� *�
�5�-� @� @�
�
���� �,�,�t�Q�/�/��'�<C�9�D�%���e�T�T��!�'�'�'��2�$��:�D�%���e�T�T�T�'�����*�#�D�D��,�%�d�|�|���:�:�<�<�D��
�
�l�3�3�*�.�t�4�4�*�#�D�S�D�z���	�	��4�L�L�&��-�-���H�H�W�a�(�(��H�H�X�q�)�)��H�H�W�a�(�(��H�H�-�q�1�1��H�H�-�q�1�1��H�H�.��2�2��H�H�.��2�2��H�H�^�Q�/�/��H�H�]�A�.�.��H�H�X�q�)�)�������Is�4	A>�>B�Bc��	t|j�d|j�d���S#ttf$rOt|j��st
|j|j���t|j|j|j	���wxYw)Nr�z/cwd)
r�rvr�rr!rtrr�rr�r�s rD�cwdzProcess.cwd�s���	F��4�+<�+<�+<�d�h�h�h�G�H�H�H��!�#5�6�	F�	F�	F��d�h�'�'�
F�#�D�H�d�j�9�9�9�#�D�H�d�j�$�*�E�E�E�	F���s
�!�A Bsctxt_switches:\t(\d+)c��|���}|�|��}|s td|j�d|j�d����tjt|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�r�rTrvr�r�pctxswr�)rw�	_ctxsw_rerz�ctxsws    rD�num_ctx_switcheszProcess.num_ctx_switches�s����%�%�'�'���!�!�$�'�'���	@�%�%��%�%�%�t�x�x�x�1�2�2�
2��>�#�e�A�h�-�-��U�1�X���?�?�?rCsThreads:\t(\d+)c�z�|���}t|�|��d��S�Nr)r�r�r�)rw�_num_threads_rerzs   rD�num_threadszProcess.num_threads�s6��
�%�%�'�'���?�*�*�4�0�0��3�4�4�4rCc���tj|j�d|j�d���}|���g}d}|D�] }|j�d|j�d|�d�}	t|��5}|������}ddd��n#1swxYwYn#t$rd}Y�uwxYw||�	d��dzd�}|�
d	��}t|d
��tz}	t|d��tz}
tjt|��|	|
��}|�|����"|r|���|S)Nr�z/taskFz/task/rxTryr<rr�r�)r�r}rvr��sortrr�r�rr�r�rrr�pthreadr�r�r�)rw�
thread_idsr�
hit_enoent�	thread_idr�r��str�r�r�rs            rD�threadszProcess.threads�s����Z��0A�0A�0A�4�8�8�8� L�M�M�
����������
�#�	#�	#�I��!�!�!�4�8�8�8�Y�Y�Y�8�E�
� ��'�'�*�1��������)�)�B�*�*�*�*�*�*�*�*�*�*�*����*�*�*�*���$�
�
�
�"�
���	
�����B�G�G�D�M�M�A�%�&�&�'�B��X�X�d�^�^�F��&��*�%�%��3�E��&��*�%�%��3�E��_�S��^�^�U�E�B�B�F��N�N�6�"�"�"�"��	!���� � � ��s6�B&�''B�B&�B	�B&�!B	�"B&�&B5�4B5c�4�tj|j��Sr�)r��getpriorityr�r�s rD�nice_getzProcess.nice_get�s���%�d�h�/�/�/rCc�6�tj|j|��Sr�)r��setpriorityr�)rwr@s  rD�nice_setzProcess.nice_set�s���%�d�h��6�6�6rCc�4�tj|j��Sr�)rr6r�r�s rD�cpu_affinity_getzProcess.cpu_affinity_get�s���-�d�h�7�7�7rCsCpus_allowed_list:\t(\d+)-(\d+)c	�f�|���}|�|��}|rRttt	|dd��t	|dd��dz����Stttt
��������S)Nrr)r�r�r|rSr�r�r%)rw�_rerzr.s    rD�_get_eligible_cpuszProcess._get_eligible_cpus�s����)�)�+�+�D��K�K��%�%�E��
9��E�#�e�A�h�q�k�"2�"2�C��a����4D�4D�q�4H�I�I�J�J�J��E�#�m�o�o�"6�"6�7�7�8�8�8rCc	���	tj|j|��dS#ttf$r�}t|t��s|jtjkr�|���}tttt��������}|D]4}||vrt	d|�d|�����||vrt	d|�d|������5�d}~wwxYw)Nzinvalid CPU number z; choose between zCPU number z! is not eligible; choose between )
r�proc_cpu_affinity_setr�r�r*r�r�r~r�tuplerSr�r%)rwr#r�
eligible_cpus�all_cpus�cpus      rD�cpu_affinity_setzProcess.cpu_affinity_set�s��
��*�4�8�T�:�:�:�:�:���Z�(�

�

�

��c�:�.�.�E�#�)�u�|�2K�2K�$(�$;�$;�$=�$=�M�$�U�3�}���+?�+?�%@�%@�A�A�H�#�E�E���h�.�.�",�*�$'�C�C���!8�#9�#9�9��m�3�3�",�*�03���]�]�!D�#E�#E�E�4������

���s��C�B+C�Cc��tj|j��\}}t�t	|��}tj||��Sr�)rr5r��enumr>r�pionice�rw�ioclassr@s   rD�
ionice_getzProcess.ionice_get�s=��!�1�$�(�;�;�N�G�U���$�W�-�-���?�7�E�2�2�2rCc��|�d}|r"|ttfvrtd|z���|dks|dkrtd���tj|j||��S)Nrz%r ioclass accepts no valuer�zvalue not in 0-7 range)r)r&r*r�proc_ioprio_setr�r
s   rD�
ionice_setzProcess.ionice_set�sq���}����
J��%6�8I�$J�J�J� �!>��!H�I�I�I��q�y�y�E�A�I�I� �!9�:�:�:��'���'�5�A�A�ArCc��|jdkrtd���	|�t|j|��St|��dkrtdt	|��z���t|j||��dS#t
$rO}|jtjkr4t|j��r t|j|j
|j����d}~wwxYw)Nrz)can't use prlimit() against PID 0 processr<z4second argument must be a (soft, hard) tuple, got %s)r�r*r�r�r�r�r��ENOSYSrtrr�r�)rwr�r�rs    rD�rlimitzProcess.rlimits���
�x�1�}�}� �!L�M�M�M�
��>�"�4�8�Y�7�7�7��6�{�{�a�'�'�(�%�'+�F�|�|�4�5�5�5��D�H�i��8�8�8�8�8���
�
�
��9���,�,��D�H�1E�1E�,�(���$�*�d�j�I�I�I������

���s�A=�AA=�=
C�A
C�Cc��|���d}tr|���}t�|d��S)Nr��?)r�r"r
�
PROC_STATUSESr�)rw�letters  rDr�zProcess.statussC���&�&�(�(��2���	%��]�]�_�_�F�� � ���-�-�-rCc���g}tj|j�d|j�d���}d}|D�]�}|j�d|j�d|��}	t	|��}|�d���r%t
|���r|j�d|j�d|��}	t|��5}t|�	���
��d��}t|�	���
��dd��}	ddd��n#1swxYwYt|	��}
t|t|��t|��|
|	��}|�
|����O#t$rd}Y��^wxYw��d#ttf$rd}Y��zt $r!}|jt"jkrYd}~����d}~wwxYw|r|���|S)	Nr�rzFr{z/fdinfo/rr�T)r�r}rvr�r�r�rrr�r�r�r�rrr�rr!r�r�r~r�)
rwrrr�rtr�rsr��posrwrvrrs
             rD�
open_fileszProcess.open_files&sj�����
��):�):�):�D�H�H�H�E�F�F���
��"	/�"	/�B�$(�$5�$5�$5�t�x�x�x���D�D� 
/���~�~���?�?�3�'�'�/�M�$�,?�,?�/��)�)�)�4�8�8�8�R�R�9�D�/�(��.�.�D�!�"%�a�j�j�l�l�&8�&8�&:�&:�1�&=�">�">�C�$'��
�
���(:�(:�(<�(<�Q�(?��$C�$C�E�D�D�D�D�D�D�D�D�D�D�D����D�D�D�D� 2�%�8�8��!*� �#�b�'�'�3�s�8�8�T�5�"B�"B�����v�.�.�.�.��-�*�*�*�&*�
�
�
�*������-&�'9�:�
�
�
�!�
����
�
�
��9���,�,��H�H�H�H������	
����6�	!���� � � ��s[�F�
E:�A4D�E:�D 	� E:�#D 	�$E:�:F
�	F
�G�%	G�.G
�	G
�
Grlc�n�t�||j��}|���|Sr�)r�r�r�r�)rwr�r�s   rD�connectionszProcess.connectionsRs0���#�#�D�$�(�3�3���������
rCc�d�ttj|j�d|j�d�����S)Nr�rz)r�r�r}rvr�r�s rD�num_fdszProcess.num_fdsXs.���2�:�D�,=�,=�,=�t�x�x�x�H�I�I�J�J�JrCc�P�t|���d��S)Nr}r�r�s rDr}zProcess.ppid\s!���4�(�(�*�*�6�2�3�3�3rCsUid:\t(\d+)\t(\d+)\t(\d+)c���|���}|�|��d\}}}tjt	|��t	|��t	|����Sr�)r�r�r�puidsr�)rw�_uids_rerz�real�	effective�saveds      rD�uidszProcess.uids`�X���%�%�'�'��!)�!1�!1�$�!7�!7��!:���i���}�S��Y�Y��I����E�
�
�C�C�CrCsGid:\t(\d+)\t(\d+)\t(\d+)c���|���}|�|��d\}}}tjt	|��t	|��t	|����Sr�)r�r�r�pgidsr�)rw�_gids_rerzr%r&r's      rD�gidszProcess.gidsfr)rCr��rl)8r?r@rAr��	__slots__rxr�r�rr�r�r�r�r�r�r�r�r�r�r�rsrK�getpidr�r r�r�r�r��	HAS_SMAPSr,r-r�r�r�r�r�r�r�r��HAS_CPU_AFFINITYr�rr	�HAS_PROC_IO_PRIORITYrrr�rr�rrr r}r(r-rBrCrDr�r�6sJ������'�'�C�C�C�I�.�.�.�9�9�9��������_��B�������_����$�$����_�$�
3�3�3�
5�5�5�
����_��5�5�5�"����_��0�)�)��_�)�
����_��
�w�~�~�m�i�b�i�k�k�1�2�2�E�	�	E�	E�
��	E�<�O�O��_�O��7�7��_�7��@�@�@��_�@��*�*��_�*��>�>��_�>�&�'�	�'�B�J�'?�@�@�"��
�#6�7�7�#���$8�9�9�	;�	;�	;�
��	;�	;�8'���D�	�A	�A	�
��A	�F�F�F��_�F��#-�2�:�.G�#H�#H�@�@�@��_�@��*4�"�*�5H�*I�*I�5�5�5��_�5�����_��6�0�0��_�0��7�7��_�7��!�	�	8�	8�
��	8�%�"�*�%H�I�I�	9�	9�	9�	9�
�	�	�
��	�&�B�	�	3�	3�
��	3�
�	B�	B�
��	B���	�	�	�	�
��	�2�.�.��_�.��)�)��_�)�V�����_��
�K�K��_�K��4�4��_�4��&�B�J�'D�E�E�D�D�D��_�D�
�&�B�J�'D�E�E�D�D�D��_�D�D�DrCr�r�r.)F)�r��
__future__rr�r0r�r�r6r�r,ror��sys�	tracebackrrrr�rrr	rr
r�rrr
rrrrrrrrrrrrrrr�_compatrrrr r!r"�version_infor�__extra__all__rUrsrKr0r1�hasattrr3r2rTr�r)r�getpagesizer�ror��	byteorderr�r�	AF_PACKETr;�IntEnumr�r:r&r'r(r)r>�globalsr��__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_PARKEDrr*r+r,r-r.r/r0r1r2r3r4r�r\rhrrrxrryr}rr�r�r�r�r�r�r�r��	Exception�	print_excr�r��resource�ImportErrorr��CDLLr�r1�dirr�r
rr r%r1rArHr[�net_if_addrsr`rbr�r�r�r��
disk_usagerrrArErbrerpr�rtr~r�r�rBrCrD�<module>rTsc
��
%�$�������
�
�
�
�����������������	�	�	�	�	�	�	�	�
�
�
�
�
�
�
�
�
�
�
�
���������#�#�#�#�#�#�"�"�"�"�"�"�������������#�#�#�#�#�#�)�)�)�)�)�)�!�!�!�!�!�!�������������$�$�$�$�$�$�"�"�"�"�"�"�������+�+�+�+�+�+�$�$�$�$�$�$�$�$�$�$�$�$�'�'�'�'�'�'�"�"�"�"�"�"� � � � � � �������(�(�(�(�(�(�'�'�'�'�'�'�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�������������&�&�&�&�&�&�$�$�$�$�$�$�'�'�'�'�'�'���������v����K�K�K�K��D�	6�	6�	6��".���G�N�N�+�i�b�i�k�k�9�:�:�	��w�t�%6�7�7���7�4�!8�9�9���6�8�8���b�j��&�&��!�:�!�#�#���	��'�B�B�4���
��)�
����<���G�G� �D�L��"+�S�S��1A�-B�-B�!C�E�E�M��#�G��<����O��O���������T�\�����G�I�I���Z�+�,�,�,�
�	�	�	 �	�	"�	�	�	�	$�	�	�	�	�	�	�	�	!�	�	�	�	�	�	�
�
�
�"�
"�
�
�
�
�
�
 �
�
 �
�
 �
�
�
�
!�
�
�
�
�
�
����*	�
��K�K�K�	L�	L���*�
�������
�J��<�<�<�
>�
>�	��z�&�>�?�?���:�j�$�,�1G�"G�H�H���
��J�J�J�K�K�
�

�J������-�*?�!@�!@�@�
B�
B�	��j��6�6�6�7�7��
�J�{�"�"�"�
#�
#�	����(
�
�
�$�$�$�&	�0�0�	��0�0!��
�
�
�
� K����!�!�!�!���K�K�K��I�����;�
�
�;�(:�;�;�C��c�J�J�I�I�I�K���� ��8� � � � � � � ���8�8�8��M�M�M��6�;�t�t�,�,�,�D��w�t�Y���8�	8�	8�	8�	8���8����<�����F�F�C�C��I�I�F�F�F�H�H�H�1�1�1�hwB�wB�wB�t2@�2@�2@�t
�
�
� ���(���:'�'�'�T=�=�=�*�7�>�>�;�<�<�3�
����=�>�>�3�����@�W�^�^�O�$�$��
�
�
�
�����&��	�	�	�	�	�I�	�	�	�g�g�g�g�g�g�g�g�T�{�}�}��'�'�'�'�
"�"�"�J���4�
 �
�\�\�\�\�~#�#�#�#�Vn�n�n�b���@V>�V>�V>�|���$3�3�3�&M�M�M�
!�!�!�@���,���*tD�tD�tD�tD�tD�f�tD�tD�tD�tD�tDs$�=M	�	+M7�6M7�=N�+N2�1N2

?>