Download here
Eli Criffield
http://eli.criffield.net/pyprocps
Dec 2005
Licensed under PSF LICENSE AGREEMENT FOR PYTHON 2.3 as defined by
http://python.org/2.3.2/license.html
#To install untar
tar zxvf pyprocps-0.4.tar.gz
cd pyprocps-0.4/
#run setup.py
python ./setup.py install
# or create an rpm
python ./setup.py bdist_rpm
This module parses the information in /proc on Linux systems and presents it.
The pidinfo class does most everything you could want.
Create an object with it and give it the pid of the process you want info
about then object.attribute is whatever information about the object you
could want. for example;
import os
import pyprocps
myinfo = pyprocps.pidinfo(os.getpid())
myinfo.rss # rss size
myinfo.ppid # parent pid
and so on for a complete list of attributes see the docstring for the
pidinfo class. Note: all info is real time myinfo.rss maybe different a few
seconds later. Or the end of this readme.
Other functions include:
updatedb(filename) will make a database of "useful" information about
every running process
if you run it again on the same file it will just
add new information but will not delete information about
process that have died
"useful" is defined by the list USEFULLIST and is
described in the docstring for alluseful
scandb(filename) reads the file created with updatedb and presents it as a
"useful" list
alluseful() a list of usefullists of every process
boottime() unix long time of last boot
uptimej() uptime in jiffies
uptime() uptime in seconds
num_cpus() how many cpus do we have
vmstat() a list of vm info
meminfo() a list of meminfo
hz_hack() how many jiffies in a second
do_time() formats seconds kinda like ps does
---- ALL ATRIBUTES TO A pidinfo object.
possible attributes are:
pid: The process ID.
comm: The filename of the executable: in parentheses
state: One character from the string RSDZTW
ppid: The PID of the parent
pgrp: The process group ID of the process.
session: The session ID of the process
tty_nr: The tty the process uses
tpgid: The process group ID of the process which currently owns
the tty that the process is connected to.
flags: The kernel flags word of the process. see .
minflt: The number of minor faults the process has made which
have not required loading a memory page from disk.
cminflt: The number of minor faults that the process's waited-for
children have made.
majflt: The number of major faults the process has made which
have required loading a memory page from disk.
cmajflt: The number of major faults that the process's waited-for
children have made.
utime: The number of jiffies that this process has been
scheduled in user mode.
stime: The number of jiffies that this process has been
scheduled in kernel mode
cutime: The number of jiffies that this process's waited-for
children have been scheduled in user mode
cstime: The number of jiffies that this process's waited-for
children have been scheduled in kernel mode.
priority: The standard nice value: plus fifteen. The value is
never negative in the kernel.
nice: The nice value ranges from 19 (nicest) to -19 (not nice
to others).
0: This value is hard coded to 0 as a placeholder for a
removed field.
itrealvalue: The time in jiffies before the next SIGALRM is sent to
the process due to an interval timer.
starttime: The time in jiffies the process started after system
boot.
vsize: Virtual memory size in bytes.
rss: Resident Set Size: number of pages the process has in
real memory: minus 3 for administrative purposes. This is
just the pages which count towards text: data: or stack
space. This does not include pages which have not been
demand-loaded in: or which are swapped out.
rlim: Current limit in bytes on the rss of the process (usually
4294967295 on i386).
startcode: The address above which program text can run.
endcode: The address below which program text can run.
startstack: The address of the start of the stack.
kstkesp: The current value of esp (stack pointer): as found in the
kernel stack page for the process.
kstkeip: The current EIP (instruction pointer).
signal: The bitmap of pending signals.
blocked: The bitmap of blocked signals.
sigignore: The bitmap of ignored signals.
sigcatch: The bitmap of caught signals.
wchan: This is the channel in which the process is waiting.
nswap: Number of pages swapped (not maintained).
cnswap: Cumulative nswap for child processes (not maintained).
exit_signal: Signal to be sent to parent when we die.
processor: CPU number last executed on
rt_priority: Real-time scheduling priority: NULL if kernel < 2.5.19
policy Scheduling policy: NULL if kernel < 2.5.19
size: total program size
resident: resident set size
share: shared pages
text: text (code)
lib: library
data: data/stack
dt: dirty pages (unused in Linux 2.6) and thus -1
Name: Name
State: State
SleepAVG: SleepAVG
Tgid: Tgid
Pid: Pid
PPid: PPid
TracerPid: TracerPid
Uid: Uid (4 element list)
Gid: Gid (4 element list)
FDSize: FDSize
Groups: Groups (list)
VmSize: VmSize
VmLck: VmLck
VmRSS: VmRSS
VmData: VmData
VmStk: VmStk
VmExe: VmExe
VmLib: VmLib
VmPTE: VmPTE
Threads: Threads
SigQ: SigQ
SigPnd: SigPnd
ShdPnd: ShdPnd
SigBlk: SigBlk
SigIgn: SigIgn
SigCgt: SigCgt
CapInh: CapInh
CapPrm: CapPrm
CapEff: CapEff
cwd: The current working directory
exe: The path of the file that was executed for this process
root: The path to this processes root
wchan: the channel the process is in
environ: a dictionary of envorment varibales for this process
loginuid: the loginuid
cmdline: the cmdline (with nulls insted of spaces)
formatedtime: the time formated to look like time from ps
usefull: a list that includes everything in the USEFULLIST
see the docstring for pyprocps.allusefull() for whats in a
USEFULLIST
usefull_dict: a dictionary of the above so process.usefull_dict['cmdline']
is the same as process.cmdline