+
     hP c                   sJ
   R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^R	IHt ^R
IHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIH t  ^RIH!t! ^RIH"t" ^RIH#t# ^RIH$t$ ^RIH%t% ^RIH&t& ^RIH't' ^RIH(t( ^RIH)t) ^RIH*t* ^RIH+t+ . R{Ot,]-! ]	R4      '       dX   ],P]                  ]/! ]4       U u. uF5  q Pa                  R4      '       g   K  V Pc                  4       '       g   K3  V NK7  	  up 4       Rt2]Pf                  Pi                  R ]Pj                  ! 4        R!24      t6]Pf                  Pi                  R ]Pj                  ! 4        R"24      t7]-! ]R#4      t8]-! ]R$4      t9]Pt                  ! R%4      t;]Px                  ! 4       t=Rs>]P~                  R&8H  t@R'tA]P                  ! R(R)]C! ]
P                  4      /4      tE]EP                  tF ! R* R+]P                  4      tG]H! 4       P                  ]GP                  4       R,]P                  R-]P                  R.]P                  R/]P                  R0]P                  R1]P                  R2]P                  R3]P                  R4]P                  R5]P                  R6]P                  R7]P                  /tVR8]P                  R9]P                  R:]P                  R;]P                  R<]P                  R=]P                  R>]P                  R?]P                  R@]P                  RA]P                  RB]P                  /tb]! RC. R|O4      tc]! RD. R}O4      td]! RE. R~O4      te]! RFRG4      tf]! RH]fP                  R,           4      th]! RI. RO4      ti]! RJRKRLP                  ]iP                  4      ,           4      tk]! RM. RO4      tl]! RN. RO4      tmRO tnRP toRQ tp]$RR 4       tq ]q! RS4       RX tuRY tvRZ twR[ txR\ tyR] tzR^ t{R_ t|R` t}]Pf                  Pi                  Ra4      '       g"   ]Pf                  Pi                  Rb4      '       d   Rc t~MRd t~]P                  t ! Re Rf]r4      t ! Rg Rh4      t]! 4       tRRi ltRj tRk t]EP                  tRRl lt ! Rm Rn4      tRRo ltRp tRq tRr tRs tRt tRu tRv tRw tRx t ! Ry Rz4      tR# u up i   ]r d)   ts] ! RT]s: 24       ]! RURV4      ! RWRWRW4      st RtsAsELRtsAsii ; i)zLinux platform implementation.N)defaultdict)
namedtuple)_common)_psposix)_psutil_linux)_psutil_posix)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prlimitZRLIMz/sys/class/power_supply/proc//smaps/smaps_rollupproc_ioprio_getproc_cpu_affinity_getZ
SC_CLK_TCKZlittlei   AddressFamilyAF_LINKc                   s&    ] tR t^kt^ t^t^t^tRtR# )
IOPriority N)	__name__
__module____qualname____firstlineno__IOPRIO_CLASS_NONEIOPRIO_CLASS_RTIOPRIO_CLASS_BEIOPRIO_CLASS_IDLE__static_attributes__r$       6/usr/lib64/python3.14/site-packages/psutil/_pslinux.pyr#   r#   k   s    OOr.   r#   ZRZSZDZTZtZZZXxZKZWZIZPZ01Z02Z03Z04Z05Z06Z07Z08Z09Z0AZ0Bsvmemsdiskio	popenfilepmemz"rss vms shared text lib data dirtypfullmempmmap_grouped	pmmap_extzaddr perms  pio	pcputimesc                s    \         P                  ! V 4      p V P                  R4      ^ ,          p V P                  R4      '       d   \	        V 4      '       g   V RR p V # )zWrapper around os.readlink(). 
 (deleted)N)osreadlinksplitendswithr   )path   &r/   r?   r?      sS     ;;tD ::fa D }}\""+=d+C+CDSzKr.   c                s|   \         P                  R\         P                  R\         P                  R/pW\         P                  \         P                  ,          \         P                  ,          ,          ,          pV \         P                  ,          '       d   VP                  RR^4      pVP                  RR4      pV# )zRConvert file's open() flags into a readable string.
Used by Process.open_files().
ZrZwzw+Zazr+)r>   ZO_RDONLYZO_WRONLYZO_RDWRZO_APPENDreplace)flagsZ	modes_mapmode   &  r/   file_flags_to_moderH      s{     c2;;RYYEIbkkBKK7"))CDEDr{{||Ca(<<d#DKr.   c                s    V P                  RR4      p RpV'       d   RV  2pMRV  R2p\        P                  ! V\        P                  4      # )zReturn 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.
/Z!Tz/sys/block/z/device)rD   r>   ZaccessZF_OK)nameZincluding_virtualrB   rG   r/   is_storage_devicerK      sL     <<S!DTF#TF'*99T277##r.   c                sz   \        V  R24      ;_uu_ 4       pVP                  4       P                  4       R,          pRRR4       . ROp\        X4      pV^8  d   VP	                  R4       V^	8  d   VP	                  R4       V^
8  d   VP	                  R4       \        RV4      sR#   + '       g   i     Lu; i)	zSet 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.
/stat:i   NNNZstealZguestZ
guest_nice	scputimes)userZnicesystemZidleiowaitZirqZsoftirq)r   readliner@   lenappendr   rM   )procfs_pathfvaluesfieldsZvlen   &    r/   set_scputimes_ntuplerY      s     
}E*	+	+q##%b) 
,KFv;Dqygqygrzl#;/I 
,	+s   &B**B:	/proczignoring exception on import: rM   zuser system idle        c                s   V R,          pWP                  R^ 4      ,           p V R,          pV R,          pV R,          p \	        \        4        R24      p^ pT;_uu_ 4        T FS  p	T	P                  4       p	T	P                  R	4      '       g   K,  T\        T	P                  4       ^,          4      ,          pKU  	  RRR4       T\        ,          pY,
          p
Y4,           pT\        T^,          T4      ,          pY,          p
Y\        TR
,          T4      ,
          ,          p
\        T
4      #   \         d,   p\        TP                  ^ ,           R24       Tu Rp?# Rp?ii ; i  \         d    Tu # i ; i  + '       g   i     L; i)a9  Fallback 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:s   Active(file):s   Inactive(file):   SReclaimable:zW is missing from /proc/meminfo; using an approximation for calculating available memoryNz	/zoneinfos   lowg       @)getKeyErrorr   argsr   r   OSErrorstrip
startswithintr@   PAGESIZEmin)memsfreefallbackZlru_active_fileZlru_inactive_fileZslab_reclaimableerrrU   Zwatermark_lowlineavailZ	pagecache   &           r/   calculate_avail_vmemro   !  sc   < Dhhz1--H	/0 !34 01?,-Y78 M	
D::<Dv&&TZZ\!_!55  

 XM E3IY]M22I	E	$4s$:M JJJEu:1  xx{m > >	
    
s@   D- E& !*E9+E9-E#8 EE#E#&E65E69F		c                 s   . p / p\        \        4        R24      ;_uu_ 4       pV F5  pVP                  4       p\        V^,          4      R,          W^ ,          &   K7  	  RRR4       VR,          pVR,          p VR,          p VR,          pWP                  R	^ 4      ,          p VR,          p	 TR,          p
 TR,          p TR,          pYV,
          T,
          T,
          pT^ 8  d	   YV,
          p TR,          pT^ 8X  d   \        T4      pT^ 8  d   ^ pT P                  R4       MY8  d   Tp\        Y^,
          T^R7      pT '       dQ   RP                  RP                  T 4      \        T 4      ^8X  d   RMR4      p\        P                  ! T\        ^R7       \        TTTTTT
TTTT	T4      #   + '       g   i     EL\; i  \         d    ^ pT P                  R4        ELdi ; i  \         d    ^ pT P                  R
4        ELgi ; i  \         d5     TR,          p	 ELy  \         d    ^ p	T P                  R4         ELi ; ii ; i  \         d    ^ p
T P                  R4        ELi ; i  \         dQ     TR,          TR,          ,           TR,          ,           p EL  \         d    ^ pT P                  R4         EL
i ; ii ; i  \         d    ^ p ELi ; i  \         d    \        T4      p ELi ; i)a  Report 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.
/meminfo   Ns	   MemTotal:r\   s   Buffers:buffersr]   r^   cacheds   Shmem:s
   MemShared:shareds   Active:actives	   Inactive:s   Inact_dirty:s   Inact_clean:s   Inact_laundry:inactives   Slab:s   MemAvailable:	availableZround_z6{} memory stats couldn't be determined and {} set to 0z, ZwasZwereZ
stacklevel)r   r   r@   re   r`   rS   r_   ro   r   ZformatjoinrR   warningswarnRuntimeWarningr1   )Zmissing_fieldsrh   rU   rl   rW   totalri   rr   rs   rt   ru   rv   slabusedrm   percentmsg                    r/   virtual_memoryr   `  s    ND	)*(3	4	4DZZ\F!&)nt3DO  
5 ED){#
0j! 	((+Q//,i(j!
.%H~ <& 7*Dax |
/%& A:
 ).Eqyk*	 U]U1=G FMMIIn%(A-E6
 	c>a8 Y 
5	4	4  )i()  (h'(  ,	,-(F 	,F!!(++	,,  (h'(  	.	._%'(()* 
  	.H!!*--	.	.  $  +$T*+s   <F2:	G 	G+ &	H 0	I :	I7 	K 3	K) 2G	G('G(+HHI	H((II
III43I47K%J++K	KKKK&%K&)LLc                 s   / p \        \        4        R24      ;_uu_ 4       pV F5  pVP                  4       p\        V^,          4      R,          W^ ,          &   K7  	  RRR4        V R,          pV R,          pWE,
          p\        W^R7      p	 \        \        4        R24      pT;_uu_ 4        R;rV F  pVP                  R4      '       d1   \        VP                  R	4      ^,          4      ^,          R,          p
MFVP                  R
4      '       d0   \        VP                  R	4      ^,          4      ^,          R,          pV
f   K  Vf   K   M-	  RpVR,          p\        P                  ! V\        ^R7       ^ ;rRRR4       \        P                  ! YHYYX
X4      #   + '       g   i     ELL; i  \         d0    \
        P                  ! 4       w     rdrWYG,          pYW,          p ELui ; i  + '       g   i     Lz; i  \         d1   pRT R2p\        P                  ! T\        ^R7       ^ ;r Rp?LRp?ii ; i)zReturn swap memory metrics.rp   rq   Ns
   SwapTotal:s	   SwapFree:rx   z/vmstats   pswpin    s   pswpoutz,'sin' and 'sout' swap memory stats couldn't zbe determined and were set to 0ry   zM'sin' and 'sout' swap memory stats couldn't be determined and were set to 0 (Z))r   r   r@   re   r`   cextZlinux_sysinfor   rd   r{   r|   r}   rb   r   Zsswap)rh   rU   rl   rW   r~   ri   _Zunit_multiplierr   r   ZsinZsoutr   rk   s                 r/   swap_memoryr     s   D	)*(3	4	4DZZ\F!&)nt3DO  
