Rc#@ s%dZddlmZdZegejdD]Zee^q/Zddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'g#Z dd(l Z dd(l Z dd(l Z dd(l Z dd(lZdd(lZdd(lZydd(lZWnek r6eZnXdd)lmZmZmZmZdd*lmZdd+lmZmZmZmZm Z!m"Z#dd,lm$Z%m&Z'm(Z)m*Z+m,Z-dd-lm.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7e j8j9d.ridd(l:j;Z<dd/l:m=Z=m>Z>m?Z?m@Z@mAZAmBZBe<j=Z=e<j>Z>ne j8j9d0rdd(lCjDZ<dd1lCmEZEmFZFmGZGmHZHmIZImJZJn[e j8j9d2rdd(lKjLZ<n7e j8j9d3rdd(lMjNZ<neOd4e j8e jPe<jQe<jRZRe<jSZSe<jTZTd5ZUdeVfd6YZWdeWfd7YZXe<jYZYe<jZZZiZ[d8Z\e]d9Z^e^a_e^d:e`aad;e]d<Zbt_actaadeaed;e]d=Zfd>Zgd?Zhd@Zie]dAZje]dBZke]dCZldDZmdEZne%dFZoe%dGZpe%dHdIZqe%dJdKZre%dLdMZse%dNdOZte%dPdQZue%dRdSZvdTZwexdUkrewn[[[e jdVdWfkr![nd(S(Xspsutil is a module providing convenience functions for managing processes and gather system information in a portable way by using Python. i(tdivisions0.7.0t.tErrort NoSuchProcesst AccessDeniedtTimeoutExpiredtNUM_CPUSt TOTAL_PHYMEMt BOOT_TIMEt version_infot __version__tSTATUS_RUNNINGt STATUS_IDLEtSTATUS_SLEEPINGtSTATUS_DISK_SLEEPtSTATUS_STOPPEDtSTATUS_TRACING_STOPt STATUS_ZOMBIEt STATUS_DEADt STATUS_WAKINGt STATUS_LOCKEDtProcesstPopent pid_existst get_pid_listt process_itertvirtual_memoryt swap_memoryt cpu_timest cpu_percenttcpu_times_percenttnetwork_io_counterstdisk_io_counterstdisk_partitionst disk_usaget get_userst get_boot_timeN(RRRR(tcached_property(tpropertytcallablet defaultdictt namedtupletwrapstPY3(t deprecatedtnt_disk_iostatt nt_net_iostatt nt_sysmeminfot isfile_strict( R R R RRRRRRRtlinux(tphymem_bufferst cached_phymemtIOPRIO_CLASS_NONEtIOPRIO_CLASS_RTtIOPRIO_CLASS_BEtIOPRIO_CLASS_IDLEtwin32(tABOVE_NORMAL_PRIORITY_CLASStBELOW_NORMAL_PRIORITY_CLASStHIGH_PRIORITY_CLASStIDLE_PRIORITY_CLASStNORMAL_PRIORITY_CLASStREALTIME_PRIORITY_CLASStdarwintfreebsdsplatform %s is not supportedc stfd}|S(spDecorator which raises NoSuchProcess in case a process is no longer running or its PID has been reused. c s7|js't|j|jjn|||S(N(t is_runningRtpidt_platform_implt _process_name(tselftargstkwargs(tfun(sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytwrapperhs (t_wraps(RHRI((RHsB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt_assert_pid_not_reuseddscB seZdZdZdZdZgd7dZee dZ edZ edZ e dZe d Zed Zed Zejd kred ZedZedZnedZe dZdZeejdr)dZndZe dZeejdrkdZd7dZ neejdrdZ!dZ"nejdkrdZ#nejd krdZ$nd Z%d!Z&d"Z'e e(d#Z)d$d%Z*d&Z+d'Z,d(Z-d)Z.e/d*Z0d+Z1d,d-Z2d.Z3e d/Z4e d0Z5e d1Z6d2Z7e d3Z8d7d4Z9ed5Z:e:j;d6Z:RS(8sRepresents an OS process.cC sts-t|ttfs-tdq-n|dkrHtdn||_t|_d|_ t j ||_ d|_d|_y |jWn7tk rn'tk rt|dd|nXdS(sCreate a new Process object for the given pid. Raises NoSuchProcess if pid does not exist. Note that most of the methods of this class do not make sure the PID of the process being queried has been reused. That means you might end up retrieving an information referring to another process in case the original one this instance refers to is gone in the meantime. The only exceptions for which process identity is pre-emptively checked are: - parent - get_children() - set_nice() - suspend() - resume() - send_signal() - terminate() - kill() To prevent this problem for all other methods you can: - use is_running() before querying the process - if you're continuously iterating over a set of Process instances use process_iter() which pre-emptively checks process identity for every yielded instance spid must be an integerispid must be a positive integersno process found with pid %sN(t_PY3t isinstancetinttlongt TypeErrort ValueErrort_pidtFalset_gonetNonet_ppidt _psplatformRRCt_last_sys_cpu_timest_last_proc_cpu_timest create_timeRR(RERB((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt__init__ss"         cC sy|j}t|j}Wn;tk r<d|j}n.tk rYd|j}nXd||f}d|jj|jj|fS(Ns(pid=%s (terminated))s(pid=%s)s(pid=%s, name=%s)s%s.%s%s(RBtreprtnameRRt __class__t __module__t__name__(RERBR]tdetails((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt__str__s    cC sd|jt|fS(Ns <%s at %s>(Rbtid(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt__repr__sc C sotddddddddd d d g }t}x2t|pKt|D]}|jd rjqOn|jd rqOn||krqOnyOt||}t|r|dkr|dd}q|}n|}Wn6tk r|}n tk r|rOqOqOnX|jdr]|dd krE|d}q]|dkr]d}q]n|||             cC sV|j}|dk rRy&t|}|j|jkr:|SWqRtk rNqRXndS(sReturn the parent process as a Process object pre-emptively checking whether PID has been reused. If no parent is known return None. N(tppidRURRZR(RERRl((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRls    cC s|jS(sThe process pid.(RR(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRBscC sKtjdkr|jjS|jdkr@|jj|_n|jSdS(sThe process parent pid.tposixN(tosR]RCtget_process_ppidRVRU(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRs  cC s|jj}tjdkryy |j}Wntk r>qyX|rytjj|d}|j|rv|}qvqyn||j_ |S(sThe process name.Ri( RCtget_process_nameRR]tcmdlineRtpathtbasenameRyRD(RER]Rt extended_name((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyR]s   c sfd}yjj}Wn+tk rOtjd}|d|SX|sy|d|}Wqtk r|qXn|SdS(s9The process executable path. May also be an empty string.c sj}|rttdrttdr|d}tjj|}tjj|rtjj|rtj|tjr|Snt |t r|n|S(NtaccesstX_OKi( RthasattrRRtrealpathtisabstisfileRRRMR(tfallbackRtexetrexe(RE(sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytguess_it(s $ $ iRN(RCtget_process_exeRtsystexc_info(RERRterr((REsB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyR%s  cC s |jjS(s.The command line process has been called with.(RCtget_process_cmdline(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRFscC s |jjS(s2The process current status as a STATUS_* constant.(RCtget_process_status(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytstatusKsRcC s |jjS(sgReturn a named tuple denoting the process real, effective, and saved user ids. (RCtget_process_uids(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytuidsRscC s |jjS(shReturn a named tuple denoting the process real, effective, and saved group ids. (RCtget_process_gids(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytgidsYscC s |jjS(sVThe terminal associated with this process, if any, else None. (RCtget_process_terminal(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytterminal`scC sQtjdkr@tdkr*tdntj|jjjS|j j SdS(stThe name of the user that owns the process. On UNIX this is calculated by using *real* process uid. Rs0requires pwd module shipped with standard pythonN( RR]tpwdRUt ImportErrortgetpwuidRtrealtpw_nameRCtget_process_username(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytusernamegs  cC s |jjS(ssThe process creation time as a floating point number expressed in seconds since the epoch, in UTC. (RCtget_process_create_time(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRZtscC s |jjS(sTReturn a string representing the process current working directory. (RCtget_process_cwd(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRt{stget_process_io_counterscC s |jjS(sReturn process I/O statistics as a namedtuple including the number of read/write calls performed and the amount of bytes read and written by the process. (RCR(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytget_io_countersscC s |jjS(s Get process niceness (priority).(RCtget_process_nice(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytget_nicescC s|jj|S(s[Set process niceness (priority) pre-emptively checking whether PID has been reused.(RCtset_process_nice(REtvalue((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytset_nicestget_process_ionicecC s |jjS(sReturn process I/O niceness (priority). On Linux this is a (ioclass, value) namedtuple. On Windows it's an integer which can be equal to 2 (normal), 1 (low) or 0 (very low). Available on Linux and Windows > Vista only. (RCR(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt get_ionices cC s|jj||S(sSet process I/O niceness (priority). On Linux 'ioclass' is one of the IOPRIO_CLASS_* constants. 'value' is a number which goes from 0 to 7. The higher the value, the lower the I/O priority of the process. On Windows only 'ioclass' is used and it can be set to 2 (normal), 1 (low) or 0 (very low). Available on Linux and Windows > Vista only. (RCtset_process_ionice(REtioclassR((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt set_ionices tget_process_cpu_affinitycC s |jjS(s!Get process current CPU affinity.(RCR(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytget_cpu_affinityscC s|jj|S(sSet process current CPU affinity. 'cpus' is a list of CPUs for which you want to set the affinity (e.g. [0, 1]). (RCtset_process_cpu_affinity(REtcpus((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytset_cpu_affinitystntcC s |jjS(s\Return the number of handles opened by this process (Windows only). (RCtget_num_handles(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRscC s |jjS(scReturn the number of file descriptors opened by this process (POSIX only). (RCt get_num_fds(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRscC s |jjS(shReturn the number voluntary and involuntary context switches performed by this process. (RCtget_num_ctx_switches(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRscC s |jjS(s2Return the number of threads used by this process.(RCtget_process_num_threads(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytget_num_threadsscC s |jjS(sReturn threads opened by process as a list of namedtuples including thread id and thread CPU times (user/system). (RCtget_process_threads(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt get_threadssc C sVg}|srxCtD]U}y;|j|jkrV|j|jkrV|j|qVnWqtk rjqXqWntt}x=tD]2}y||jj|Wqtk rqXqW|jg}x|D]}}xt||D]h}y|j|jk}Wntk rqX|r|j||j|krJ|j|jqJqqWqW|S(sReturn the children of this process as a list of Process objects pre-emptively checking whether PID has been reused. If recursive is True return all the parent descendants. Example (A == this process): A ─┐ │ ├─ B (child) ─┐ │ └─ X (grandchild) ─┐ │ └─ Y (great grandchild) ├─ C (child) └─ D (child) >>> p.get_children() B, C, D >>> p.get_children(recursive=True) B, X, Y, C, D Note that in the example above if process X disappears process Y won't be returned either as the reference to process A is lost. (RRRBRZtappendRR(tlist( REt recursiveRtpttablet checkpidsRBtchildtintime((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRms6        g?c C sb|dk o|dk}|rjtt}|jj}tj|tt}|jj}n^|j}|j}tt}|jj}|dks|dkr||_||_dS|j |j |j |j }||}||_||_y||d} Wnt k r(dSX| t } t jdkrU| dkrUdSnt| dS(sReturn a float representing the current process CPU utilization as a percentage. When interval is > 0.0 compares process times to system CPU times elapsed before and after the interval (blocking). When interval is 0.0 or None compares process times to system CPU times elapsed since last call, returning immediately (non-blocking). In this case is recommended for accuracy that this function be called with at least 0.1 seconds between calls. Examples: >>> p = psutil.Process(os.getpid()) >>> # blocking >>> p.get_cpu_percent(interval=1) 2.0 >>> # non-blocking (percentage since last call) >>> p.get_cpu_percent(interval=0) 2.9 >>> gidRgY@iN(RUtsumRRCt get_cpu_timesttimetsleepRXRYtusertsystemtZeroDivisionErrorRRR]tround( RERrtblockingtst1tpt1tst2tpt2t delta_proct delta_timetoverall_percenttsingle_cpu_percent((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRq s8           cC s |jjS(s{Return a tuple whose values are process CPU user and system times. The same as os.times() but per-process. (RCR(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyR`scC s |jjS(s Return a tuple representing RSS (Resident Set Size) and VMS (Virtual Memory Size) in bytes. On UNIX RSS and VMS are the same values shown by ps. On Windows RSS and VMS refer to "Mem Usage" and "VM Size" columns of taskmgr.exe. (RCtget_memory_info(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRfs cC s |jjS(sReturn a namedtuple with variable fields depending on the platform representing extended memory information about the process. All numbers are expressed in bytes. (RCtget_ext_memory_info(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRqscC sB|jjd}y|ttdSWntk r=dSXdS(sCompare physical system memory to process resident memory (RSS) and calculate process memory utilization as a percentage. iidgN(RCRtfloatRR(REtrss((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytget_memory_percentxs  c C s|jj}|ri}xa|D]Y}|d}|d}y!td|||||sN(RCtget_memory_mapstmaptKeyErrortnt_mmap_groupedt nt_mmap_ext( REtgroupedtittdttuplRtnumsRR((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRs    !  $ cC s |jjS(sReturn files opened by process as a list of namedtuples including absolute file name and file descriptor number. (RCtget_open_files(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRstinetcC s|jj|S(sReturn connections opened by process as a list of namedtuples. The kind parameter filters for connections that fit the following criteria: Kind Value Connections using inet IPv4 and IPv6 inet4 IPv4 inet6 IPv6 tcp TCP tcp4 TCP over IPv4 tcp6 TCP over IPv6 udp UDP udp4 UDP over IPv4 udp6 UDP over IPv6 unix UNIX socket (both UDP and TCP protocols) all the sum of all the possible families and protocols (RCtget_connections(REtkind((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRscC sI|jr tSy|j|jjkSWntk rDt|_tSXdS(sReturn whether this process is running. It also checks if PID has been reused by another process in which case returns False. N(RTRSRZRCRRtTrue(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRAs   cC stjdkrytj|j|Wqtk rtjd}|jj}|j t j krt |_ t |j|n|j t jkrt|j|nqXn+|tjkr|jjn tddS(sSend a signal to process pre-emptively checking whether PID has been reused (see signal module constants) . On Windows only SIGTERM is valid and is treated as an alias for kill(). Ris$only SIGTERM is supported on WindowsN(RR]RiRBtOSErrorRRRCRDterrnotESRCHRRTRtEPERMRtsignaltSIGTERMt kill_processRQ(REtsigRR]((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRes    cC s6t|jdr"|jjn|jtjdS(sSuspend process execution with SIGSTOP pre-emptively checking whether PID has been reused. On Windows it suspends all process threads. tsuspend_processN(RRCRReRtSIGSTOP(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRfscC s6t|jdr"|jjn|jtjdS(sResume process execution with SIGCONT pre-emptively checking whether PID has been reused. On Windows it resumes all process threads. tresume_processN(RRCRReRtSIGCONT(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRgscC s|jtjdS(sTerminate the process with SIGTERM pre-emptively checking whether PID has been reused. On Windows this is an alias for kill(). N(ReRR(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRhscC s3tjdkr"|jtjn |jjdS(saKill the current process with SIGKILL pre-emptively checking whether PID has been reused.RN(RR]ReRtSIGKILLRCR(RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRiscC s8|dk r(|dk r(tdn|jj|S(sWait for process to terminate and, if process is a children of the current one also return its exit code, else None. is"timeout must be a positive integerN(RURQRCt process_wait(REttimeout((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRj scC s)d}tj|dtdd|jS(s\Get or set process niceness (priority). Deprecated, use get_nice() instead. sBthis property is deprecated; use Process.get_nice() method insteadtcategoryt stackleveli(twarningstwarntDeprecationWarningR(REtmsg((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRnscC s,d}tj|dtdd|j|S(NsBthis property is deprecated; use Process.set_nice() method insteadRRi(RRRR(RERR((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRnsN(<R`R_t__doc__R[RbRdRURkR&RKRlRBRR%R]RRRRRRRRRZRtRRWRRRRRRRRRRRRRRSRmRqRRRRRRRRRAReRfRgRhRiRjRntsetter(((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRpsp 0 1!            @ @          cB s)eZdZdZdZdZRS(sA more convenient interface to stdlib subprocess module. It starts a sub process and deals with it exactly as when using subprocess.Popen class but in addition also provides all the property and methods of psutil.Process class in a single interface: >>> import psutil >>> from subprocess import PIPE >>> p = psutil.Popen(["/usr/bin/python", "-c", "print 'hi'"], stdout=PIPE) >>> p.name 'python' >>> p.uids user(real=1000, effective=1000, saved=1000) >>> p.username 'giampaolo' >>> p.communicate() ('hi ', None) >>> p.terminate() >>> p.wait(timeout=2) 0 >>> For method names common to both classes such as kill(), terminate() and wait(), psutil.Process implementation takes precedence. For a complete documentation refers to: http://docs.python.org/library/subprocess.html cO stj|||_|jj|_t|_d|_t j |j|_ d|_ d|_ y |jWn=tk r{n-tk rt|jdd|jnXdS(Nsno process found with pid %s(t subprocessRt_Popen__subprocRBRRRSRTRURVRWRRCRXRYRZRR(RERFRG((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyR[Es        cC s#ttttttjS(N(RRvRxRR (RE((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt__dir__UscC ssytj||SWnXtk rnytj|j|SWqotk rjtd|jj|fqoXnXdS(Ns!%s instance has no attribute '%s'(tobjectt__getattribute__tAttributeErrorR R^R`(RER]((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRXs  (R`R_R R[R R(((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyR(s  cc sd}d}tt}ttj}||}||}x|D]}||qNWxtttjttj|jD]|\}}y=|dkr||Vn|j r|Vn ||VWqt k r||qt k r|VqXqWdS(sReturn a generator yielding a Process class instance for all running processes on the local machine. Every new Process instance is only created once and then cached into an internal table which is updated every time this is used. Cached Process instances are checked for identity so that you're safe in case a PID has been reused by another process, in which case the cached instance is updated. The sorting order in which processes are yielded is based on their PIDs. cS st|}|t|j<|S(N(Rt_pmapRB(RBtproc((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytaddzs  cS stj|ddS(N(RtpopRU(RB((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytremovesN( RvRRtkeystsortedRtitemsRwtfromkeysRURARR(RRtatbtnew_pidst gone_pidsRBR((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRls(     )     cC s|stjStjSdS(sReturn system-wide CPU times as a namedtuple object. Every CPU time represents the time CPU has spent in the given mode. The attributes availability varies depending on the platform. Here follows a list of all available attributes: - user - system - idle - nice (UNIX) - iowait (Linux) - irq (Linux, FreeBSD) - softirq (Linux) - steal (Linux >= 2.6.11) - guest (Linux >= 2.6.24) - guest_nice (Linux >= 3.2.0) When percpu is True return a list of nameduples for each CPU. First element of the list refers to first CPU, second element to second CPU and so on. The order of the list is consistent across calls. N(RWtget_system_cpu_timestget_system_per_cpu_times(tpercpu((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRs R g?cC s|dk o|dk}d}|sb|rFt}tj|nt}ta||tSg}|rtdt}tj|nt}tdtax3t|tD]"\}}|j|||qW|SdS(sReturn a float representing the current system-wide CPU utilization as a percentage. When interval is > 0.0 compares system CPU times elapsed before and after the interval (blocking). When interval is 0.0 or None compares system CPU times elapsed since last call or module import, returning immediately. In this case is recommended for accuracy that this function be called with at least 0.1 seconds between calls. When percpu is True returns a list of floats representing the utilization as a percentage for each CPU. First element of the list refers to first CPU, second element to second CPU and so on. The order of the list is consistent across calls. Examples: >>> # blocking, system-wide >>> psutil.cpu_percent(interval=1) 2.0 >>> >>> # blocking, per-cpu >>> psutil.cpu_percent(interval=1, percpu=True) [2.0, 1.0] >>> >>> # non-blocking (percentage since last call) >>> psutil.cpu_percent(interval=0) 2.9 >>> gc S sqt|}||j}t|}||j}||krBdS||}||}||d}t|dS(Ngidi(RtidleR( tt1tt2tt1_alltt1_busytt2_alltt2_busyt busy_deltat all_deltat busy_perc((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt calculates       R N( RURRRt_last_cpu_timesRt_last_per_cpu_timestzipR(RrR RR+R"Rttot1R#((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRs$#    cC s|dk o|dk}d}|sb|rFt}tj|nt}ta||tSg}|rtdt}tj|nt}tdtax3t|tD]"\}}|j|||qW|SdS(sSame as cpu_percent() but provides utilization percentages for each specific CPU time as is returned by cpu_times(). For instance, on Linux we'll get: >>> cpu_times_percent() cpupercent(user=4.8, nice=0.0, system=4.8, idle=90.5, iowait=0.0, irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0) >>> interval and percpu arguments have the same meaning as in cpu_percent(). gcS sg}t|t|}xo|jD]d}t||t||}yd||}Wntk rsd}nX|jt|dq&Wtdkrtddj |jant|S(Nidgit cpupercentt ( Rt_fieldsRzRRRt_ptime_cpu_perc_ntRUR)tjoin(R"R#RR)tfieldt field_deltat field_perc((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyR+#s   R N( RURRRt_last_cpu_times_2Rt_last_per_cpu_times_2R.R(RrR RR+R"RR/R#((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRs$    cC s tjS(sReturn statistics about system memory usage as a namedtuple including the following fields, expressed in bytes: - total: total physical memory available. - available: the actual amount of available memory that can be given instantly to processes that request more memory in bytes; this is calculated by summing different memory values depending on the platform (e.g. free + buffers + cached on Linux) and it is supposed to be used to monitor actual memory usage in a cross platform fashion. - percent: the percentage usage calculated as (total - available) / total * 100 - used: memory used, calculated differently depending on the platform and designed for informational purposes only: OSX: active + inactive + wired BSD: active + wired + cached LINUX: total - free - free: memory not being used at all (zeroed) that is readily available; note that this doesn't reflect the actual memory available (use 'available' instead) Platform-specific fields: - active (UNIX): memory currently in use or very recently used, and so it is in RAM. - inactive (UNIX): memory that is marked as not used. - buffers (BSD, Linux): cache for things like file system metadata. - cached (BSD, OSX): cache for various things. - wired (OSX, BSD): memory that is marked to always stay in RAM. It is never moved to disk. - shared (BSD): memory that may be simultaneously accessed by multiple processes. The sum of 'used' and 'available' does not necessarily equal total. On Windows 'available' and 'free' are the same. (RWR(((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRLs5cC s tjS(sReturn system swap memory statistics as a namedtuple including the following attributes: - total: total swap memory in bytes - used: used swap memory in bytes - free: free swap memory in bytes - percent: the percentage usage - sin: no. of bytes the system has swapped in from disk (cumulative) - sout: no. of bytes the system has swapped out from disk (cumulative) 'sin' and 'sout' on Windows are meaningless and always set to 0. (RWR(((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRs cC s tj|S(sReturn disk usage statistics about the given path as a namedtuple including total, used and free space expressed in bytes plus the percentage usage. (RWtget_disk_usage(R((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyR"scC s tj|S(s&Return mounted partitions as a list of namedtuples including device, mount point, filesystem type and mount options (a raw string separated by commas which may vary depending on the platform). If "all" parameter is False return physical devices only and ignore all others. (RWR!(tall((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyR!scC stj}|s!tdn|rXx*|jD]\}}t|||R(tpernicR@tnicRBR((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyRs cC s tjS(svReturn the system boot time expressed in seconds since the epoch. This is also available as psutil.BOOT_TIME. (RWtget_system_boot_time(((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyR$scC s tjS(sReturn users currently connected on the system as a list of namedtuples including the following attributes. - user: the name of the user - terminal: the tty or pseudo-tty associated with the user, if any. - host: the host name associated with the entry, if any. - started: the creation time as a floating point number expressed in seconds since the epoch. (RWtget_system_users(((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyR#s cC s ttS(snReturn a list of Process class instances for all running processes on the local machine (deprecated). (RR(((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pytget_process_listscC s(t}t|j|j|j|jS(sReturn the amount of total, used and free physical memory on the system in bytes plus the percentage usage. Deprecated by psutil.virtual_memory(). (Rt_nt_sysmeminfottotaltusedtfreetpercent(tmem((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt phymem_usages spsutil.swap_memory()cC stS(N(R(((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt virtmem_usagesspsutil.phymem_usage().freecC s tjS(N(RORL(((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt avail_phymemsspsutil.phymem_usage().usedcC s tjS(N(RORK(((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt used_phymemsspsutil.virtmem_usage().totalcC s tjS(N(RPRJ(((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt total_virtmemsspsutil.virtmem_usage().usedcC s tjS(N(RPRK(((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt used_virtmemsspsutil.virtmem_usage().freecC s tjS(N(RPRL(((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt avail_virtmem#sc C sWddl}ddlm}|jj}d}ddddd d d d g}tjd krn|jdn||d*xtt ddD]}y|j |dd}Wnt k rqX|d r|jj |d }|j|kr |j d}q$|j d}nd}tj dtjt|d }|d} tjd!krd"| kr| jd"d#} n|d$rt|d$jd%pd&} |d$rt|d$jd%pd&} |d'rt|d'd#pd&} ||| d( |d|d)| | | |jddp.d&|||d jpGd&f qWdS(+sNList info of all currently running processes emulating ps aux output. iN(tprint_s+%-10s %5s %4s %4s %7s %7s %-13s %5s %7s %sRBRRqRR]RRZRRRtUSERtPIDs%CPUs%MEMtVSZtRSStTTYtSTARTtTIMEtCOMMANDtkeycS s|jS(N(RB(R((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyR6sR}ts%H:%Ms%b%ds%M:%SRRs\it memory_infoit?tmemory_percenti R( RWRXs%CPUs%MEMRYRZR[R\R]R^(tdatetimetpsutil._compatRVtdatettodayRR]RRRRkRt fromtimestamptstrftimeRt localtimeRtsplitRNtvmsRRRststrip( RdRVt today_dayttemplR|RtpinfotctimetcputimeRRlRtmemp((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyttest'sR   %     t__main__ii(yR t __future__RR ttupleRktnumRNR t__all__RRRRRRR RRRUt psutil._errorRRRRtpsutil._commonR%ReR&R'R(R)R*RJR+RLR,t _deprecatedR-R=R.RCR/RIR0t_isfile_strictR R R RRRRRRRtplatformRytpsutil._pslinuxt_pslinuxRWR2R3R4R5R6R7tpsutil._psmswindowst _psmswindowsR9R:R;R<R=R>t psutil._psosxt_psosxt psutil._psbsdt_psbsdR{textendt__extra__all__RRRRKRRRRRRRRSRR,RR-RR8R9R3RRRR"R!R RR$R#RHRORPRQRRRSRTRURtR`(((sB/opt/alt/python27/lib64/python2.7/site-packages/psutil/__init__.pyt s.                 ".(F.  1    ?   5  O: 7   ! !    2