ok

Mini Shell

Direktori : /proc/self/root/proc/self/root/proc/self/root/lib/python2.7/site-packages/procfs/
Upload File :
Current File : //proc/self/root/proc/self/root/proc/self/root/lib/python2.7/site-packages/procfs/procfs.pyc

�
���Yc@s�ddlZddlZddlZdZd�Zdd'd��YZdd(d��YZdd)d	��YZd
d*d��YZdd+d
��YZ	dd,d��YZ
dd-d��YZdd.d��YZdd/d��YZ
dd0d��YZdd1d��YZedkr�ddlZe	�Zx-ej	j�D]Zdeej	efGHq5We
�Zx-ejj�D]ZdeejefGHqnWe�ZdejGHx'ej�D]ZdeeefGHq�Wddd GHe
eejd!��Zx:eej�D])Zd"ejej ejej!fGHqWdd GHx'ej"ejd#�D]Z#e#d$GHqPWe�Z$e$d!GHe�Z%xOe&r�ej'd!�e%j(�x#e%D]Zd%ej!ej)fGHq�Wd2GHq�WndS(3i����Ns0.3cCs0|dr$td�|d�j�S|ddS(s�
	Returns the process command line, if available in the given `process' class, if
	not available, falls back to using the comm (short process name) in its pidstat key.
	tcmdlinecSs|d|S(Ns %s((tatb((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyt<lambda>ststattcomm(treducetstrip(tpid_info((s1/usr/lib/python2.7/site-packages/procfs/procfs.pytprocess_cmdlines
tpidstatc+Bs�eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$d Z%d Z&d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKg+Z'dLdM�Z(dN�Z)dO�Z*dP�Z+dQ�Z,dR�Z-dS�Z.dLdT�Z/dU�Z0dV�Z1RS(WsProvides a dictionary to access the fields in the per process /proc/PID/stat
	   files.

	   One can obtain the available fields asking for the keys of the dictionary, e.g.:

		>>> p = procfs.pidstat(1)
		>>> print p.keys()
		['majflt', 'rss', 'cnswap', 'cstime', 'pid', 'session', 'startstack', 'startcode', 'cmajflt', 'blocked', 'exit_signal', 'minflt', 'nswap', 'environ', 'priority', 'state', 'delayacct_blkio_ticks', 'policy', 'rt_priority', 'ppid', 'nice', 'cutime', 'endcode', 'wchan', 'num_threads', 'sigcatch', 'comm', 'stime', 'sigignore', 'tty_nr', 'kstkeip', 'utime', 'tpgid', 'itrealvalue', 'kstkesp', 'rlim', 'signal', 'pgrp', 'flags', 'starttime', 'cminflt', 'vsize', 'processor']

	   And then access the various process properties using it as a dictionary:

		>>> print p['comm']
		systemd
		>>> print p['priority']
		20
		>>> print p['state']
		S

	   Please refer to the 'procfs(5)' man page, by using:

		$ man 5 procfs

	   To see information for each of the above fields, it is part of the
           'man-pages' RPM package.
	iiiiii i@i�iiiiii i@i�iiiiii i@i�iiiiii i@ltpidRtstatetppidtpgrptsessionttty_nrttpgidtflagstminflttcminflttmajflttcmajflttutimetstimetcutimetcstimetprioritytnicetnum_threadstitrealvaluet	starttimetvsizetrsstrlimt	startcodetendcodet
startstacktkstkesptkstkeiptsignaltblockedt	sigignoretsigcatchtwchantnswaptcnswaptexit_signalt	processortrt_prioritytpolicytdelayacct_blkio_tickstenvirons/proccCs||_|j|�dS(N(Rtload(tselfRtbasedir((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyt__init__rs	cCs|j|S(N(tfields(R6t	fieldname((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyt__getitem__vscCs
|jj�S(N(R9tkeys(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR<yscCs
|jj�S(N(R9tvalues(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR=|scCs|jj|�S(N(R9thas_key(R6R:((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR>scCs|jS(N(R9(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pytitems�scCs
||jkS(N(R9(R6R:((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyt__contains__�scCstd||jf�}|j�j�jd�}|j�|djd�|dj�}i|_tt|�t|j	��}x~t
|�D]p}|j	|}||}|dkr�|jd�|jd<q�yt|�|j|<Wq�||j|<q�Xq�WdS(Ns
%s/%d/stats) is (iRs()(topenRtreadlineRtsplittcloseR9tmintlentproc_stat_fieldstrangetint(R6R7tfR9t	nr_fieldstitattrnametvalue((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR5�s
!	

cCs|jd|j@rtptS(s�
		Returns true if this process has a fixed smp affinity mask,
                not allowing it to be moved to a different set of CPUs.
		R(R9tPF_THREAD_BOUNDtTruetFalse(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pytis_bound_to_cpu�scCsgg}xZt|�D]L}|d dkr/qnt||�}||jd@r|j|�qqW|S(s.
		Returns a list with all the process flags known, details depend
		on kernel version, declared in the file include/linux/sched.h in
		the kernel sources.

		As of v4.2-rc7 these include (from include/linux/sched.h comments):

			PF_EXITING	   Getting shut down
			PF_EXITPIDONE	   Pi exit done on shut down
			PF_VCPU		   I'm a virtual CPU
			PF_WQ_WORKER	   I'm a workqueue worker
			PF_FORKNOEXEC	   Forked but didn't exec
			PF_MCE_PROCESS	   Process policy on mce errors
			PF_SUPERPRIV	   Used super-user privileges
			PF_DUMPCORE	   Dumped core
			PF_SIGNALED	   Killed by a signal
			PF_MEMALLOC	   Allocating memory
			PF_NPROC_EXCEEDED  Set_user noticed that RLIMIT_NPROC was exceeded
			PF_USED_MATH	   If unset the fpu must be initialized before use
			PF_USED_ASYNC	   Used async_schedule*(), used by module init
			PF_NOFREEZE	   This thread should not be frozen
			PF_FROZEN	   Frozen for system suspend
			PF_FSTRANS	   Inside a filesystem transaction
			PF_KSWAPD	   I am kswapd
			PF_MEMALLOC_NOIO   Allocating memory without IO involved
			PF_LESS_THROTTLE   Throttle me less: I clean memory
			PF_KTHREAD	   I am a kernel thread
			PF_RANDOMIZE	   Randomize virtual address space
			PF_SWAPWRITE	   Allowed to write to swap
			PF_NO_SETAFFINITY  Userland is not allowed to meddle with cpus_allowed
			PF_MCE_EARLY	   Early kill for mce process policy
			PF_MUTEX_TESTER	   Thread belongs to the rt mutex tester
			PF_FREEZER_SKIP	   Freezer should not count it as freezable
			PF_SUSPEND_TASK	   This thread called freeze_processes and should not be frozen
	
		itPF_R(tdirtgetattrR9tappend(R6tsflagstattrRN((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyt
process_flags�s%(2t__name__t
__module__t__doc__tPF_ALIGNWARNtPF_STARTINGt
PF_EXITINGt
PF_EXITPIDONEtPF_VCPUtPF_WQ_WORKERt
PF_FORKNOEXECtPF_MCE_PROCESStPF_SUPERPRIVtPF_DUMPCOREtPF_SIGNALEDtPF_MEMALLOCtPF_NPROC_EXCEEDEDt
PF_FLUSHERtPF_USED_MATHt
PF_USED_ASYNCtPF_NOFREEZEt	PF_FROZENt
PF_FSTRANSt	PF_KSWAPDtPF_MEMALLOC_NOIOt
PF_SWAPOFFtPF_LESS_THROTTLEt
PF_KTHREADtPF_RANDOMIZEtPF_SWAPWRITEtPF_SPREAD_PAGEtPF_SPREAD_SLABROtPF_NO_SETAFFINITYtPF_MCE_EARLYtPF_MEMPOLICYtPF_MUTEX_TESTERtPF_FREEZER_SKIPtPF_FREEZER_NOSIGtPF_SUSPEND_TASKRGR8R;R<R=R>R?R@R5RRRY(((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR
#st								t	pidstatuscBs\eZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	dd	�Z
RS(
s�
	Provides a dictionary to access the fields in the per process /proc/PID/status
	files. This provides additional information about processes and threads to what
	can be obtained with the procfs.pidstat() class.

	One can obtain the available fields asking for the keys of the dictionary, e.g.:

		>>> import procfs
		>>> p = procfs.pidstatus(1)
		>>> print p.keys()
		['VmExe', 'CapBnd', 'NSpgid', 'Tgid', 'NSpid', 'VmSize', 'VmPMD', 'ShdPnd', 'State', 'Gid', 'nonvoluntary_ctxt_switches', 'SigIgn', 'VmStk', 'VmData', 'SigCgt', 'CapEff', 'VmPTE', 'Groups', 'NStgid', 'Threads', 'PPid', 'VmHWM', 'NSsid', 'VmSwap', 'Name', 'SigBlk', 'Mems_allowed_list', 'VmPeak', 'Ngid', 'VmLck', 'SigQ', 'VmPin', 'Mems_allowed', 'CapPrm', 'Seccomp', 'VmLib', 'Cpus_allowed', 'Uid', 'SigPnd', 'Pid', 'Cpus_allowed_list', 'TracerPid', 'CapInh', 'voluntary_ctxt_switches', 'VmRSS', 'FDSize']
		>>> print p["Pid"]
		1
		>>> print p["Threads"]
		1
		>>> print p["VmExe"]
		1248 kB
		>>> print p["Cpus_allowed"]
		f
		>>> print p["SigQ"]
		0/30698
		>>> print p["VmPeak"]
		320300 kB
		>>>

	Please refer to the 'procfs(5)' man page, by using:

		$ man 5 procfs

	To see information for each of the above fields, it is part of the
	'man-pages' RPM package.

	In the man page there will be references to further documentation, like
        referring to the "getrlimit(2)" man page when explaining the "SigQ"
        line/field.
	s/proccCs||_|j|�dS(N(RR5(R6RR7((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR8�s	cCs|j|S(N(R9(R6R:((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR;�scCs
|jj�S(N(R9R<(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR<�scCs
|jj�S(N(R9R=(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR=scCs|jj|�S(N(R9R>(R6R:((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR>scCs|jS(N(R9(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR?scCs
||jkS(N(R9(R6R:((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR@
scCs�td||jf�}i|_x�|j�D]u}|jd�}t|�dkr\q/n|d}|dj�}yt|�|j|<Wq/||j|<q/Xq/W|j�dS(Ns%s/%d/statust:iii(	RARR9t	readlinesRCRFRRIRD(R6R7RJtlineR9tnameRN((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR5
s	
(RZR[R\R8R;R<R=R>R?R@R5(((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR��s$						tprocesscBsYeZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
RS(
s
	Information about a process with a given pid, provides a dictionary with
	two entries, instances of different wrappers for /proc/ process related
	meta files: "stat" and "status", see the documentation for procfs.pidstat
	and procfs.pidstatus for further info about those classes.
	s/proccCs||_||_dS(N(RR7(R6RR7((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR8$s	cCs�t||�s�|dkrX|dkr0t}nt}t||||j|j��q�|dkrq|j�q�|dkr�|j�q�|dkr�|j�q�|dkr�|j	�q�nt
||�S(NRtstatusRtthreadstcgroupsR4(sstatR�(thasattrR
R�tsetattrRR7tload_cmdlinetload_threadstload_cgroupstload_environRU(R6RXtsclass((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR;(s	"


cCs
t||�S(N(R�(R6RX((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR><scCs
t||�S(N(R�(R6RX((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR@?scCsCtd|j�}|j�j�jd�d |_|j�dS(Ns/proc/%d/cmdlineti����(tfileRRBRRCRRD(R6RJ((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR�Bs"cCs'td|j�|_|j|j=dS(Ns/proc/%d/task/(tpidstatsRR�(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR�GscCs~td|j�}d|_xQt|j��D]=}t|j�r_|jd|d |_q/|d |_q/W|j�dS(Ns/proc/%d/cgrouptt,i����(R�RR�treversedR�RFRD(R6RJR�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR�Ls	cCs�i|_td|j�}xV|j�jd�D]?}t|�dkr2|jd�}|d|j|d<q2q2W|j�dS(s�
		Loads the environment variables for this process. The entries then
		become available via the 'environ' member, or via the 'environ'
		dict key when accessing as p["environ"].

		E.g.:


		>>> all_processes = procfs.pidstats()
		>>> firefox_pid = all_processes.find_by_name("firefox")
		>>> firefox_process = all_processes[firefox_pid[0]]
		>>> print firefox_process["environ"]["PWD"]
		/home/acme
		>>> print len(firefox_process.environ.keys())
		66
		>>> print firefox_process["environ"]["SHELL"]
		/bin/bash
		>>> print firefox_process["environ"]["USERNAME"]
		acme
		>>> print firefox_process["environ"]["HOME"]
		/home/acme
		>>> print firefox_process["environ"]["MAIL"]
		/var/spool/mail/acme
		>>>
		s/proc/%d/environR�it=iN(R4R�RRBRCRFRD(R6RJtxty((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR�Vs	(RZR[R\R8R;R>R@R�R�R�R�(((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR�s						
R�cBs�eZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�ZRS(s
	Provides access to all the processes in the system, to get a picture of
	how many processes there are at any given moment.

	The entries can be accessed as a dictionary, keyed by pid. Also there are
	methods to find processes that match a given COMM or regular expression.
	s/proccCs ||_i|_|j�dS(N(R7t	processestreload(R6R7((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR8�s		cCs|j|S(N(R�(R6tkey((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR;�scCsy|j|=WnnXdS(N(R�(R6R�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyt__delitem__�scCs
|jj�S(N(R�R<(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR<�scCs
|jj�S(N(R�R=(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR=�scCs|jj|�S(N(R�R>(R6R�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR>�scCs|jS(N(R�(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR?�scCs
||jkS(N(R�(R6R�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR@�scCsl|`i|_tj|j�}xD|D]<}yt|�}Wn
q(nXt||j�|j|<q(WdS(s�
		This operation will throw away the current dictionary contents, if any, and
		read all the pid files from /proc/, instantiating a 'process' instance for
		each of them.

		This is a high overhead operation, and should be avoided if the perf python
		binding can be used to detect when new threads appear and existing ones
		terminate.

		In RHEL it is found in the python-perf rpm package.

		More information about the perf facilities can be found in the 'perf_event_open'
		man page.
		N(R�tostlistdirR7RIR�(R6tpidstspidR((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR��s	
cCsQxJ|jj�D]9}y|j|j�Wqtk
rH|j|=qXqWdS(N(R�R<R�tOSError(R6R((s1/usr/lib/python2.7/site-packages/procfs/procfs.pytreload_threads�s

cCs{|d }g}xd|jj�D]S}y/||j|ddkrT|j|�nWq tk
rr|j|=q Xq W|S(NiRR(R�R<RVtIOError(R6R�R�R((s1/usr/lib/python2.7/site-packages/procfs/procfs.pytfind_by_name�s

cCstg}xg|jj�D]V}y2|j|j|dd�rM|j|�nWqtk
rk|j|=qXqW|S(NRR(R�R<tmatchRVR�(R6tregexR�R((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyt
find_by_regex�s
cCsrg}xe|jj�D]T}y0|jt|j|��rK|j|�nWqtk
ri|j|=qXqW|S(N(R�R<R�R	RVR�(R6R�R�R((s1/usr/lib/python2.7/site-packages/procfs/procfs.pytfind_by_cmdline_regex�s
c	Cs�d}d}g}x�tr�d||f}|j|�}|srtg|D]}||krK|^qK�dkrvPnxM|D]E}y!|d|j|dd7}Wq}tk
r�|j|=q}Xq}W||7}|d7}qW|jd�}|S(	NiR�s%s/%ds%s,RR1iR�(RPR�RFR�R�R(	R6tbasenametcput
prioritiestprocessed_pidsR�R�tnR((s1/usr/lib/python2.7/site-packages/procfs/procfs.pytget_per_cpu_rtprios�s"	8
!

cCs�d}d}g}x�tr�|j|�}|sbtg|D]}||kr;|^q;�dkrfPnxM|D]E}y!|d|j|dd7}Wqmtk
r�|j|=qmXqmW||7}|d7}qW|jd�}|S(NiR�s%s,RR1iR�(RPR�RFR�R�R(R6R�R�R�R�R�R�R((s1/usr/lib/python2.7/site-packages/procfs/procfs.pytget_rtprioss 	8
!

cCs|j|dj�S(sE
		Checks if a given pid can't have its SMP affinity mask changed.
		R(R�RR(R6R((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyRRs(RZR[R\R8R;R�R<R=R>R?R@R�R�R�R�R�R�R�RR(((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR�xs"											
	
		t
interruptscBszeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�ZRS(
s4
	Information about IRQs in the system. A dictionary keyed by IRQ number
	will have as its value another dictionary with "cpu", "type" and "users"
	keys, with the SMP affinity mask, type of IRQ and the drivers associated
	with each interrupt.

	The information comes from the /proc/interrupts file, documented in
	'man procfs(5)', for instance, the 'cpu' dict is an array with one entry
	per CPU present in the sistem, each value being the number of interrupts
	that took place per CPU.

	E.g.:

	>>> import procfs
	>>> interrupts = procfs.interrupts()
	>>> thunderbolt_irq = interrupts.find_by_user("thunderbolt")
	>>> print thunderbolt_irq
	34
	>>> thunderbolt = interrupts[thunderbolt_irq]
	>>> print thunderbolt
	{'affinity': [0, 1, 2, 3], 'type': 'PCI-MSI', 'cpu': [3495, 0, 81, 0], 'users': ['thunderbolt']}
	>>>
	cCsi|_|j�dS(N(R�R�(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR84s	cCs|jt|�S(N(R�tstr(R6R�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR;8scCs
|jj�S(N(R�R<(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR<;scCs
|jj�S(N(R�R=(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR=>scCs|jjt|��S(N(R�R>R�(R6R�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR>AscCs|jS(N(R�(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR?DscCst|�|jkS(N(R�R�(R6R�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR@GscCs�|`i|_td�}x�|j�D]�}|j�}|j�}|dd dkrot|�|_q(n|djd�}i|j|<|j|d|�|j|<yt|�}Wn
q(nX|j	|�|j|d<q(W|j
�dS(Ns/proc/interruptsiitCPUR�itaffinity(R�RAR�RRCRFtnr_cpustparse_entryRItparse_affinityRD(R6RJR�R9tirqtnirq((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR�Js$	
cCs�i}g|d<|djt|d��t|�}||jkr�|dcg|d|j!D]}t|�^qa7<||jkr�||j|d<||jdkr�g||djd�D]}|j�^q�|d<q�g|d<q�n|S(NR�iittypeR�tusers(RVRIRFR�RCR(R6R9R�tdictRKRLR((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR�`s
37cCsYy=td|�}|j�}|j�tj||j�SWntk
rTdgSXdS(Ns/proc/irq/%s/smp_affinityi(R�RBRDtutilisttbitmasklistR�R�(R6R�RJR�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR�ps

cCsOxH|jj�D]7}|j|jd�r||j|dkr|SqWdS(s�
		Looks up a interrupt number by the name of one of its users"

		E.g.:

		>>> import procfs
		>>> interrupts = procfs.interrupts()
		>>> thunderbolt_irq = interrupts.find_by_user("thunderbolt")
		>>> print thunderbolt_irq
		34
		>>> thunderbolt = interrupts[thunderbolt_irq]
		>>> print thunderbolt
		{'affinity': [0, 1, 2, 3], 'type': 'PCI-MSI', 'cpu': [3495, 0, 81, 0], 'users': ['thunderbolt']}
		>>>
		R�N(R�R<R>tNone(R6tuserRL((s1/usr/lib/python2.7/site-packages/procfs/procfs.pytfind_by_userys
cCs|g}xo|jj�D]^}|j|jd�s8qnx9|j|dD]&}|j|�rJ|j|�PqJqJWqW|S(s�
		Looks up a interrupt number by a regex that matches names of its users"

		E.g.:

		>>> import procfs
		>>> import re
		>>> interrupts = procfs.interrupts()
		>>> usb_controllers = interrupts.find_by_user_regex(re.compile(".*hcd"))
		>>> print usb_controllers
		['22', '23', '31']
		>>> print [ interrupts[irq]["users"] for irq in usb_controllers ]
		[['ehci_hcd:usb4'], ['ehci_hcd:usb3'], ['xhci_hcd']]
		>>>
		R�(R�R<R>R�RV(R6R�tirqsRLR�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pytfind_by_user_regex�s
(RZR[R\R8R;R<R=R>R?R@R�R�R�R�R�(((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR�s												RcBsDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(s
	Parses the kernel command line (/proc/cmdline), turning it into a dictionary."

	Useful to figure out if some kernel boolean knob has been turned on, as well
	as to find the value associated to other kernel knobs.

	It can also be used to find out about parameters passed to the init process,
	such as 'BOOT_IMAGE', etc.

	E.g.:
	>>> import procfs
	>>> kcmd = procfs.cmdline()
	>>> print kcmd.keys()
	['LANG', 'BOOT_IMAGE', 'quiet', 'rhgb', 'rd.lvm.lv', 'ro', 'root']
	>>> print kcmd["BOOT_IMAGE"]
	/vmlinuz-4.3.0-rc1+
	>>>
	cCsi|_|j�dS(N(toptionstparse(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR8�s	cCs�td�}xj|j�j�j�D]P}|jd�}t|�dkr`t|j|d<q%|d|j|d<q%W|j�dS(Ns
/proc/cmdlineR�ii(R�RBRRCRFRPR�RD(R6RJtoptionR9((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR��scCs|j|S(N(R�(R6R�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR;�scCs
|jj�S(N(R�R<(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR<�scCs
|jj�S(N(R�R=(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR=�scCs|jS(N(R�(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR?�s(	RZR[R\R8R�R;R<R=R?(((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR�s					tcpuinfocBsGeZdZdd�Zd�Zd�Zd�Zd�Zd�ZRS(s�
	Dictionary with information about CPUs in the system.

	Please refer to 'man procfs(5)' for further information about the
        '/proc/cpuinfo' file, that is the source of the information provided by this
        class. The 'man lscpu(1)' also has information about a program that uses
	the '/proc/cpuinfo' file.

	Using this class one can obtain the number of CPUs in a system:

	  >>> cpus = procfs.cpuinfo()
          >>> print cpus.nr_cpus
          4

	It is also possible to figure out aspects of the CPU topology, such as
	how many CPU physical sockets exists, i.e. groups of CPUs sharing components
	such as CPU memory caches:

	  >>> print len(cpus.sockets)
	  1

	Additionally dictionary with information common to all CPUs in the system is
	available:

	  >>> print cpus["model name"]
          Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz
          >>> print cpus["cache size"]
          4096 KB
          >>>
	s
/proc/cpuinfocCs,i|_d|_g|_|j|�dS(Ni(ttagsR�tsocketsR�(R6tfilename((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR8�s			cCs|j|j�S(N(R�tlower(R6R�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR;�scCs
|jj�S(N(R�R<(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR<scCs
|jj�S(N(R�R=(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR=scCs|jS(N(R�(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR?scCs~t|�}x�|j�D]�}|j�}t|�dkrCqn|jd�}|dj�j�}|dkr�|jd7_qn|dkr�qn|dj�|j|<|dkr|j|}||jkr�|jj	|�q�qqW|j
�|jrt|j�pB|jd|jkr>t|jd�pAd|_d|jkrjt|jd�pmd|j|_
dS(	NiR�R0iscore idsphysical idtsiblingss	cpu cores(R�R�RRFRCR�R�R�R�RVRDRIt
nr_socketstnr_cores(R6R�RJR�R9ttagnamet	socket_id((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR�	s*

2(	RZR[R\R8R;R<R=R?R�(((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR��s				t	smaps_libcBs;eZdZd�Zd�Zd�Zd�Zd�ZRS(s^
	Representation of an mmap in place for a process. Can be used to figure
	out which processes have an library mapped, etc.

	The 'perm' member can be used to figure out executable mmaps, i.e. libraries.

	The 'vm_start' and 'vm_end' in turn can be used when trying to resolve
	processor instruction pointer addresses to a symbol name in a library.
	cCs/|dj�}td�|djd��\|_|_|d|_t|dd�|_|djd�\|_|_t|d	�|_	t
|�d
kr�|d
|_n	d|_i|_
xd|dD]X}|j�}|dd j�}yt|d�|j
|<Wq�||j
|<q�Xq�WdS(NicSs
t|d�S(Ni(RI(R((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR-st-iiiiR�iii����(RCtmaptvm_starttvm_endtpermsRItoffsettmajortminortinodeRFR�R�R�R�(R6tlinesR9R�ttag((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR8+s"+
		cCs|j|j�S(N(R�R�(R6R�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR;@scCs
|jj�S(N(R�R<(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR<CscCs
|jj�S(N(R�R=(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR=FscCs|jS(N(R�(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR?Is(RZR[R\R8R;R<R=R?(((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR�!s					tsmapscBsDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(sl
	List of libraries mapped by a process. Parses the lines in
	the /proc/PID/smaps file, that is further documented in the
	procfs(5) man page.

	Example: Listing the executable maps for the 'sshd' process:

          >>> import procfs
          >>> processes = procfs.pidstats()
          >>> sshd = processes.find_by_name("sshd")
          >>> sshd_maps = procfs.smaps(sshd[0])
          >>> for i in range(len(sshd_maps)):
          ...     if 'x' in sshd_maps[i].perms:
          ...         print "%s: %s" % (sshd_maps[i].name, sshd_maps[i].perms)
          ...
          /usr/sbin/sshd: r-xp
          /usr/lib64/libnss_files-2.20.so: r-xp
          /usr/lib64/librt-2.20.so: r-xp
          /usr/lib64/libkeyutils.so.1.5: r-xp
          /usr/lib64/libkrb5support.so.0.1: r-xp
          /usr/lib64/libfreebl3.so: r-xp
          /usr/lib64/libpthread-2.20.so: r-xp
	  ...
	cCs ||_g|_|j�dS(N(RtentriesR�(R6R((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR8fs		cCs�g}|s!|j�j�}n|s+dS|j|�xWtr�|j�}|sWPn|j�}|j�dddkr�|j|�q;Pq;W|jjt|��|S(Nii����R�(RBRRVRPRCR�R�(R6RJR�R�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR�ks 
	cCs
t|j�S(N(RFR�(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyt__len__~scCs|j|S(N(R�(R6tindex((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR;�scCsbtd|j�}d}x&trA|j||�}|sPqqW|j�t|j�|_dS(Ns/proc/%d/smaps(	R�RR�RPR�RDRFR�t
nr_entries(R6RJR�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR��s	
cCsjg}x]t|j�D]L}|j|jr|j|jj|�dkr|j|j|�qqW|S(Ni(RHR�R�R�tfindRV(R6tfragmenttresultRL((s1/usr/lib/python2.7/site-packages/procfs/procfs.pytfind_by_name_fragment�s(	RZR[R\R8R�R�R;R�R�(((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR�Ms					
tcpustatcBs eZdZd�Zd�ZRS(s�
	CPU statistics, obtained from a line in the '/proc/stat' file, Please
	refer to 'man procfs(5)' for further information about the '/proc/stat'
	file, that is the source of the information provided by this class.
	cCs�|d|_g|dd!D]}t|�^q\|_|_|_|_|_|_|_t	|�dkr�t|d�|_
t	|�dkr�t|d�|_q�ndS(Niiii(R�RIR�RtsystemtidletiowaitR�tsoftirqRFtstealtguest(R6R9RL((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR8�s
PcCs�d|j|j|j|j|j|j|jf}t|d�rW|d|j7}nt|d�rz|d|j	7}n|dS(NsL< user: %s, nice: %s, system: %s, idle: %s, iowait: %s, irq: %s, softirq: %sR�s, steal: %dR�s, guest: %dt>(
R�RR�R�R�R�R�R�R�R�(R6ts((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyt__repr__�s1(RZR[R\R8R�(((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR��s	t	cpusstatscBsYeZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
RS(
s<
	Dictionary with information about CPUs in the system. First entry in the
	dictionary gives an aggregate view of all CPUs, each other entry is about
	separate CPUs. Please refer to 'man procfs(5)' for further information
	about the '/proc/stat' file, that is the source of the information provided
	by this class.
	s
/proc/statcCs;i|_d|_tjd�|_||_|j�dS(Ni(R�R�ttimeR�tsysconfthertzR�R�(R6R�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR8�s
			cCs
t|j�S(N(titerR�(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyt__iter__�scCs|j|S(N(R�(R6R�((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR;�scCst|jj��S(N(RFR�R<(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR��scCs
|jj�S(N(R�R<(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR<�scCs
|jj�S(N(R�R=(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR=�scCs|jS(N(R�(R6((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR?�scCs�|j}i|_t|j�}x�|j�D]�}|j�j�}|dd j�dkrfq.nt|�}|jdkr�d}nt	|jd�d}||j|<q.W|j
�|j}tj�|_|r�|j|}||j}	x�|jj
�D]�}
|
|kr%d|_qn|j|
}||
}|j|j|j|j|j|j}
|
|	d|_|jdkrd|_qqWndS(NiiR�iid(R�R�R�R�RRCR�R�R�RIRDR�R�R<tusageR�RR�(R6tlast_entriesRJR�R9tctidxt	last_timet	delta_sectinterval_hzR�tcurrtprevtdelta((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR��s:			
	

	

(RZR[R\R8R�R;R�R<R=R?R�(((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyR��s						t__main__s%s: %ss
cpuinfo data: %d processorss%s=%sssmaps:
R�i(is%#x %sitSizes%s: %di
(((((((((((s
----------(*R�R�R�tVERSIONR	R
R�R�R�R�RR�R�R�R�R�RZtsystintsR<RLR�toR�R�R�RItargvR�RHR�R�R�R�R�RtpstcsRPtsleepR�R�(((s1/usr/lib/python2.7/site-packages/procfs/procfs.pyt<module>sR$	
�K\��/I,JB			
'	
				




Zerion Mini Shell 1.0