5 ]#L! <DD2G?,-W56 QC ??9--djj.q12Q6=C__Z00tzz$/23a7$>D?t'7  E88c>a@% & ==dS$??c 
5	4	4   373E3E3G01a4  & Q  003uA7 	 	c>a8dsT   <F &F4 H .A&G10G1
G1/G1 F1	46G.-G.1H	H?&H::H?c                 sx   \        4       p \        V 4       \        V  R24      ;_uu_ 4       pVP                  4       P	                  4       pRRR4       X^\        \        P                  4      ^,            pV Uu. uF  p\        V4      \        ,          NK  	  pp\        V!  #   + '       g   i     La; iu upi )zReturn 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.
rL   N)
r   rY   r   rQ   r@   rR   rM   _fieldsfloatCLOCK_TICKS)rT   rU   rV   rW   r0           r/   	cpu_timesr   !  s     "#K%	}E*	+	+q##% 
,AI--.23F.45feAh$$fF5f	 
,	+ 6s   B$:B7$B4	c            	     s   \        4       p \        V 4       . p\        V  R24      ;_uu_ 4       pVP                  4        V F  pVP	                  R4      '       g   K  VP                  4       pV^\        \        P                  4      ^,            pV Uu. uF  p\        V4      \        ,          NK  	  pp\        V!  pVP                  V4       K  	  VuuRRR4       # u upi   + '       g   i     R# ; i)z^Return a list of namedtuple representing the CPU times
for every CPU available on the system.
rL   s   cpuN)r   rY   r   rQ   rd   r@   rR   rM   r   r   r   rS   )rT   cpusrU   rl   rV   rW   r0   entry           r/   per_cpu_timesr   1  s     "#K%D	}E*	+	+q	

Dv&&C	(9(9$:Q$>?:@A&Q%([00&A!6*E"   
,	+ B 
,	+	+s#   *C$7C$C
3!C$C$$C5	c                 s    \         P                  ! R4      #   \         Ed!    ^ p \        \	        4        R24      ;_uu_ 4       pT F3  pTP                  4       P                  R4      '       g   K*  T ^,          p K5  	  RRR4       M  + '       g   i     M; iT ^ 8X  d   \        P                  ! R4      p\        \	        4        R24      ;_uu_ 4       pT F=  pTP                  R4      ^ ,          pTP                  T4      '       g   K4  T ^,          p K?  	  RRR4       M  + '       g   i     M; iT ^ 8X  d    R# T u # i ; i)z0Return the number of logical CPUs in the system.ZSC_NPROCESSORS_ONLN/cpuinfos	   processorNzcpu\drL   r8   )r>   sysconf
ValueErrorr   r   lowerrd   recompiler   r@   match)ZnumrU   rl   searchs       r/   cpu_count_logicalr   E  s    zz/00 O-.h788A::<**<881HC  9888 !8ZZ)Fo/06771D::c?1-D||D))q  8777 !8
-sR    ,E(B1B>	EBAE2D"D"	E"D2-E?EEc                 s`   \        4       p RpRp\        P                  ! V4      ;'       g    \        P                  ! V4       FL  p\        V4      ;_uu_ 4       pV P                  VP	                  4       P                  4       4       RRR4       KN  	  \        V 4      pV^ 8w  d   V# / p/ p\        \        4        R24      ;_uu_ 4       pV Fz  pVP                  4       P                  4       pV'       g    VR,          WgR,          &   / pK@  VP                  R4      '       g   KY  VP                  R^4      w  r\        V
4      Wy&   K|  	  RRR4       \        VP                  4       4      pT;'       g    R#   + '       g   i     EKF  ; i  \         d     Li ; i  + '       g   i     L[; i)	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_listNr   	   cpu cores   physical ids   	:)r   r   )setglobr   addreadrc   rR   r   r   r`   rd   r@   re   sumrV   )lsZp1Zp2rB   rU   ZresultZmappingZcurrent_inforl   keyvalue              r/   cpu_count_coresr   b  sb    
B 
EB	JB		"..2.!FF1668>>#$  / WF{ GL	)*(3	4	4D::<%%'D<H$=G89
  "!?@@!ZZ2
$'J!  
5" !"F>>T7 $    
5	4sB   .E7	,F6FF%%F7F	F	FF	FF-	c                 s<   \        \        4        R24      ;_uu_ 4       p RpRpRpV  F  pVP                  R4      '       d"   \        VP	                  4       ^,          4      pMoVP                  R4      '       d"   \        VP	                  4       ^,          4      pM7VP                  R4      '       d!   \        VP	                  4       ^,          4      pVf   K  Vf   K  Vf   K   M	  RRR4       ^ p\
        P                  ! XXXV4      #   + '       g   i     L+; i)z*Return various CPU stats as a named tuple.rL   Ns   ctxts   intrs   softirq)r   r   rd   re   r@   r   Z	scpustats)rU   Zctx_switchesZ
interruptsZsoft_interruptsrl   Zsyscallss         r/   	cpu_statsr     s    	)*%0	1	1Q
Dw''"4::<?3)) a1
,,"%djjl1o"6(#/* 	 
2" Hj/8 % 
2	1s*   AD:7D2!DDD$DD	c                 s8   \        \        4        R24      ;_uu_ 4       p V  Uu. uFL  pVP                  4       P                  R4      '       g   K*  \	        VP                  R^4      ^,          4      NKN  	  upuuRRR4       # u upi   + '       g   i     R# ; i)z7Return current CPU frequency from cpuinfo if available.r   s   cpu mhz   :N)r   r   r   rd   r   r@   )rU   rl        r/   _cpu_get_cpuinfo_freqr     s{    	)*(3	4	4 
zz|&&z2 *E$**T1%a()
 
5	4
 
5	4	4s"   B'B&B6BBB	z'/sys/devices/system/cpu/cpufreq/policy0z$/sys/devices/system/cpu/cpu0/cpufreqc            	     sR   \        4       p \        P                  ! R4      ;'       g    \        P                  ! R4      pVP                  R R7       . p\        P                  P
                  p\        V4       EF)  w  rE\        V4      \        V 4      8X  d   W,          R,          pM\        V! VR4      RR7      pVfg   \        V! VR	4      RR7      pVfO   R
