Your IP : 18.219.255.63


Current Path : /usr/lib64/python3.6/site-packages/psutil/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/psutil/__pycache__/_pssunos.cpython-36.pyc

3

��JZ2d�@s
dZddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddl	mZddl	mZ
dd	l	mZdd
l
mZddl
mZddl
mZdd
l
mZddl
mZddl
mZddlmZddlmZddlmZddlmZddlmZdddgZejd�Ze
j Z ej!d^kZ"dZ#dZ$ej%e
j&ej'e
j(ej)e
j*ej+e
j,ej-e
j.ej/e
j(ej0e
j1iZ2ej3e
j4ej5e
j6ej7e
j8ej9e
j:ej;e
j<ej=e
j>ej?e
j@ejAe
jBejCe
jDejEe
jFejGe
jHejIe
jJejKe#ejLe$iZMeNddddddd d!d"�ZOed#d$d%d&d'g�ZPed(d$d%d)d*g�ZQed+d,d-d.d/d0g�ZRed1d2d3g�ZSeSZTed4d5d2d6d7g�ZUed8d9d:jVeUjW��ZXd;d<�ZYd=d>�ZZd?d@�Z[dAdB�Z\dCdD�Z]dEdF�Z^dGdH�Z_dIdJ�Z`ejaZaejbZbd_dLdM�ZcejdZde
jeZedadNdO�ZfdPdQ�ZgdRdS�ZhdTdU�ZidVdW�ZjdXdY�ZkdZd[�ZlGd\d]�d]em�ZndS)bz'Sun OS Solaris platform implementation.�N)�
namedtuple)�AF_INET�)�_common)�_psposix)�
_psutil_posix)�
_psutil_sunos)�AF_INET6)�
isfile_strict)�memoize_when_activated)�sockfam_to_enum)�socktype_to_enum)�
usage_percent)�b)�PY3)�AccessDenied)�
NoSuchProcess)�
ZombieProcess�	CONN_IDLE�
CONN_BOUND�PROCFS_PATH�SC_PAGE_SIZE�� ZIDLEZBOUND�����)�ppid�rss�vms�create_time�nice�num_threads�status�ttynr�	scputimes�user�systemZidleZiowait�	pcputimes�
children_user�children_system�svmem�totalZ	available�percent�used�free�pmemr r!�
pmmap_grouped�pathZ	anonymous�locked�	pmmap_extzaddr perms � cCstjdjS)z+Return updated psutil.PROCFS_PATH constant.Zpsutil)�sys�modulesr�r:r:� /usr/lib64/python3.6/_pssunos.py�get_procfs_pathqsr<cCsFtjd�t}tjd�t}}||}t||dd�}t|||||�S)zReport virtual memory metrics.�
SC_PHYS_PAGES�SC_AVPHYS_PAGESr)�_round)�os�sysconf�	PAGE_SIZErr-)r.r1Zavailr0r/r:r:r;�virtual_memory{s
rCc
Cstj�\}}tjddtjdddgtjd�}|j�\}}trL|j	t
jj�}|j
dkrdtd|j
��|j�jd	�d
d�}|s�td��d}}xL|D]D}|j�}|dd�\}	}
|tt|	�d�7}|tt|
�d�7}q�W||}t||d
d�}tj|||||t|t�S)zReport swap memory metrics.z/usr/bin/envzPATH=/usr/sbin:/sbin:%s�PATHZswapz-l)�stdoutrz'swap -l' failed (retcode=%s)�
rNzno swap device(s) configuredri)r?���)�cextZswap_mem�
subprocess�Popenr@�environ�PIPE�communicater�decoder8rE�encoding�
returncode�RuntimeError�strip�split�intrrZsswaprB)
ZsinZsout�prE�stderr�linesr.r1�line�t�fr0r/r:r:r;�swap_memory�s,


