Your IP : 3.15.211.55


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

3

��JZ�K�@s�dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddlm
Z
ddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZdgZ e!ed�Z"ej#d�Z$ej%Z%ej&ej'ej(ej)ej*ej+ej,ej+ej-ej.iZ/ej0ej1ej2ej3ej4ej5ej6ej7ej8ej9ej:ej;ej<ej=ej>ej?ej@ejAejBejCejDejEejFejGiZHeIddddddddd�ZJed d!d"g�ZKeKZLed#d$d%d&d'g�ZMed(d)d*d+d,d-g�ZNed.d/d!d0d1g�ZOed2d3d4jPeOjQ��ZRd5d6�ZSd7d8�ZTd9d:�ZUd;d<�ZVd=d>�ZWd?d@�ZXdAdB�ZYdCdD�ZZej[Z[e
j\Z\dXdFdG�Z]ej^Z^ej_Z_dZdHdI�Z`dJdK�ZadLdM�ZbdNdO�ZcdPdQ�ZddRdS�ZedTdU�ZfGdVdW�dWeg�ZhdS)[zAIX platform implementation.�N)�
namedtuple)�AF_INET�)�_common)�_psposix)�_psutil_aix)�
_psutil_posix)�AF_INET6)�memoize_when_activated)�NIC_DUPLEX_FULL)�NIC_DUPLEX_HALF)�NIC_DUPLEX_UNKNOWN)�sockfam_to_enum)�socktype_to_enum)�
usage_percent)�PY3)�AccessDenied)�
NoSuchProcess)�
ZombieProcess�PROCFS_PATH�proc_threads�SC_PAGE_SIZE������)�ppid�rss�vms�create_time�nice�num_threads�status�ttynr�pmemrr �	scputimes�user�systemZidleZiowait�svmem�totalZ	available�percent�used�free�
pmmap_grouped�pathZanon�locked�	pmmap_extzaddr perms � cCstjdjS)z+Return updated psutil.PROCFS_PATH constant.Zpsutil)�sys�modulesr�r6r6�/usr/lib64/python3.6/_psaix.py�get_procfs_pathlsr8cCs4tj�\}}}}}t|||dd�}t|||||�S)Nr)�_round)�cextZvirtual_memrr*)r+Zavailr.ZpinnedZinuser,r6r6r7�virtual_memoryvsr;cCs:tj�\}}}}||}t||dd�}tj||||||�S)z=Swap system memory as a (total, used, free, sin, sout) tuple.r)r9)r:Zswap_memrrZsswap)r+r.ZsinZsoutr-r,r6r6r7�swap_memory|sr<cCstj�}tdd�t|�D��S)z-Return system-wide CPU times as a named tuplecSsg|]}t|��qSr6)�sum)�.0�xr6r6r7�
<listcomp>�szcpu_times.<locals>.<listcomp>)r:�
per_cpu_timesr'�zip)�retr6r6r7�	cpu_times�srDcCstj�}dd�|D�S)z5Return system per-CPU times as a list of named tuplescSsg|]}t|��qSr6)r')r>r?r6r6r7r@�sz!per_cpu_times.<locals>.<listcomp>)r:rA)rCr6r6r7rA�srAcCs$y
tjd�Stk
rdSXdS)z0Return the number of logical CPUs in the system.�SC_NPROCESSORS_ONLNN)�os�sysconf�
ValueErrorr6r6r6r7�cpu_count_logical�s
rIcCsrd}tj|dtjtjd�}|j�\}}tr@dd�||fD�\}}|jdkrZtd||f��|j�j�}t	|�ppdS)Nzlsdev -Cc processorT)�shell�stdout�stderrcSsg|]}|jtjj��qSr6)�decoder4rK�encoding)r>r?r6r6r7r@�sz&cpu_count_physical.<locals>.<listcomp>rz%r command error
%s)
�
subprocess�Popen�PIPE�communicater�
returncode�RuntimeError�strip�
splitlines�len)�cmd�prKrLZ
processorsr6r6r7�cpu_count_physical�s

rZcCs tj�\}}}}tj||||�S)z*Return various CPU stats as a named tuple.)r:�	cpu_statsrZ	scpustats)Zctx_switchesZ
interruptsZsoft_interruptsZsyscallsr6r6r7r[�sr[Fc	Cs`g}tj�}xN|D]F}|\}}}}|dkr.d}|s>t|�js>qtj||||�}|j|�qW|S)zReturn system disk partitions.Znone�)r:�disk_partitions�
disk_usager+rZ	sdiskpart�append)	�all�retlistZ
partitions�	partitionZdeviceZ
mountpointZfstypeZopts�ntupler6r6r7r]�s