V R2p\        VRR7      R8X  d*   VP                  \        P                  ! RRR4      4       K  Rp\        V4      h\        V4      R,          p\        \        V! VR4      4      4      R,          p	\        \        V! VR4      4      4      R,          p
VP                  \        P                  ! WjV	4      4       EK,  	  V# )zjReturn 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]*/cpufreqc                 s^    \        \        P                  ! R V 4      P                  4       4      # )z[0-9]+)re   r   r   Zgroupr0   rC   r/   Z<lambda>Zcpu_freq.<locals>.<lambda>  s    RYYy!%<%B%B%D!Er.   )r   i  Zscaling_cur_freqNrj   Zcpuinfo_cur_freqz/sys/devices/system/cpu/cpuz/onlinez0
r[   z!can't find current frequency fileZscaling_max_freqZscaling_min_freq)r   r   sortr>   rB   rz   	enumeraterR   r   r   rS   r   scpufreqNotImplementedErrorre   )Zcpuinfo_freqspathsretZpjoinZirB   ZcurrZonline_pathr   Zmax_Zmin_r   r/   cpu_freqr     sr   
 ./		:
 D DYYBC 	 	

E
F 'GA5zS// %'$.E$(:;dK| E$(:;dK<$?s'"JK;6%?

7#3#3Cc#BC =C-c22t9t#DtE$(:;<=DDtE$(:;<=DDJJw''D9:- (. 
r.   c                 sl    \        4        U u. uF  p \        P                  ! V RR4      NK  	  up # u up i )zmAlternate implementation using /proc/cpuinfo.
min and max frequencies are not available and are set to None.
r[   )r   r   r   r   r   r/   r   r     s1     8M7NO7N!  C-7NOOOs   !1c                   s    ] tR tRtRtR# )_Ipv6UnsupportedErrori  r$   N)r%   r&   r'   r(   r-   r$   r.   r/   r   r     s    r.   r   c                   sx   a  ] tR tRt o RtR tR tR t]R 4       t	]RR l4       t
]RR	 l4       tRR
 ltRtV tR# )NetConnectionsi  a[  A 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                s   R \         P                  \         P                  3pR\         P                  \         P                  3pR\         P                  \         P                  3pR\         P                  \         P                  3pR\         P
                  R3pRWW4V3R W3RV3RV3RW43RV3RV3RV3R	WW43R
W3RW$3/V n        RV n        R# )Ztcptcp6Zudpudp6unixNalltcp4udp4inetZinet4Zinet6)socketAF_INETSOCK_STREAMAF_INET6Z
SOCK_DGRAMZAF_UNIXtmap_procfs_path)selfr   r   r   r   r      &     r/   __init__ZNetConnections.__init__  s     v~~v'9'9:););<v~~v'8'89):):;-DD1D<TGTGD<TGTGTGT,d\d\
	 !r.   c                s@   \        \        4      p\        P                  ! V P                   R V R24       Fh  p \        V P                   R V RV 24      pVP                  R4      '       d1   VR,          RR pW$,          P                  V\        V4      34       Kh  Kj  	  V#   \        \        3 d     K  \         d\   pTP                  \        P                  8X  d    Rp?K  TP                  \        P                  8X  d   \        T4        Rp?K  h Rp?ii ; i)rI   /fd/fd/zsocket:[:i   NNN)r    listr>   listdirr   r?   rd   rS   re   FileNotFoundErrorProcessLookupErrorrb   errnoEINVALENAMETOOLONGr   )r   pidinodesfdinoderk      &&    r/   get_proc_inodesZNetConnections.get_proc_inodes  s    T"** 1 12!C5<=B9 D$5$5#6auD!EF  ##J//!"IcrNEM((#s2w8 0% >, ' &'9:   99,99 2 22#Js/   B$$D8DDD'*DDDc                s    / p\        4        F$  p VP                  V P                  V4      4       K&  	  V#   \        \        \
        3 d     KC  i ; iN)pidsupdater   r   r   PermissionError)r   r   r   rG   r/   get_all_inodesZNetConnections.get_all_inodes*  sT    6C
d22378   &'9?K  s    7AAc           
     s   V P                  R4      w  r#\        V^4      pV'       g   R# VP                  R4      pV\        P                  8X  do   \
        '       d7   \        P                  ! V\        P                  ! V4      RRR1,          4      pM\        P                  ! V\        P                  ! V4      4      pM\        P                  ! V4      p \
        '       dR   \        P                  ! \        P                  \        P                  ! R.\        P                  ! RV4      O5!  4      pMQ\        P                  ! \        P                  \        P                  ! R.\        P                  ! RV4      O5!  4      p \         P"                  ! W#4      #   \         d    \        4       '       g   \        Rhh i ; i)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
:ZasciiNz>4Iz<4Ir$   r   )r@   re   encoder   r   LITTLE_ENDIANZ	inet_ntopbase64Z	b16decoder   structZpackZunpackr   r   r   r   addr)r   familyZipZport   &&  r/   decode_addressZNetConnections.decode_address:  s@   " ::c?4} IYYwV^^#}%%ff.>.>r.B4R4.HI%%ff.>.>r.BC!!"%B =))EEFMM%,DEB
  ))EEFMM%,DEB ||B%%  $/T9	s   F !AF 2AF $F=Nc              #  s   "   V P                  R4      '       d(   \        P                  P                  V 4      '       g   R# \	        V 4      ;_uu_ 4       pVP                  4        \        V^4       F  w  rg VP                  4       R,          w
  rr    rY9   d   Y<,          ^ ,          w  rMRRrTe	   YN8w  d   KL  T\        P                  8X  d   \        T,          pM\        P                  p \        P!                  Y4      p	\        P!                  Y4      p
YY)YT3x  K  	  RRR4       R#   \         d    RT  RT RT: 2p\        T4      Rhi ; i  \"         d     K  i ; i  + '       g   i     R# ; i5i)z.Parse /proc/net/tcp* and /proc/net/udp* files.Z6NNi
   Nerror while parsing ; malformed line r8   r   )rA   r>   rB   existsr   rQ   r   r@   r   RuntimeErrorr   r   TCP_STATUSESr   	CONN_NONEr   r   r   )filer   type_r   
filter_pidrU   Zlinenorl   r   laddrraddrstatusr   r   r   r   s   &&&&&           r/   process_inetZNetConnections.process_inetm  se     ==bggnnT&:&:t__JJL )!Q	6

S) BAeQ1a ? %mA.GC"B)j.? 2 22!-f!5!(!2!2! . = =e L . = =e L uUCHHC !0 _ " 6.tf 5"81TH.  's+564 1 ! !C __s_   <E>E>"E*7D1AE*1*EE*'
E>1$E	E*E'	#E*&E'	'E**E;	5	E>c              #  s6  "   \        V 4      ;_uu_ 4       pVP                  4        V F  pVP                  4       p VR,          w     rxryY9   d
   Y),          pMR.pT Ff  w  rTe	   Y<8w  d   K  \        T4      ^8X  d
   TR,          MRp\        P                  ! \        T4      4      pRp\        P                  pYYTTT3x  Kh  	  K  	  RRR4       R#   \         d     RT9  d    K  RT  RT: 2p
\	        T
4      hi ; i  + '       g   i     R# ; i5i)	zParse /proc/net/unix files.:       Nr8   r   r   N r   )Nr   )
r   rQ   r@   r   r   rR   r   Zsocktype_to_enumre   r   )r   r   r   r   rU   rl   Ztokensr   r   r   r   Zpairsr   r   rB   r   r   s   &&&&             r/   process_unixZNetConnections.process_unix  s     t__JJL	,28+/Aq!Qq ? #ME'LE$GC!-*2C -0[A-=vbz2 ' 8 8U D !#!(!2!2!5vsKK  %%  _ " ,$ .tf4EdXN  's++, __s@   D&DCBD
DD	*D-D	DD		Dc                sR   \        4       V n        Ve   V P                  V4      pV'       g   . # MV P                  4       p\	        4       pV P
                  V,           F  w  rVpV P                   RV 2pV\        P                  \        P                  09   d   V P                  WWsVR7      p	MV P                  WW2R7      p	V	 FS  w  rr{rpV'       d   \        P                  ! WW{W4      pM\        P                  ! WW{WV4      pVP                  V4       KU  	  K  	  \        V4      # )Nz/net/)r   )r   r   r   r   r   r   r   r   r   r   r   r   ZpconnZsconnr   r   )r   kindr   r   r   Z
proto_namer   r   rB   r   r   r   r   r   Z	bound_pidZconns   &&&             r/   retrieveZNetConnections.retrieve  s   +-?))#.F	  ((*Fe)-4%J''(j\:D&..&//::&&%C '  &&tV&LFHBE%"==E%D #==E%D  GI *9$ Cyr.   )r   r   r   )r%   r&   r'   r(   __doc__r   r   r   Zstaticmethodr   r   r   r   r-   __classdictcell__Z__classdict__   @r/   r   r     sf     	!.4  0& 0&d (I (IT !L !LF r.   r   c                s,    \         P                  V 4      # )z$Return system-wide open connections.)_net_connectionsr   )r   rC   r/   net_connectionsr     s    $$T**r.   c                 s   \        \        4        R24      ;_uu_ 4       p V P                  4       pRRR4       / pXR,           F{  pVP                  R4      pVRV P	                  4       pW4^,           R P	                  4       P                  4       p\        \        V4      w  ppp	p
ppppppppppppVVVVV	VV
V3W%&   K}  	  V#   + '       g   i     L; i)zkReturn network I/O statistics for every network interface
installed on the system as a dict of raw tuples.
z/net/devNi   NNr   )r   r   	readlinesrfindrc   r@   mapre   )rU   linesretdictrl   ZcolonrJ   rW   Z
bytes_recvZpackets_recvZerrinZdropinZ_fifoinZ_frameinZ_compressedinZ_multicastinZ
bytes_sentZpackets_sentZerroutZdropoutZ_fifooutZ_collisionsoutZ_carrieroutZ_compressedouts                          r/   net_io_countersr    s     
o'(1	2	2a 
3Gb		

3FU|!!#aik"((*002* V'	
 	
7 J NQ 
3	2s   CC	c                 sH   \         P                  \        \         P                  \        \         P
                  \        /p \        4       P                  4       p/ pV F  p \        P                  ! V4      p\        P                  ! V4      p\         P                  ! V4      w  rgRP                  V4      pRV9   p	\        P                  ! WV,          WtV4      W#&   K  	  V#   \          d7   p