r[cCstj�}tdd�t|�D��S)z-Return system-wide CPU times as a named tuplecSsg|]}t|��qSr:)�sum)�.0�xr:r:r;�
<listcomp>�szcpu_times.<locals>.<listcomp>)rH�
per_cpu_timesr'�zip)�retr:r:r;�	cpu_times�srccCstj�}dd�|D�S)z5Return system per-CPU times as a list of named tuplescSsg|]}t|��qSr:)r')r]r^r:r:r;r_�sz!per_cpu_times.<locals>.<listcomp>)rHr`)rbr:r:r;r`�sr`cCs$y
tjd�Stk
rdSXdS)z0Return the number of logical CPUs in the system.�SC_NPROCESSORS_ONLNN)r@rA�
ValueErrorr:r:r:r;�cpu_count_logical�s
rfcCstj�S)z1Return the number of physical CPUs in the system.)rHZcpu_count_physr:r:r:r;�cpu_count_physical�srgcCs$tj�\}}}}d}tj||||�S)z*Return various CPU stats as a named tuple.r)rH�	cpu_statsrZ	scpustats)Zctx_switchesZ
interruptsZsyscallsZtrapsZsoft_interruptsr:r:r;rh�s
rhFc	Cs`g}tj�}xN|D]F}|\}}}}|dkr.d}|s>t|�js>qtj||||�}|j|�qW|S)zReturn system disk partitions.Znone�)rH�disk_partitions�
disk_usager.rZ	sdiskpart�append)	�all�retlistZ
partitions�	partitionZdeviceZ
mountpointZfstypeZoptsZntupler:r:r;rj�s

rjc	Cstjj�}|dkr|jdd�||krFtd|djdd�|D��f��tj|\}}tj|�}t�}x�|D]�}|\}}	}
}}}
}|	|kr�qj|
|kr�qj|	t	t
fkr�|r�tj|�}|r�tj|�}t|
}
t
|	�}	t|
�}
|d	kr�tj||	|
|||
|�}ntj||	|
|||
�}|j|�qjWt|�S)
z�Return socket connections.  If pid == -1 return system-wide
    connections (as opposed to connections opened by one process only).
    Only INET sockets are returned (UNIX are not).
    r�unixrz+invalid %r kind argument; choose between %sz, cSsg|]}t|��qSr:)�repr)r]r^r:r:r;r_�sz#net_connections.<locals>.<listcomp>���rr)rZ	conn_tmap�copy�popre�joinrH�net_connections�setrr	�addr�TCP_STATUSESrr
Zsconn�pconn�add�list)�kind�_pidZcmapZfamilies�types�rawlistrb�item�fdZfamZtype_ZladdrZraddrr%�pid�ntr:r:r;rv�s8




rvcCsVtj�}xH|j�D]<\}}|\}}}}ttd�r:tj|�}tj||||�||<qW|S)z)Get NIC stats (isup, duplex, speed, mtu).�	NicDuplex)rH�net_if_stats�items�hasattrrr�Z	snicstats)rb�namer�ZisupZduplexZspeedZmtur:r:r;r�s