r]c	Cstj}||kr.td|djdd�|D��f��tj|\}}tj|�}t�}x�|D]�}|\}}	}
}}}
}|	|krrqR|
|kr|qRt|
}
|	tt	fkr�|r�tj
|�}|r�tj
|�}t|	�}	t|
�}
|dkr�tj
||	|
|||
|�}ntj||	|
|||
�}|j|�qRWt|�S)z�Return socket connections.  If pid == -1 return system-wide
    connections (as opposed to connections opened by one process only).
    z+invalid %r kind argument; choose between %sz, cSsg|]}t|��qSr6)�repr)r>r?r6r6r7r@�sz#net_connections.<locals>.<listcomp>r���)rZ	conn_tmaprH�joinr:�net_connections�set�TCP_STATUSESrr	ZaddrrrZsconnZpconn�add�list)�kind�_pidZcmapZfamilies�types�rawlistrC�item�fdZfamZtype_ZladdrZraddrr$�pid�ntr6r6r7rg�s4



rgcCs�ttd�}tdd�t�D��}i}x�|D]�}tj|�\}}d}d}tjdd|gtjtjd�}|j	�\}	}
t
r�d	d�|	|
fD�\}	}
|jdkr�tj
d
|	�}|dk	r�t|jd��}|jd
�}|j|t�}tj||||�||<q(W|S)z)Get NIC stats (isup, duplex, speed, mtu).)ZFullZHalfcSsg|]}|d�qS)rr6)r>r?r6r6r7r@�sz net_if_stats.<locals>.<listcomp>r\rz/usr/bin/entstatz-d)rKrLcSsg|]}|jtjj��qSr6)rMr4rKrN)r>r?r6r6r7r@
sz"Running: (\d+) Mbps.*?(\w+) DuplexNrr)rrrh�net_if_addrsr:�net_if_statsrOrPrQrRrrS�re�search�int�group�getr
rZ	snicstats)Z
duplex_map�namesrC�nameZisupZmtuZduplexZspeedrYrKrLZ	re_resultr6r6r7ru�s,


rucCstj�S)z:The system boot time expressed in seconds since the epoch.)r:�	boot_timer6r6r6r7r}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)r:�usersrZsuserr_)raror�rpr(ZttyZhostnameZtstampZuser_processrrrsr6r6r7r�$s
r�cCsdd�tjt��D�S)z7Returns a list of PIDs currently running on the system.cSsg|]}|j�rt|��qSr6)�isdigitrx)r>r?r6r6r7r@>szpids.<locals>.<listcomp>)rF�listdirr8r6r6r6r7�pids<sr�cCstjjtjjt�t|�d��S)z&Check for the existence of a unix pid.Zpsinfo)rFr0�existsrfr8�str)rrr6r6r7�
pid_existsAsr�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�tdks:tdks:tdkr<�|jtjtjfkrzt|j�sht|j|j	��nt|j|j	|j
��|jtjtjfkr�t|j|j	���WYdd}~XnXdS)N)
�EnvironmentErrorrrr�errno�ENOENTZESRCHr�rr�_name�_ppidZEPERMZEACCES)�self�args�kwargs�err)�funr6r7�wrapperKs
z wrap_exceptions.<locals>.wrapperr6)r�r�r6)r�r7�wrap_exceptionsFsr�c@sheZdZdZddddgZdd�Zdd	�Zd
d�Zedd
��Z	edd��Z
edd��Zedd��Z
edd��Zedd��Zedd��Zedd��Zer�edd��Zed@dd ��Zed!d"��Zed#d$��Zed%d&��Zed'd(��Zed)d*��Zed+d,��Zed-d.��Zed/d0��Zed1d2��ZeZed3d4��Zd5d6�Z ed7d8��Z!ed9d:��Z"edAd<d=��Z#ed>d?��Z$d;S)B�Processz1Wrapper class around underlying C implementation.rrr�r��_procfs_pathcCs||_d|_d|_t�|_dS)N)rrr�r�r8r�)r�rrr6r6r7�__init__fszProcess.__init__cCs"|jj�|jj�|jj�dS)N)�_proc_name_and_argsZcache_activate�_proc_basic_info�
_proc_cred)r�r6r6r7�
oneshot_enterls

zProcess.oneshot_entercCs"|jj�|jj�|jj�dS)N)r�Zcache_deactivater�r�)r�r6r6r7�oneshot_exitqs