T
P"                  \"        P$                  8w  d   h \'        T
4        Rp
?
K  Rp
?
ii ; i)z)Get NIC stats (isup, duplex, speed, mtu).Z,ZrunningN)r   ZDUPLEX_FULLr   ZDUPLEX_HALFr   ZDUPLEX_UNKNOWNr	   r  Zkeys
cext_posixZ
net_if_mtuZnet_if_flagsZnet_if_duplex_speedrz   r   Z	snicstatsrb   r   ZENODEVr   )Z
duplex_mapZnamesr   rJ   ZmturE   ZduplexZspeedZoutput_flagsZisuprk   r   r/   net_if_statsr    s     	///J
 ""$E
C	''-C++D1E 44T:MF 88E?L%D))(%lCI   J  	yyELL(#JJ		s   AC  D!++DD!c                s   R pR p\         P                  P                  \        4        R24      '       d	   V! 4       pME\         P                  P                  R4      '       d	   V! 4       pM\        4        R2p\	        V4      h/ pV FJ  pVw
  rxrrrppV '       g   \        V4      '       g   K'  V
\        ,          p
V\        ,          pWWWWV3	WW&   KL  	  V# )z[Return disk I/O statistics for every disk installed on the
system as a dict of raw tuples.
c               3   sv  "   \        \        4        R 24      ;_uu_ 4       p V P                  4       pRRR4       X F  pVP                  4       p\	        V4      pV^8X  d;   V^,          p\        V^,          4      p\        \
        VR,          4      w
  rxrprrpM{V^8X  g   V^8  d)   V^,          p\        \
        VR,          4      w  rgrrrrpMEV^8X  d.   V^,          p\        \
        VR,          4      w  rhr^ ;p	;p;p;rMRV: 2p\        V4      hWVWWVW{V3
x  K  	  R#   + '       g   i     L; i5i)
/diskstatsN:i      N:   r  N:r	  NNznot sure how to interpret line )r   r   r   r@   rR   re   r  r   )rU   r  rl   rW   ZflenrJ   readsreads_mergedrbytesrtimewriteswrites_mergedwbyteswtimer   	busy_timer   r   r/   read_procfsZ%disk_io_counters.<locals>.read_procfs;  s4    " /+,J788AKKME 9DZZ\Fv;DrzayF1I69#vd|6L4um1trzay69#vd|6L4fV1ay03C0D-vKLLLLL}y7x@ o%u	; ;/  98s   D9D&C4D9&D6	1D9c               3   sR  "   \         P                  ! R 4       F  p \         P                  ! \         P                  P	                  R V 4      4       F  w  rpRV9  d   K  \        \         P                  P	                  VR4      4      ;_uu_ 4       pVP                  4       P                  4       P                  4       pRRR4       \         P                  P                  V4      p\        \        XR,          4      w
  rxrrrr/WgWWWW3
x  K  	  K  	  R#   + '       g   i     L_; i5i)
/sys/blockstatNr   )r>   r   ZwalkrB   rz   r   r   rc   r@   basenamer  re   )Zblockrootr   filesrU   rW   rJ   r
  r  r  r  r  r  r  r  r  s                   r/   
read_sysfsZ$disk_io_counters.<locals>.read_sysfsi  s     ZZ-E"$''"'',,|U*K"L&rww||D&9::aVVX^^-335F ;ww''- 47sF3K3H1fV1FFMF F #M . ;:s   BD'-D	=AD'D$D'r  r  z6/diskstats nor /sys/block are available on this system)r>   rB   r   r   r   rK   DISK_SECTOR_SIZE)Zperdiskr  r  Zgenr   r  r   rJ   r
  r  r  r  r  r  r  r  r  s   &                r/   disk_io_countersr  6  s    
+;\F 
ww~~*+:677m		%	%l  ! "  	 "#&&G ).	&ffU9066 """"%iA) 0 Nr.   c                   sJ   a  ] tR tRt o RtRR.tR tR tR tR t	R	 t
R
tV tR# )RootFsDeviceFinderi  a2  disk_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minorc                s    \         P                  ! R 4      P                  p\         P                  ! V4      V n        \         P                  ! V4      V n        R# )rI   N)r>   r  Zst_devr  r  )r   Zdev   & r/   r   ZRootFsDeviceFinder.__init__  s3    ggcl!!XXc]
XXc]
r.   c                sL   \        \        4        R 24      ;_uu_ 4       pVP                  4       R,           F  pVP                  4       p\	        V4      ^8  d   K%  V^ ,          P                  4       '       d   \        V^ ,          4      MRpV^,          P                  4       '       d   \        V^,          4      MRpV^,          pW@P                  8X  g   K  WPP                  8X  g   K  V'       g   K  RV 2u uuRRR4       # 	  RRR4       R#   + '       g   i     R# ; i)z/partitionsr   N/dev/)	r   r   r   r@   rR   isdigitre   r  r  )r   rU   rl   rW   r  r  rJ      &      r/   ask_proc_partitionsZ&RootFsDeviceFinder.ask_proc_partitions  s    /+,K899Qb))v;?*0)*;*;*=*=F1I4*0)*;*;*=*=F1I4ayJJ&5JJ+>t!&tf~- :9) :999s0   AD90D**DD+D5DDD#	c                sb   R V P                    RV P                   R2p\        V4      ;_uu_ 4       pV F[  pVP                  R4      '       g   K  VP	                  4       P                  R4      ^,          pV'       g   KL  RV 2u uuRRR4       # 	  RRR4       R#   + '       g   i     R# ; i)z/sys/dev/block/r   z/ueventzDEVNAME=r   N)r  r  r   rd   rc   Z
rpartition)r   rB   rU   rl   rJ   rX   r/   ask_sys_dev_blockZ$RootFsDeviceFinder.ask_sys_dev_block  s     Adjj\At__??:..::<22:>qADt!&tf~- _ ___s   B+B BBB.	c                s   V P                    R V P                   2p\        P                  ! R4      pV F  p \	        V4      pT;_uu_ 4        VP                  4       P                  4       pWQ8X  dN   \        P                  P                  \        P                  P                  V4      4      pRV 2uuRRR4       u #  RRR4       K  	  R#   + '       g   i     K  ; i  \         d     K  i ; i)r   z/sys/class/block/*/devr   N)r  r  r   Ziglobr   r   rc   r>   rB   r  dirnamer   )r   Zneedler  r   rU   datarJ   r"  r/   ask_sys_class_blockZ&RootFsDeviceFinder.ask_sys_class_block  s    JJ<q-

34D	.dO Q668>>+D~!ww//0EF!&tf~	 Q% Q  QQ % s   C"A%CC"C10C1c                s   R pVf    V P                  4       pVf    V P                  4       pVf    V P	                  4       pVe*   \
        P                  P                  V4      '       d   V# R # R #   \         d   p\        T4        R p?LtR p?ii ; i  \         d   p\        T4        R p?LR p?ii ; i  \         d   p\        T4        R p?LR p?ii ; ir   )r#  rb   r   r$  r'  r>   rB   r   )r   rB   rk   rG   r/   findZRootFsDeviceFinder.find  s    <//1 <--/ <//1
 t 4 4K !5  c


  c


  c

sE   A1 B B7 1B<BBB4B//B47CCC)r  r  N)r%   r&   r'   r(   r   	__slots__r   r#  r$  r'  r(  r-   r   r   r   r/   r  r    s4      '"I#
... r.   r  c                s   \        4       p\        4       pV '       g   \        V R24      ;_uu_ 4       pV F}  pVP                  4       pVP	                  R4      '       g"   VP                  VP                  4       4       KK  VP                  R4      ^,          pVR8X  g   Kl  VP                  R4       K  	  RRR4       VR8X  dF   \        P                  P                  R4      '       d!   \        P                  P                  R4      pM"\        P                  P                  V R24      p. p\        P                  ! V4      pV Fz  p	V	w  rr\V
R	8X  d   R
p
V
R9   d#   \        4       P                  4       ;'       g    T
p
V '       g   V
'       d   WQ9  d   KR  \        P                   ! WW\4      pVP#                  V4       K|  	  V#   + '       g   i     EL; i)z8Return mounted disk partitions as a list of namedtuples.z/filesystemsZnodevZ	ZzfsNrZ   z	/etc/mtabz/self/mountsZnoner   >   Zrootfsz	/dev/root)r   r   r   rc   rd   r   r@   r>   rB   ZisfileZrealpathr   disk_partitionsr  r(  r   Z	sdiskpartrS   )r   ZfstypesrT   rU   rl   ZfstypeZmounts_pathretlistZ
partitionsZ	partitionZdeviceZ
mountpointZoptsntuples   &             r/   r*  r*    sm   eG!#K+l344zz|w//KK