r�cCstj�S)z:The system boot time expressed in seconds since the epoch.)rH�	boot_timer:r:r:r;r�)sr�cCs`g}tj�}d}xJ|D]B}|\}}}}}}	|s0q||kr<d}tj|||||	�}
|j|
�qW|S)z:Return currently connected users as a list of namedtuples.�:0.0�:0�	localhost)r�r�)rH�usersrZsuserrl)rnr�r�r�r(�ttyZhostnameZtstampZuser_processr�r�r:r:r;r�.s
r�cCsdd�tjtt���D�S)z7Returns a list of PIDs currently running on the system.cSsg|]}|j�rt|��qSr:)�isdigitrT)r]r^r:r:r;r_Hszpids.<locals>.<listcomp>)r@�listdirrr<r:r:r:r;�pidsFsr�cCs
tj|�S)z&Check for the existence of a unix pid.)r�
pid_exists)r�r:r:r;r�Ksr�cs�fdd�}|S)z�Call callable into a try/except clause and translate ENOENT,
    EACCES and EPERM in NoSuchProcess or AccessDenied exceptions.
    cs�y�|f|�|�Stk
r�}z�|jdkrHdt�krFt|j|j��n�|jtjtjfkr�t|j�stt	|j|j��nt
|j|j|j��|jtjtj
fkr�t|j|j���WYdd}~XnXdS)Nr)�EnvironmentErrorr�r�r�_name�errno�ENOENT�ESRCHr�rr�_ppidZEPERMZEACCES)�self�args�kwargs�err)�funr:r;�wrapperUs


z wrap_exceptions.<locals>.wrapperr:)r�r�r:)r�r;�wrap_exceptionsPsr�c@s�eZdZdZddddgZdd�Zdd	�Zd
d�Zedd
��Z	edd��Z
edd��Zedd��Z
edd��Zedd��Zedd��Zedd��Zedd��Zedd��Zed d!��Zed"d#��Zed$d%��Zed&d'��Zed(d)��Zed*d+��Zed,d-��Zed.d/��Zed0d1��ZeZed2d3��Zed4d5��Zed6d7��Z d8d9�Z!edId;d<��Z"e#d=d>�Z$e#d=d?�Z%ed@dA��Z&edBdC��Z'edDdE��Z(edJdGdH��Z)dFS)K�Processz1Wrapper class around underlying C implementation.r�r�r��_procfs_pathcCs||_d|_d|_t�|_dS)N)r�r�r�r<r�)r�r�r:r:r;�__init__qszProcess.__init__cCs"|jj�|jj�|jj�dS)N)�_proc_name_and_argsZcache_activate�_proc_basic_info�
_proc_cred)r�r:r:r;�
oneshot_enterws

zProcess.oneshot_entercCs"|jj�|jj�|jj�dS)N)r�Zcache_deactivater�r�)r�r:r:r;�oneshot_exit|s

zProcess.oneshot_exitcCstj|j|j�S)N)rHZproc_name_and_argsr�r�)r�r:r:r;r��szProcess._proc_name_and_argscCs(tj|j|j�}t|�tt�ks$t�|S)N)rHZproc_basic_infor�r��len�
proc_info_map�AssertionError)r�rbr:r:r;r��szProcess._proc_basic_infocCstj|j|j�S)N)rHZ	proc_credr�r�)r�r:r:r;r��szProcess._proc_credcCs|j�dS)Nr)r�)r�r:r:r;r��szProcess.namecCs8ytjd|j|jf�Stk
r*YnX|j�dS)Nz%s/%s/path/a.outri)r@�readlinkr�r��OSError�cmdline)r�r:r:r;�exe�szProcess.execCs|j�djd�S)Nrr7)r�rS)r�r:r:r;r��szProcess.cmdlinecCstj|j|j�S)N)rHZproc_environr�r�)r�r:r:r;rK�szProcess.environcCs|j�tdS)Nr")r�r�)r�r:r:r;r"�szProcess.create_timecCs|j�tdS)Nr$)r�r�)r�r:r:r;r$�szProcess.num_threadscCsbytj|j�Stk
r\}z4|jtjtjdfkrJt|j�rJt|j|j	���WYdd}~XnXdS)N�0)
�
cext_posix�getpriorityr�r�r�r�r�r�rr�)r�r�r:r:r;�nice_get�s
zProcess.nice_getcCs&|jdkrt|j|j��tj|j|�S)Nrr)rr)r�rr�r��setpriority)r��valuer:r:r;�nice_set�s
zProcess.nice_setcCs|j�td|_|jS)Nr)r�r�r�)r�r:r:r;r�szProcess.ppidcCs"|j�\}}}}}}tj|||�S)N)r�r�puids)r��real�	effective�saved�_r:r:r;�uids�szProcess.uidscCs"|j�\}}}}}}tj|||�S)N)r�rr�)r�r�r�r�r�r:r:r;�gids�szProcess.gidscCs\ytj|j|j�}Wn<tk
rP}z |jtjkr>tr>d}n�WYdd}~XnXtj	|�S)N�)r�r�r�r�)
rHZproc_cpu_timesr�r�r�r��	EOVERFLOW�	IS_64_BITrr*)r��timesr�r:r:r;rc�szProcess.cpu_timescCstj|j|j�S)N)rHZproc_cpu_numr�r�)r�r:r:r;�cpu_num�szProcess.cpu_numcCs�|j}d}t|j�td�}|tjkr�xZd
D]R}ytjd||j|f�St	k
r~}z|j
t
jkrld}w.�WYdd}~Xq.Xq.W|r�tjd	||jf�dS)NFr&rrr�z
%s/%d/path/%dTz%s/%s)rrrr�)
r�r�r�r�rHZPRNODEVr@r�r�r�r�r��stat)r��procfs_path�
hit_enoentr�r^r�r:r:r;�terminal�s 

zProcess.terminalcCsh|j}ytjd||jf�Stk
rb}z,|jtjkrPtjd||jf�dS�WYdd}~XnXdS)Nz%s/%s/path/cwdz%s/%s)r�r@r�r�r�r�r�r�)r�r�r�r:r:r;�cwdszProcess.cwdcCs2|j�}|tdd}|tdd}t||�S)Nr ir!)r�r�r2)r�rbr r!r:r:r;�memory_infoszProcess.memory_infocCs|j�td}tj|d�S)Nr%�?)r�r��
PROC_STATUSES�get)r��coder:r:r;r%$szProcess.statusc
Cs�|j}g}tjd||jf�}d}x�|D]�}t|�}ytj|j||�\}}WnJtk
r�}z.|jtj	krrt
rrw(|jtjkr�d}w(�WYdd}~Xq(Xtj
|||�}	|j|	�q(W|r�tjd||jf�|S)Nz	%s/%d/lwpFTz%s/%s)r�r@r�r�rTrHZquery_process_threadr�r�r�r�r�rZpthreadrlr�)
r�r�rbZtidsr��tid�utimeZstimer�r�r:r:r;�threads*s*
zProcess.threadsc	Cs�g}d}|j}d||jf}x�tjd||jf�D]�}tjj||�}tjj|�r2ytj|�}Wn6tk
r�}z|j	t	j
kr�d}w2�WYdd}~Xq2Xt|�r2|jt
j|t|���q2W|r�tjd||jf�|S)NFz
%s/%d/pathz%s/%d/fdTz%s/%s)r�r�r@r�r4ru�islinkr�r�r�r�r
rlrZ	popenfilerTr�)	r�rnr�r�Zpathdirr�r4�filer�r:r:r;�
open_filesLs&zProcess.open_filesccs,d|}tj|dtjtjd�}|j�\}}trDdd�||fD�\}}|jdkr�d|j�krht|j|j	��d|j�kr�t
|j|j	��td	||f��|jd
�dd�}x�t
|�D]v\}}|j�}|jd
�r�|jdd�d}	||dj�}
|
dkr�tj}
n|
dk�r
tj}
nd}
dtj|
|	dtjfVq�WdS)z<Get UNIX sockets used by process by parsing 'pfiles' output.z	pfiles %sT)�shellrErVcSsg|]}|jtjj��qSr:)rNr8rErO)r]r^r:r:r;r_nsz-Process._get_unix_sockets.<locals>.<listcomp>rzpermission deniedzno such processz%r command error
%srFrNzsockname: AF_UNIXr7�SOCK_STREAM�
SOCK_DGRAMrrirrrr)rIrJrLrMrrP�lowerrr�r�rrQrS�	enumerate�lstrip�
startswithrR�socketr�r�ZAF_UNIXr�	CONN_NONE)r�r��cmdrUrErVrW�irXr4�typer:r:r;�_get_unix_socketses2



zProcess._get_unix_sockets�inetcCsPt||jd�}|s(tjd|j|jf�|dkrL|jdd�|j|j�D��|S)N)r~z%s/%srmrpcSsg|]}tj|��qSr:)rrz)r]Zconnr:r:r;r_�sz'Process.connections.<locals>.<listcomp>)rmrp)rvr�r@r�r��extendr�)r�r}rbr:r:r;�connections�s
zProcess.connectionsZmmapzpath rss anon lockedzaddr perms path rss anon lockedc$Cs.dd�}|j}g}ytj|j|�}Wn:tk
r^}z|jtjkrLtrLgS�WYdd}~XnXd}x�|D]�}|\}}	}
}}}
}|||	�}|jd�s�yt	j
d||j|f�}WnFtk
r�}z*|jtjkr�d||j|f}d}n�WYdd}~XnX|j||
|||
|f�qjW|�r*t	j
d||jf�|S)NcSs0dt|�dd�jd�t|�dd�jd�fS)Nz%s-%sr�L)�hexrR)�start�endr:r:r;�toaddr�sz#Process.memory_maps.<locals>.toaddrF�[z
%s/%s/path/%sTz%s/%s)r�rHZproc_memory_mapsr�r�r�r�r�r�r@r�r�rlr�)r�r�r�rnr�r�r�r�rxZaddrsizeZpermr�r Zanonr5r:r:r;�memory_maps�s4


zProcess.memory_mapscCsttjd|j|jf��S)Nz%s/%s/fd)r�r@r�r�r�)r�r:r:r;�num_fds�szProcess.num_fdscCstjtj|j|j��S)N)rZpctxswrHZproc_num_ctx_switchesr�r�)r�r:r:r;�num_ctx_switches�szProcess.num_ctx_switchesNcCstj|j||j�S)N)rZwait_pidr�r�)r�Ztimeoutr:r:r;�wait�szProcess.wait)r�)N)*�__name__�
__module__�__qualname__�__doc__�	__slots__r�r�r�rr�r�r�r�r�r�r�rKr"r$r�r�rr�r�rcr�r�r�r�Zmemory_full_infor%r�r�r�r�rZnt_mmap_groupedZnt_mmap_extr�r�r�r�r:r:r:r;r�lsL

" 

0r�l)Frr)rr)or�r�r@r�rIr8�collectionsrrrirrrr�rrHr	r
rrr
rZ_compatrr�_exceptionsrrrZ__extra__all__rArBZAF_LINK�maxsizer�rrZSSLEEPZSTATUS_SLEEPINGZSRUNZSTATUS_RUNNINGZSZOMBZ
STATUS_ZOMBIEZSSTOPZSTATUS_STOPPEDZSIDLZSTATUS_IDLEZSONPROCZSWAITZSTATUS_WAITINGr�ZTCPS_ESTABLISHEDZCONN_ESTABLISHEDZ
TCPS_SYN_SENTZ
CONN_SYN_SENTZ
TCPS_SYN_RCVDZ
CONN_SYN_RECVZTCPS_FIN_WAIT_1ZCONN_FIN_WAIT1ZTCPS_FIN_WAIT_2ZCONN_FIN_WAIT2ZTCPS_TIME_WAITZCONN_TIME_WAITZTCPS_CLOSEDZ
CONN_CLOSEZTCPS_CLOSE_WAITZCONN_CLOSE_WAITZ
TCPS_LAST_ACKZ
CONN_LAST_ACKZTCPS_LISTENZCONN_LISTENZTCPS_CLOSINGZCONN_CLOSINGZPSUTIL_CONN_NONEr�Z	TCPS_IDLEZ
TCPS_BOUNDry�dictr�r'r*r-r2Zpfullmemr3ru�_fieldsr6r<rCr[rcr`rfrgrhZdisk_io_countersrkrjZnet_io_countersZnet_if_addrsrvr�r�r�r�r�r��objectr�r:r:r:r;�<module>s�



	
&	


$

?>