zProcess.oneshot_exitcCstj|j|j�S)N)r:Zproc_name_and_argsrrr�)r�r6r6r7r�vszProcess._proc_name_and_argscCstj|j|j�S)N)r:Zproc_basic_inforrr�)r�r6r6r7r�zszProcess._proc_basic_infocCstj|j|j�S)N)r:Z	proc_credrrr�)r�r6r6r7r�~szProcess._proc_credcCs |jdkrdS|j�djd�S)NrZswapper�)rrr��rstrip)r�r6r6r7r|�s
zProcess.namecCs�|j�d}tjj|krttjj|�s>tjjtjj|j�|��}tjj|�rhtjj|�rhtj	|tj
�rh|Stjj|�}xLtjdj
d�D]8}tjjtjj||��}tjj|�r�tj	|tj
�r�|Sq�WdS)Nr�PATH�:r\)�cmdlinerFr0�sep�isabs�abspathrf�cwd�isfile�access�X_OK�basename�environ�split)r��exer0Zpossible_exer6r6r7r��szProcess.execCs|j�djd�S)Nrr3)r�r�)r�r6r6r7r��szProcess.cmdlinecCs|j�tdS)Nr!)r��
proc_info_map)r�r6r6r7r!�szProcess.create_timecCs|j�tdS)Nr#)r�r�)r�r6r6r7r#�szProcess.num_threadscCsZtj|j�}g}x*|D]"\}}}tj|||�}|j|�qW|sVtjd|j|jf�|S)Nz%s/%s)	r:rrrrZpthreadr_rF�statr�)r�roraZ	thread_id�utimeZstimercr6r6r7�threads�szProcess.threads�inetcCs,t||jd�}|s(tjd|j|jf�|S)N)rmz%s/%s)rgrrrFr�r�)r�rlrCr6r6r7�connections�szProcess.connectionscCstj|j�S)N)�
cext_posix�getpriorityrr)r�r6r6r7�nice_get�szProcess.nice_getcCstj|j|�S)N)r��setpriorityrr)r��valuer6r6r7�nice_set�szProcess.nice_setcCs|j�td|_|jS)Nr)r�r�r�)r�r6r6r7r�szProcess.ppidcCs"|j�\}}}}}}tj|||�S)N)r�r�puids)r��real�	effective�saved�_r6r6r7�uids�szProcess.uidscCs"|j�\}}}}}}tj|||�S)N)r�rr�)r�r�r�r�r�r6r6r7�gids�szProcess.gidscCstj|j|j�}tj|�S)N)r:Zproc_cpu_timesrrr�rZ	pcputimes)r�rDr6r6r7rD�szProcess.cpu_timescCsP|j�td}|d@d?|d@B}x&tjd�D]}tj|�j|kr0|Sq0WdS)Nr%l��i��z	/dev/**/*)r�r��globrFr��st_rdev)r�ZttydevZdevr6r6r7�terminal�szProcess.terminalcCsr|j}ytjd||jf�}|jd�Stk
rl}z,|jtjkrZtjd||jf�dS�WYdd}~XnXdS)Nz	%s/%s/cwd�/z%s/%s)	r�rF�readlinkrrr��OSErrorr�r�r�)r�Zprocfs_path�resultr�r6r6r7r��s
zProcess.cwdcCs2|j�}|tdd}|tdd}t||�S)Nrir )r�r�r&)r�rCrr r6r6r7�memory_info�szProcess.memory_infocCs|j�td}tj|d�S)Nr$�?)r�r��
PROC_STATUSESrz)r��coder6r6r7r$szProcess.statuscCs�tjddt|j�gtjtjd�}|j�\}}trFdd�||fD�\}}d|j�kr`t|j|j	��t
jd|�}g}xR|D]J\}}|j�}|j
d�r�|d	d�}|j�d
kr�qv|jtj|t|���qvW|S)Nz/usr/bin/procfilesz-n)rKrLcSsg|]}|jtjj��qSr6)rMr4rKrN)r>r?r6r6r7r@sz&Process.open_files.<locals>.<listcomp>zno such processz(\d+): S_IFREG.*\s*.*name:(.*)
z//rzcannot be retrieved)rOrPr�rrrQrRr�lowerrr�rv�findallrU�
startswithr_rZ	popenfilerx)r�rYrKrLZ	procfilesrarqr0r6r6r7�
open_filess$
zProcess.open_filescCs(|jdkrdSttjd|j|jf��S)Nrz%s/%s/fd)rrrWrFr�r�)r�r6r6r7�num_fds$s
zProcess.num_fdscCstjtj|j��S)N)rZpctxswr:Zproc_num_ctx_switchesrr)r�r6r6r7�num_ctx_switches*szProcess.num_ctx_switchesNcCstj|j||j�S)N)rZwait_pidrrr�)r�Ztimeoutr6r6r7�wait/szProcess.waitc
CsXytj|j�\}}}}Wn.tk
rFt|j�s@t|j|j���YnXtj||||�S)N)	r:Zproc_io_countersrrr�r�rr�rZpio)r�ZrcZwc�rb�wbr6r6r7�io_counters3s
zProcess.io_counters)r�)N)%�__name__�
__module__�__qualname__�__doc__�	__slots__r�r�r�r
r�r�r�r�r|r�r�r!r#�HAS_THREADSr�r�r�r�rr�r�rDr�r�r�Zmemory_full_infor$r�r�r�r�r�r6r6r6r7r�asDr�)Fre)re)ir�r�r�rFrvrOr4�collectionsrZsocketrr\rrrr:rr�r	r
rrr
rrrZ_compatr�_exceptionsrrrZ__extra__all__�hasattrr�rGZ	PAGE_SIZEZAF_LINKZSIDLZSTATUS_IDLEZSZOMBZ
STATUS_ZOMBIEZSACTIVEZSTATUS_RUNNINGZSSWAPZSSTOPZSTATUS_STOPPEDr�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_NONEZ	CONN_NONEri�dictr�r&Zpfullmemr'r*r/rf�_fieldsr2r8r;r<rDrArIrZr[Zdisk_io_countersr^r]rtZnet_io_countersrgrur}r�r�r�r��objectr�r6r6r6r7�<module>s�

	

	

!$

?>