- "ZZ-a0FE*  5 g"''.."="=gg&&{3gg&&+l'CDG%%k2J	+4(FVF,,')..0::FFV2""6vDv   N? 544s   A*G"GG	c            	     s	   \         P                  ! \        4      p \        P                  ! R4      pVP	                  \        P                  ! R4      4       \        V Uu0 uF  q"P                  R4      ^ ,          kK  	  up4      p\        P                  ! R4      p\        P                  ! R4      pV F.  pVP                  RV4      pWa9  g   K  VP                  V4       K0  	  V EF  p VR,           p\        \        V4      4      R,          p	\        P                  P                  \        P                  P!                  V4      R	4      p\#        V4      P%                  4       p
\        TR
,           RR7      p\        TR,           RR7      p\#        TR,           RR7      P%                  4       pTe    \        T4      R,          pTe    \        T4      R,          pY
,          P                  YY34       EK  	  V'       Eg'   \        P                  ! R4      p\        \+        V4      4      pV EF  p \        P                  P                  VR4      p\        \        V4      4      R,          p	\        P                  P                  VR4      p\#        V4      P%                  4       p
\        P                  ! TR,           4      pT Uu0 uFG  pRP                  \        P                  P/                  T4      P                  R4      R,          4      kKI  	  ppRpRpT F  p\        P                  P                  TTR,           4      p\#        TRR7      P%                  4       pTR8X  d4   \        \        P                  P                  TTR,           4      RR7      pM9TR8X  d3   \        \        P                  P                  TTR,           4      RR7      pTe    \        T4      R,          pTf   K   \        T4      R,          pK  	  Y
,          P                  RYT34       EK  	  \1        V 4      # u upi   \&        \(        3 d     EKi  i ; i  \(         d    Rp ELi ; i  \(         d    Rp ELi ; i  \&        \(        3 d   p\-        T4        Rp?EKn  Rp?ii ; iu upi   \(         d    Rp Li ; i  \(         d    Rp EK  i ; i)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*_*r   z5/sys/devices/platform/coretemp.*/hwmon/hwmon*/temp*_*z'/sys/devices/platform/coretemp.*/hwmon/z/sys/class/hwmon/_inputg     @@rJ   Z_maxNr   Z_crit_labelr   z /sys/class/thermal/thermal_zone*ZtempZtypez/trip_point*:r   r	  NZ_typecriticalZ_temphigh)collectionsr    r   r   extendsortedr@   r   r   ZsubrS   r   r   r>   rB   rz   r%  r   rc   rb   r   r   r   r  dict)r   	basenamesr0   Z
basenames2ZreplrJ   ZaltnamebaserB   current	unit_namer0  r/  labelrk   Z
trip_pathsZpZtrip_pointsZ
trip_pointZ	trip_types                       r/   sensors_temperaturesr:    s    
!
!$
'C		;<I TYYGHI;AQ;<I ?J ::@AD((.5#T" 
 	(?DDJ'&0G77<< 5v>DD	)I D6MD1w6D8Ob1779T{V+   ?V3 	ut>?A F 9II@A	3y>*	Dww||D&1T
+f4ww||D&1IOO-	
 4.#89J $#A ))!,2237<=#   HD)
ww||D*w*>?r288:	
*#T:+?@4 H &(T:+?@4D #$$T{V3 '(#(?V#;' *. N!!2wh"?@Q T 9A <* $ 		 		$  
      Z( c

* & $#$
 & (#'(s    P7-A:P<6QQ)7A4Q=AR(R-7S <QQQ&%Q&)Q:9Q:=R%R  R%-R=<R= SSc                 s   \         P                  ! \        4      p \        P                  ! R4      pV'       g   \        P                  ! R4      p\	        V Uu0 uF  q"P                  R4      ^ ,          kK  	  up4      pV F  p \        \        VR,           4      4      p\        \        P                  P                  \        P                  P                  T4      R4      4      P                  4       p\        TR,           RR	7      P                  4       pY,          P!                  \"        P$                  ! Yt4      4       K  	  \'        V 4      # u upi   \         d   p\        T4        Rp?K  Rp?ii ; i)
ak  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*_*r   r-  NrJ   r.  r   r   )r1  r    r   r   r3  r@   re   r   rb   r   r   r>   rB   rz   r%  rc   rS   r   Zsfanr4  )r   r5  r0   r6  r7  rk   r8  r9  r   r/   sensors_fansr;    s    
!
!$
'C		:;I IIEF	;AQ;<I	$th/0G RWW__T%:FCDJJL	D8Ob1779gll5:;  9 <  	#J	s    EEE6 E11E6c                 s4  a \        4       oV3R lp \        P                  ! \        4       Uu. uF3  pVP	                  R4      '       g   RVP                  4       9   g   K1  VNK5  	  ppV'       g   R# \        P                  P                  \        \        V4      4      pV ! VR,           VR,           4      pV ! VR,           VR,           4      pV ! VR	,           VR
,           4      pV ! VR,           4      pVe   Ve    RV,          V,          pM&\        \        VR,           RR7      4      pVR8X  d   R# Rp	V ! \        P                  P                  \        R4      \        P                  P                  \        R4      4      p
V
e   V
^8H  p	MC\        VR,           RR7      P                  4       P                  4       pVR8X  d   Rp	M	VR9   d   Rp	V	'       d   \        P                  pM`Ve   Ve    \        WE,          R,          4      pM>Ve+   \        V^<,          4      pV^ 8  d   \        P                  pM\        P                  p\        P                   ! WV	4      # u upi   \         d    Rp ELAi ; i  \         d    \        P                  p LMi ; i)zReturn 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                 s   < V  F%  p\        VSR7      pVS8w  g   K   \        V4      u # 	  R#   \         d    TP                  4       u u # i ; i)zfAttempt to read the content of multiple files which may
not exist. If none of them exist return None.
r   N)r   re   r   rc   )r   rB   r   nulls   *  r/   
multi_bcatZ#sensors_battery.<locals>.multi_bcat  sR     Dtd+Cd{'s8O	   " '99;&'s   
/AAZBATZbatteryNz/energy_nowz/charge_nowz
/power_nowz/current_nowz/energy_fullz/charge_fullz/time_to_empty_nowg      Y@r[   z	/capacityr   z
AC0/onlinez	AC/online/statusr   ZdischargingFTi  r   >   ZfullZcharging)Zobjectr>   r   POWER_SUPPLY_PATHrd   r   rB   rz   rg   ZZeroDivisionErrorre   r   rc   r   ZPOWER_TIME_UNLIMITEDZPOWER_TIME_UNKNOWNZsbattery)r=  r0   Zbatsr  Z
energy_nowZ	power_nowZenergy_fullZtime_to_emptyr   Zpower_pluggedZonliner   Zsecsleftr<  s                @r/   sensors_batteryr@    sM    8D -..A<<)qwwy"8 	
. 	 
  77<<)3t95D D=0$2FGJ4,.~0EFITN2D>4IJKt&::;M :#9	j(;6G c$,r:;b=
 M
&5
&4F !TI%399;AAC]"!M++ M //		I$9	2:1D89H 
	"}r)*a<11H--G}==C. ! 	G	B ! 	211H	2s5   I 
I !I =I% 2I9 %I65I69JJc                 s    . p \         P                  ! 4       pV F<  pVw  r4rVp\        P                  ! Y4;'       g    RWVV4      pV P	                  V4       K>  	  V # )z:Return currently connected users as a list of namedtuples.N)r   usersr   ZsuserrS   )	r+  ZrawlistitemrN   ZttyZhostnameZtstampr   Znts	            r/   rA  rA  
  sS    GjjlG+/(8S]]4hDr  Nr.   c                 sH   \        4        R2p \        V 4      ;_uu_ 4       pV FX  pVP                  R4      '       g   K  \        VP	                  4       P                  4       ^,          4      pVsVu uuRRR4       # 	  RV  2p\        V4      h  + '       g   i     R# ; i)zAReturn the system boot time expressed in seconds since the epoch.rL   s   btimeNzline 'btime' not found in )r   r   rd   r   rc   r@   	BOOT_TIMEr   )rB   rU   rl   r   r   r   r/   	boot_timerD    s      &D	T		aDx((DJJL..034	
 
	
 +4&13 
		s   B 3B>BB!	c                 s    \        4       P                  \        4      p \        P                  ! V 4       Uu. uF%  qP                  4       '       g   K  \        V4      NK'  	  up# u upi )z7Returns a list of PIDs currently running on the system.)r   r   r   r>   r   r!  re   )rB   r0   r   r/   r   r   (  sD    ##H-DJJt,<,q		FCF,<<<s   A$A$c                s   \         P                  ! V 4      '       g   R#  \        4        RV  R2p\        V4      ;_uu_ 4       pV FJ  pVP	                  R4      '       g   K  \        VP                  4       ^,          4      pW@8H  u uuRRR4       # 	  RV 2p\        V4      h  + '       g   i     R# ; i  \        \        3 d    T \        4       9   u # i ; i)z[Check for the existence of a unix PID. Linux TIDs are not
supported (always return False).
FrI   r>  s   Tgid:Nz'Tgid' line not found in )
r   
pid_existsr   r   rd   re   r@   r   rb   r   )r   rB   rU   rl   Ztgidr   r   r/   rE  rE  .  s     s##	! &'(#g6DT""aDx00"4::<?3  ${* #" 2$8 o% #"" $ 	!$&= 	!s;   #B8 B$"%B$
B8 B$$B5	/B8 5B8 8CCc                 s|   / p \        4       p\        4        Fv  p \        V RV R24      ;_uu_ 4       pVP                  4       pRRR4       XP	                  R4      pWE^,           R P                  4       p\        V^,          4      pWpV&   Kx  	  V #   + '       g   i     LV; i  \        \        3 d     K  i ; i)zkObtain a {pid: ppid, ...} dict for all running processes in
one shot. Used to speed up Process.children().
rI   rL   N   ))	r   r   r   r   r   r@   re   r   r   )r   rT   r   rU   r&  rparZdsetppidr   r/   ppid_maprI  O  s     C!#Kv	}AcU%899Qvvx : ::d#Dq
#))+DtAw<DH  J :9!#56 	 	s(   B&BB&B#B&&B;:B;c                sF   a  \         P                  ! S 4      V 3R l4       pV# )zdDecorator which translates bare OSError and OSError exceptions
into NoSuchProcess and AccessDenied.
c                 s  < V P                   V P                  rC S! V .VO5/ VB #   \         d   p\        Y44      ThR p?i\         d"   pT P                  4        \        Y44      ThR p?i\         dX   pT P                  4        \        P                  P                  T P                   RT R24      '       g   \        Y44      Thh R p?ii ; i)NrI   rL   )r   _namer   r
   r   _raise_if_zombier   r   r>   rB   r   r   )r   ra   Zkwargsr   rJ   rk   funs   &*,   r/   wrapperZ wrap_exceptions.<locals>.wrapperj  s    HHdjjT	t-d-f-- 	3s)s2! 	4!!#*3  	!!# 77>>T%6%6$7qU"CDD#C.C7	s7   & C=C
CA''C4C5ACC)	functoolsZwraps)rL  rM  s   f r/   wrap_exceptionsrO  e  s'    
 __S $ Nr.   c                   s  a  ] tR tRt o Rt. R;OtR tR tR tR t	]
]R 4       4       t]
]R 4       4       t]
]R	 4       4       tR
 tR t]
R 4       t]
R 4       t]
R 4       t]
R 4       t]
R 4       t]P.                  P1                  R]P2                  ! 4        R24      '       d	   ]
R 4       t]
R 4       t]
R 4       t]
R<R l4       t]
R 4       t]
R 4       t] '       g	   ]!'       dJ   R t"]
]#PH                  ! R4      ]#PH                  ! R4      ]#PH                  ! R4      3R l4       t%]
R 4       t&M]t&]!'       d	   ]
R  4       t']
R! 4       t(]
]#PH                  ! R"4      3R# l4       t)]
]#PH                  ! R$4      3R% l4       t*]
R& 4       t+]
R' 4       t,]
R( 4       t-].'       d'   ]
R) 4       t/]#PH                  ! R*4      3R+ lt0]
R, 4       t1]2'       d   ]
R- 4       t3]
R. 4       t4]5! ]6R/4      '       d   ]
R<R0 l4       t7]
R1 4       t8]
R2 4       t9]
R=R3 l4       t:]
R4 4       t;]
R5 4       t<]
]#PH                  ! R64      3R7 l4       t=]
]#PH                  ! R84      3R9 l4       t>R:t?V t@R# )>Processi  zLinux process implementation.c                sL    Wn         R V n        R V n        \        4       V n        R # r   )r   rJ  _ppidr   r   )r   r      &&r/   r   ZProcess.__init__  s     

+-r.   c                s     \        V P                   R V P                   R24      pVP                  R4      pW^,           V^,            pVR8H  #   \         d     R# i ; i)rI   rL   rF  s   ZF)r   r   r   r   rb   )r   r&  rG  r   s   &   r/   
_is_zombieZProcess._is_zombie  si    	"4,,-Qtxxj>?D ::d#D(TAX.FT>!  		s   %A AAc                s    V P                  4       '       d,   \        V P                  V P                  V P                  4      hR # r   )rS  r   r   rJ  rQ  r   rC   r/   rK  ZProcess._raise_if_zombie  s/    ??$**djjAA r.   c                sd    \         P                  ! V P                   RV P                   24       R# )z+Raise NSP if the process disappeared on us.rI   N)r>   r  r   r   rT  rC   r/   _raise_if_not_aliveZProcess._raise_if_not_alive  s&     	4$$%Qtxxj12r.   c                s   \        V P                   RV P                   R24      pVP                  R4      pWP	                  R4      ^,           V pW^,           R P                  4       p/ pW5R&   V^ ,          VR&   V^,          VR&   V^,          VR	&   V^,          VR
&   V^,          VR&   V^,          VR&   V^,          VR&   V^,          VR&   V^$,          VR&    V^',          VR&   V#   \         d    \        R4       ^ TR&    T# i ; i)a!  Parse /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.
rI   rL   rF  s   (NrJ   r   rH  ttynrutimestimechildren_utimechildren_stimecreate_timecpu_numblkio_ticksz&can't get blkio_ticks, set iowait to 0)r   r   r   r   r(  r@   Z
IndexErrorr   )r   r&  rG  rJ   rW   r   r   r/   _parse_stat_fileZProcess._parse_stat_file  s-    t(()488*E:; zz$IIdOa'$/Qhj!'')Fq	HQiFayGbzGbzG &r
 &r
#BZMI	#!'C 
  	#:;!"C
	#s   C+ +D
	D
c                s    \        V P                   RV P                   R24      ;_uu_ 4       pVP                  4       uuRRR4       #   + '       g   i     R# ; i)zwRead /proc/{pid}/stat file and return its content.
The return value is cached in case oneshot() ctx manager is
in use.
rI   r>  N)r   r   r   r   r   rU   r  r/   _read_status_fileZProcess._read_status_file  sB     D--.azABBa668 CBBBs   A		A	c                s    \        V P                   R V P                   R24      ;_uu_ 4       pVP                  4       P	                  4       uuRRR4       #   + '       g   i     R# ; i)rI   r   N)r   r   r   r   rc   r_  r  r/   _read_smaps_fileZProcess._read_smaps_file  sI     D--.az@AAQ668>># BAAAs   AA(	c                    V P                   P                  V 4       V P                  P                  V 4       V P                  P                  V 4       R # r   )r^  Zcache_activater`  ra  rT  rC   r/   oneshot_enterZProcess.oneshot_enter  s>    ,,T2--d3,,T2r.   c                rb  r   )r^  Zcache_deactivater`  ra  rT  rC   r/   oneshot_exitZProcess.oneshot_exit  s>    ..t4//5..t4r.   c                B    \        V P                  4       R ,          4      # )rJ   )r   r^  rT  rC   r/   rJ   ZProcess.name  s     d++-f566r.   c                s    \        V P                   R V P                   R24      #   \        \        3 dT    T P                  4        \        P                  P                  T P                   R T P                   24      '       d    R# h i ; i)rI   z/exer   )	r?   r   r   r   r   rK  r>   rB   ZlexistsrT  rC   r/   exeZProcess.exe  s|    		t001488*DABB!#56 	!!# ww$"3"3!4AdhhZ@AA	s   $' AB	Bc                s   \        V P                   R V P                   R24      ;_uu_ 4       pVP                  4       pRRR4       X'       g   V P	                  4        . # VP                  R4      '       d   RMRpVP                  V4      '       d   VRR pVP                  V4      pVR8X  d)   \        V4      ^8X  d   RV9   d   VP                  R4      pV#   + '       g   i     L; i)rI   z/cmdlineNr;   r8   r   )r   r   r   r   rK  rA   r@   rR   )r   rU   r&  ZsepcmdlinerX   r/   rg  ZProcess.cmdline  s    $++,AdhhZx@AAQ668D B!!#I f--f3==9D**S/ &=S\Q.3$;jjoG- BAs   CC*	c                s    \        V P                   R V P                   R24      ;_uu_ 4       pVP                  4       pRRR4       \	        X4      #   + '       g   i     L; i)rI   z/environN)r   r   r   r   r   )r   rU   r&  rG   r/   environZProcess.environ  sM    $++,AdhhZx@AAQ668D B"4(( BAs   AA"	c                s    \        V P                  4       R ,          4      p\        P                  ! 4       p W!,          #   \         d     R# i ; i)rV  N)re   r^  r   Zget_terminal_mapr`   )r   Ztty_nrr   rG   r/   terminalZProcess.terminal  sG    T**,W56((*	< 		s   ? AAr   /ioc           	     sf   V P                    R V P                   R2p/ p\        V4      ;_uu_ 4       pV F>  pVP                  4       pV'       g   K   VP	                  R4      w  rV\        V4      W%&   K@  	  RRR4       V'       g   V R2p\        V4      h \        VR,          VR,          VR,          VR,          VR	,          VR
,          4      #   \         d     K  i ; i  + '       g   i     Lu; i  \         d/   pTP                  ^ ,          : RT RT: 2p\        T4      RhRp?ii ; i)rI   rj  s   : Nz file was emptys   syscrs   syscws
   read_bytess   write_bytess   rchars   wcharz field was not found in z; found fields are )r   r   r   rc   r@   re   r   r   r9   r`   ra   )	r   fnamerW   rU   rl   rJ   r   r   rk   	   &        r/   io_countersZProcess.io_counters$  s5   (()488*C8EFU##qD::<Dt6*.**U*;KD
 ,/u:FL  $ /"3''08$8$=)>*8$8$   * %$% $#0  0xx{o%=eW E##)*.  !o4/0sG   C$C&C$9C7 C!	C$ C!	!C$$C4	7D0)D++D0c                s^   V P                  4       p\        VR ,          4      \        ,          p\        VR,          4      \        ,          p\        VR,          4      \        ,          p\        VR,          4      \        ,          p\        VR,          4      \        ,          p\        W#WEV4      # )rW  rX  rY  rZ  r]  )r^  r   r   r:   )r   rV   rW  rX  rY  rZ  rP   r"  r/   r   ZProcess.cpu_timesG  s    &&(fWo&4fWo&4v&678;Fv&678;Fvm,-;~vNNr.   c                sB    \        V P                  4       R,          4      # )zWhat CPU the process is on.r\  re   r^  rT  rC   r/   r\  ZProcess.cpu_numQ  s     4((*9566r.   Nc                sX    \         P                  ! V P                  WP                  4      # r   )r   Zwait_pidr   rJ  )r   ZtimeoutrR  r/   waitZProcess.waitV  s      7JJ??r.   c                s    \        V P                  4       R ,          4      p\        ;'       g    \        4       pV\        ,          V,           # )r[  )r   r^  rC  rD  r   )r   ZctimeZbtrG   r/   r[  ZProcess.create_timeZ  s;    d++-m<= %%)+#r))r.   c           	     s   \        V P                   R V P                   R24      ;_uu_ 4       pR VP                  4       P	                  4       R,           4       w  r#rErgpRRR4       \        XXXXXXX4      #   + '       g   i     L!; i)rI   z/statmc              3   sN   "   T F  p\        V4      \        ,          x  K  	  R # 5ir   )re   rf   )Z.0r0   r  r/   Z	<genexpr>Z&Process.memory_info.<locals>.<genexpr>s  s       8+CaA!!+Cs   #%:Nr   NN)r   r   r   rQ   r@   r4   )	r   rU   Zvmsrssrt   ZtextZlibr&  Zdirtyrl  r/   memory_infoZProcess.memory_infoe  s~     D--.az@AAQ8+,::<+=+=+?+C84CfCu B CfdCu==	 BAs   2A99B		c                sF   ^ ;p;r#\        V P                   RV P                   R24      ;_uu_ 4       pV F  pVP                  R4      '       d1   V\	        VP                  4       ^,          4      R,          ,          pKJ  VP                  R4      '       d*   \	        VP                  4       ^,          4      R,          pK  VP                  R4      '       g   K  \	        VP                  4       ^,          4      R,          pK  	  RRR4       WV3#   + '       g   i     L; i)r   rI   r   s   Private_rq      Pss:   Swap:N)r   r   r   rd   re   r@   )r   usspssswaprU   rl   r   r/   _parse_smaps_rollupZProcess._parse_smaps_rollupz  s      ! C #$$%Qtxxj> D{33s4::<?3d::11!$**,q/2T922"4::<?3d:  d## s   A#D=D+DD 	s   \nPrivate.*:\s+(\d+)s   \nPss\:\s+(\d+)s   \nSwap\:\s+(\d+)c                sD   V P                  4       p\        \        \        VP	                  V4      4      4      R ,          p\        \        \        VP	                  V4      4      4      R ,          p\        \        \        VP	                  V4      4      4      R ,          pWVV3# )rq   )ra  r   r  re   findall)r   Z_private_reZ_pss_reZ_swap_reZ
smaps_datart  ru  rv  s   &&&&    r/   _parse_smapsZProcess._parse_smaps  s    * ..0J c#{22:>?@4GCc#wz:;<tCCs3 0 0 <=>EDd##r.   c                s    \         '       d    V P                  4       w  rpMV P	                  4       w  rpV P                  4       p\        WAW#3,           !  #   \        \        3 d    T P	                  4       w  rp LGi ; ir   )HAS_PROC_SMAPS_ROLLUPrw  r   r   ry  rq  r5   )r   rt  ru  rv  Z	basic_memrX   r/   memory_full_infoZProcess.memory_full_info  s}    $$9%)%=%=%?NCd "&!2!2!4$((*IYs)99:: +,=> 9%)%6%6%8NCd9s   A $A=<A=c                s   R pV P                  4       pV'       g   V P                  4        . # VP                  R4      p. pVP                  ^ 4      pV.pV! W64       EFD  w  rrVP                  R^4      p Vw  rrrV'       g   RpMH\        V4      pVP                  4       pVP                  R4      '       d   \        V4      '       g   VRR p\        V	4      \        V
4      VVP                  R^ 4      VP                  R^ 4      VP                  R	^ 4      VP                  R
^ 4      VP                  R^ 4      VP                  R^ 4      VP                  R^ 4      VP                  R^ 4      VP                  R^ 4      VP                  R^ 4      3pVP                  V4       EKG  	  V#   \         d    TR.,           w  rrr ELHi ; i)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              3   s  "   / pV  F}  pVP                  R ^4      pV^ ,          P                  R4      '       g(   VP                  4       V3x  VP                  V4       KZ   \	        V^,          4      R,          W$^ ,          &   K  	  VP                  4       V3x  R #   \
         d5    T^ ,          P                  R4      '       d    K  RT: 2p\        T4      R hi ; i5i)Nr   rq   s   VmFlags:z!don't know how to interpret line )r@   rA   poprS   re   r   rd   )r  current_blockr&  rl   rW   r   r   r/   
get_blocksZ'Process.memory_maps.<locals>.get_blocks  s     !D!ZZa0F!!9--d33,002D99%,,T2<.1&)nt.CDO " %((*D11  * <%ay33K@@ ($EdX"NC",S/t;<s*   AC ""BC (CC 
CC s   
Nr   z[anon]r<   s   Rss:s   Size:rr  s   Shared_Clean:s   Shared_Dirty:s   Private_Clean:s   Private_Dirty:s   Referenced:s
   Anonymous:rs  r=   )ra  rK  r@   r|  r   r   rc   rA   r   r_   rS   )r   r~  r&  r  r   Z
first_liner}  ZheaderZhfieldsr   ZpermsZ_offsetZ_devZ_inoderB   rB  s   &               r/   memory_mapsZProcess.memory_maps  s   2& ((*D %%'	JJu%EB1J'LM *5 @ ,,tQ/N?F<D #D!$<D::<D}}\22;M< <  $DSz4L5MHHWa(HHXq)HHWa(HH-q1HH-q1HH.2HH.2HH^Q/HH]A.HHXq) 		$= !A> I7 " N?F"~<DNs   6F((GGc                sL    \        V P                   R V P                   R24      # )rI   z/cwd)r?   r   r   rT  rC   r/   cwdZProcess.cwd  s%    4,,-Qtxxj=>>r.   s   ctxt_switches:\t(\d+)c                s   V P                  4       pVP                  V4      pV'       g)   R V P                   RV P                   R2p\	        V4      h\
        P                  ! \        V^ ,          4      \        V^,          4      4      # )zR'voluntary_ctxt_switches' and 'nonvoluntary_ctxt_switches'lines were not found in rI   z1/status; the kernel is probably older than 2.6.23)r`  rx  r   r   r   r   Zpctxswre   )r   Z	_ctxsw_rer&  Zctxswr   s   &&   r/   num_ctx_switchesZProcess.num_ctx_switches  s}     %%'!!$'%%&az 2..  &c**~~c%(mSq];;r.   s   Threads:\t(\d+)c                sd    V P                  4       p\        VP                  V4      ^ ,          4      # r   )r`  re   rx  )r   Z_num_threads_rer&     && r/   num_threadsZProcess.num_threads  s-     %%'?**40344r.   c                s   \         P                  ! V P                   R V P                   R24      pVP	                  4        . pRpV F  pV P                   R V P                   RV R2p \        V4      ;_uu_ 4       pVP                  4       P                  4       pRRR4       XTP                  R4      ^,           R pTP                  R4      p\        T^,          4      \        ,          p	\        T^,          4      \        ,          p
\        P                  ! \!        T4      Y4      pTP#                  T4       K  	  V'       d   V P%                  4        V#   + '       g   i     L; i  \        \        3 d    Rp EK<  i ; i)	rI   z/taskFz/task/rL   NTrF  r   )r>   r   r   r   r   r   r   rc   r   r   r(  r@   r   r   r   Zpthreadre   rS   rU  )r   Z
thread_idsr+  
hit_enoentZ	thread_idrk  rU   ZstrV   rW  rX  r,  rn   r/   threadsZProcess.threads!  s>   ZZ4#4#4"5Qtxxj FG

#I(()488*F9+UKE ''1)B ( BGGDMA%'(BXXd^F&*%3E&*%3E__S^UBFNN6"! $" $$&! ('%'9:  "
	s0   *E,=EE,E)$E,)E,,FFc                B    \         P                  ! V P                  4      # r   )r  Zgetpriorityr   rT  rC   r/   nice_getZProcess.nice_get<  s     %%dhh//r.   c                sD    \         P                  ! V P                  V4      # r   )r  Zsetpriorityr   )r   r   rR  r/   nice_setZProcess.nice_setE  s    %%dhh66r.   c                r  r   )r   r    r   rT  rC   r/   cpu_affinity_getZProcess.cpu_affinity_getL  s    --dhh77r.   s   Cpus_allowed_list:\t(\d+)-(\d+)c           	     s2   V P                  4       pVP                  V4      pV'       dK   \        \        \	        V^ ,          ^ ,          4      \	        V^ ,          ^,          4      ^,           4      4      # \        \        \        \        4       4      4      4      # r  )r`  rx  r   rangere   rR   r   )r   Z_rer&  r   r   r/   _get_eligible_cpusZProcess._get_eligible_cpusP  sk     ))+DKK%EE#eAhqk"2Ca4Dq4HIJJE#mo"6788r.   c           	     s    \         P                  ! V P                  V4       R#   \        \        3 d   p\        T\        4      '       g    TP                  \        P                  8X  du   T P                  4       p\        \        \        \        4       4      4      4      pT F9  pYT9  d   R T: RT: 2p\	        T4      RhYS9  g   K'  RT RT 2p\	        T4      Th	  h Rp?ii ; i)zinvalid CPU z; choose between NzCPU number z! is not eligible; choose between )r   Zproc_cpu_affinity_setr   rb   r   Z
isinstancer   r   r  Ztupler  rR   r   )r   r   rk   Zeligible_cpusZall_cpusZcpur   s   &&     r/   cpu_affinity_setZProcess.cpu_affinity_set[  s    **488T:Z( c:..#))u||2K$($;$;$=M$U3}+?%@AH#.".sg 6$$1#4!6   #-S/t;3"-cU 3,,9?!<   #-S/s:  $ #s   !% C%BC 	C  C%c                s    \         P                  ! V P                  4      w  r\        V4      p\        P
                  ! W4      # r   )r   r   r   r#   r   Zpionice)r   ioclassr   rG   r/   
ionice_getZProcess.ionice_getu  s1    !11$((;NG )G??722r.   c                s   Vf   ^ pV'       d7   V\         P                  \         P                  09   d   V: R2p\        V4      hV^ 8  g   V^8  d   Rp\        V4      h\        P
                  ! V P                  W4      # )Nz ioclass accepts no valuezvalue not in 0-7 range)r#   r,   r)   r   r   Zproc_ioprio_setr   )r   r  r   r   s   &&& r/   
ionice_setZProcess.ionice_set{  sy    },,,,%  !#<= o%qyEAI. o%'''AAr.   r   c                s   V P                   ^ 8X  d   Rp\        V4      h Vf"   \        P                  ! V P                   V4      # \	        V4      ^8w  d   RV: 2p\        V4      h\        P                  ! V P                   W4       R#   \
         d6   pTP                  \        P                  8X  d   T P                  4        h Rp?ii ; i)r   z)can't use prlimit() against PID 0 processNz2second argument must be a (soft, hard) tuple, got )	r   r   resourcer   rR   rb   r   ZENOSYSrK  )r   Z	resource_Zlimitsr   rk   s   &&&  r/   rlimitZProcess.rlimit  s    
 xx1}A o%>#++DHHi@@ 6{a'**05  )o-$$TXXyA 99, ))+s   $B	 AB	 	C	0CC	c                s|    V P                  4       R ,          pVP                  4       p\        P                  VR4      # )r   Z?)r^  r   PROC_STATUSESr_   )r   Zletterr  r/   r   ZProcess.status  s3    &&(2  --r.   c                sj   . p\         P                  ! V P                   R V P                   R24      pRpV EF0  pV P                   R V P                   RV 2p \	        V4      pVP                  R 4      '       d   \        V4      '       d   V P                   R V P                   RV 2p \        V4      ;_uu_ 4       p\        VP                  4       P                  4       ^,          4      p\        VP                  4       P                  4       ^,          ^4      p	RRR4       \        X	4      p
\        V\        V4      \        X4      W4      pVP                  V4       EK-  EK0  EK3  	  V'       d   V P+                  4        V#   + '       g   i     Lq; i  \        \        3 d    Rp EKy  i ; i  \        \        3 d    Rp EK  \          d^   pTP"                  \"        P$                  8X  d    Rp?EK  TP"                  \"        P&                  8X  d   \)        T4        Rp?EK  h Rp?ii ; i)rI   r   Fr   z/fdinfo/NT)r>   r   r   r   r?   rd   r   r   re   rQ   r@   rH   r3   rS   r   r   rb   r   r   r   r   rU  )r   r+  r  r  r   r   rB   rU   ZposrE   rF   r,  rk   s   &            r/   
open_filesZProcess.open_files  s   

d//0$((3?@
B''($((4t<D$/~& ??3''M$,?,?"//0$((8B4HD/(..!"%ajjl&8&8&:1&=">C$'

(:(:(<Q(?$CE /  2%8!* #b'3s8T"  v.! -@'- N $$& /. ./AB * &*
*3 &'9: !
 99,99 2 22#Js[   F4,F?AFFFFF10F14H2H2H2H-;*H-,H--H2c                sd    \         P                  WP                  4      pV P                  4        V# r   )r   r   r   rU  )r   r   r   r  r/   r   ZProcess.net_connections  s'    ''hh7  "
r.   c                st    \        \        P                  ! V P                   R V P                   R24      4      # )rI   r   )rR   r>   r   r   r   rT  rC   r/   num_fdsZProcess.num_fds  s.    2::!2!2 31TXXJcBCDDr.   c                re  )rH  rn  rT  rC   r/   rH  ZProcess.ppid  s    4((*6233r.   s   Uid:\t(\d+)\t(\d+)\t(\d+)c                    V P                  4       pVP                  V4      ^ ,          w  r4p\        P                  ! \	        V4      \	        V4      \	        V4      4      # r  )r`  rx  r   Zpuidsre   )r   Z_uids_rer&  real	effectivesavedr   r/   uidsZProcess.uids  I    %%'!)!1!1$!7!:}}SYIE
CCr.   s   Gid:\t(\d+)\t(\d+)\t(\d+)c                r  r  )r`  rx  r   Zpgidsre   )r   Z_gids_rer&  r  r  r  r   r/   gidsZProcess.gids  r  r.   )rJ  rQ  r   r   )Z_cacherJ  rQ  r   r   r   r   )Ar%   r&   r'   r(   r   r)  r   rS  rK  rU  rO  r   r^  r`  ra  rc  rd  rJ   rf  rg  rh  ri  r>   rB   r   getpidrm  r   r\  ro  r[  rq  rz  HAS_PROC_SMAPSrw  r   r   ry  r{  r  r  r  r  r  r  r  HAS_CPU_AFFINITYr  r  r  HAS_PROC_IO_PRIORITYr  r  hasattrr  r  r   r  r   r  rH  r  r  r-   r   r   r   r/   rP  rP    s    'CI." B3 #  #J    $  $3
5
 7 7 
 
  2 ) )
   
ww~~ryy{m3/00	 	0 
 	0D O O 7 7 @ @ * * > >$ 	$. 
 

#;<JJ23ZZ 45	$ 
	$8 
		; 
		; '	E	 
E	N ? ? 

#<=< < *,**5H*I 5 5
  4 0 0 7 7 		8 
	8 jj!DE		9 
	 
	. 		3 
	3
 
	B 
	B x##		 
	6 . . - -^  
 E E 4 4 JJ'DE D D
 JJ'DE D Dr.   rP  )ZPROCFS_PATHr)   r*   r+   r,   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_CLOSING)r~   rw   r   r   ri   ru   rv   rr   rs   rt   r   )	
read_countwrite_count
read_byteswrite_bytesZ	read_timeZ
write_timeZread_merged_countZwrite_merged_countr  )rB   r   ZpositionrF   rE   )rt  ru  rv  )rB   rp  Zsizeru  Zshared_cleanZshared_dirtyZprivate_cleanZprivate_dirtyZ
referencedZ	anonymousrv  )r  r  r  r  Z
read_charsZwrite_chars)rN   rO   Zchildren_userZchildren_systemrP   r  )F)r   r   r1  Zenumr   rN  r   r>   r   r  r   r   Zsysr{   r    r   r   r   r   r   r   r   r  r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Z__extra__all__r  r2  Zdirrd   Zisupperr?  rB   r   r  r  rz  r  r  r   r   Zgetpagesizerf   rC  Z	byteorderr   r  ZIntEnumre   Z	AF_PACKETr!   r"   r#   Zglobalsr   Z__members__ZSTATUS_RUNNINGZSTATUS_SLEEPINGZSTATUS_DISK_SLEEPZSTATUS_STOPPEDZSTATUS_TRACING_STOPZSTATUS_ZOMBIEZSTATUS_DEADZSTATUS_WAKE_KILLZSTATUS_WAKINGZSTATUS_IDLEZSTATUS_PARKEDr  r  r  r  r  r  r  r  r  r  r  r  r   r1   r2   r3   r4   r   r5   r6   rz   r7   r9   r:   r?   rH   rK   rY   Z	Exceptionrk   rM   ro   r   r   r   r   r   r   r   r   r   Znet_if_addrsr   r   r   r   r  r  Z
disk_usager  r  r*  r:  r;  r@  rA  rD  r   rE  rI  rO  rP  r   s   0r/   <module>r     s%  
 %       	 	    
  # "   # )  $ $ ' ! " "     $ "  +    ( ' " "	 8YIFIqf!5!))+IF . &V <=		}M'JK t%67 4!89  jj&!!#	)  iV%5%5!67 

  	  '' ( 			 	 	"	"			$	$							!	!						" 	'
"
"'

'

'
 
 '
 
 '
 
 '

'
!
!'

'

'

, 	 K	L   <>	 &>?j$,,1G"GHJK
 -*?*?!@@B	  6 7 {"#	(
$& 	0 	00K!<~BJ4@x (:'T2
 77>>;<<*A A#NP &&	I 	k k\ "# +
,^B   
fRH HV$Xsl>W>~ &=!B,6w	D w	D1 	Gj  K	*3'
23;(:;CcJIKs*   S.S.6S.S3 3T":TT"