|
1 Metadata-Version: 1.1 |
|
2 Name: psutil |
|
3 Version: 1.0.1 |
|
4 Summary: A process and system utilities module for Python |
|
5 Home-page: http://code.google.com/p/psutil/ |
|
6 Author: Giampaolo Rodola |
|
7 Author-email: g.rodola <at> gmail <dot> com |
|
8 License: License :: OSI Approved :: BSD License |
|
9 Download-URL: http://psutil.googlecode.com/files/psutil-1.0.1.tar.gz |
|
10 Description: =========== |
|
11 Quick links |
|
12 =========== |
|
13 |
|
14 * `Home page <http://code.google.com/p/psutil>`_ |
|
15 * `Download <http://code.google.com/p/psutil/downloads/list>`_ |
|
16 * `Documentation <http://code.google.com/p/psutil/wiki/Documentation>`_ |
|
17 |
|
18 ======= |
|
19 Summary |
|
20 ======= |
|
21 |
|
22 psutil is a module providing an interface for retrieving information on all |
|
23 running processes and system utilization (CPU, memory, disks, network, users) in |
|
24 a portable way by using Python, implementing many functionalities offered by |
|
25 command line tools such as: **ps, top, df, kill, free, lsof, free, netstat, |
|
26 ifconfig, nice, ionice, iostat, iotop, uptime, pidof, tty, who, taskset, pmap**. |
|
27 |
|
28 It currently supports **Linux**, **Windows**, **OSX**, **FreeBSD**, |
|
29 **Sun Solaris** both **32-bit** and **64-bit** with Python versions from **2.4** |
|
30 to **3.3** by using a single code base. |
|
31 |
|
32 ============== |
|
33 Example usages |
|
34 ============== |
|
35 |
|
36 CPU |
|
37 === |
|
38 |
|
39 >>> import psutil |
|
40 >>> psutil.cpu_times() |
|
41 cputimes(user=3961.46, nice=169.729, system=2150.659, idle=16900.540, |
|
42 iowait=629.509, irq=0.0, softirq=19.422, steal=0.0, guest=0, nice=0.0) |
|
43 >>> |
|
44 >>> for x in range(3): |
|
45 ... psutil.cpu_percent(interval=1) |
|
46 ... |
|
47 4.0 |
|
48 5.9 |
|
49 3.8 |
|
50 >>> |
|
51 >>> for x in range(3): |
|
52 ... psutil.cpu_percent(interval=1, percpu=True) |
|
53 ... |
|
54 [4.0, 6.9] |
|
55 [7.0, 8.5] |
|
56 [1.2, 9.0] |
|
57 >>> |
|
58 >>> for x in range(3): |
|
59 ... psutil.cpu_times_percent(interval=1, percpu=False) |
|
60 ... |
|
61 cpupercent(user=1.5, nice=0.0, system=0.5, idle=96.5, iowait=1.5, irq=0.0, |
|
62 softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0) |
|
63 cpupercent(user=1.0, nice=0.0, system=0.0, idle=99.0, iowait=0.0, irq=0.0, |
|
64 softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0) |
|
65 cpupercent(user=2.0, nice=0.0, system=0.0, idle=98.0, iowait=0.0, irq=0.0, |
|
66 softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0) |
|
67 |
|
68 Memory |
|
69 ====== |
|
70 |
|
71 >>> psutil.virtual_memory() |
|
72 vmem(total=8374149120L, available=2081050624L, percent=75.1, used=8074080256L, |
|
73 free=300068864L, active=3294920704, inactive=1361616896, buffers=529895424L, |
|
74 cached=1251086336) |
|
75 >>> psutil.swap_memory() |
|
76 swap(total=2097147904L, used=296128512L, free=1801019392L, percent=14.1, |
|
77 sin=304193536, sout=677842944) |
|
78 >>> |
|
79 |
|
80 |
|
81 Disks |
|
82 ===== |
|
83 |
|
84 >>> psutil.disk_partitions() |
|
85 [partition(device='/dev/sda1', mountpoint='/', fstype='ext4', opts='rw,nosuid'), |
|
86 partition(device='/dev/sda2', mountpoint='/home', fstype='ext, opts='rw')] |
|
87 >>> |
|
88 >>> psutil.disk_usage('/') |
|
89 usage(total=21378641920, used=4809781248, free=15482871808, percent=22.5) |
|
90 >>> |
|
91 >>> psutil.disk_io_counters() |
|
92 iostat(read_count=719566, write_count=1082197, read_bytes=18626220032, |
|
93 write_bytes=24081764352, read_time=5023392, write_time=63199568) |
|
94 >>> |
|
95 |
|
96 |
|
97 Network |
|
98 ======= |
|
99 |
|
100 >>> psutil.net_io_counters(pernic=True) |
|
101 {'lo': iostat(bytes_sent=799953745, bytes_recv=799953745, |
|
102 packets_sent=453698, packets_recv=453698), |
|
103 'eth0': iostat(bytes_sent=734324837, bytes_recv=4163935363, |
|
104 packets_sent=3605828, packets_recv=4096685)} |
|
105 >>> |
|
106 |
|
107 Other system info |
|
108 ================= |
|
109 |
|
110 >>> psutil.get_users() |
|
111 [user(name='giampaolo', terminal='pts/2', host='localhost', started=1340737536.0), |
|
112 user(name='giampaolo', terminal='pts/3', host='localhost', started=1340737792.0)] |
|
113 >>> |
|
114 >>> psutil.get_boot_time() |
|
115 1365519115.0 |
|
116 |
|
117 |
|
118 Process management |
|
119 ================== |
|
120 |
|
121 >>> import psutil |
|
122 >>> psutil.get_pid_list() |
|
123 [1, 2, 3, 4, 5, 6, 7, 46, 48, 50, 51, 178, 182, 222, 223, 224, |
|
124 268, 1215, 1216, 1220, 1221, 1243, 1244, 1301, 1601, 2237, 2355, |
|
125 2637, 2774, 3932, 4176, 4177, 4185, 4187, 4189, 4225, 4243, 4245, |
|
126 4263, 4282, 4306, 4311, 4312, 4313, 4314, 4337, 4339, 4357, 4358, |
|
127 4363, 4383, 4395, 4408, 4433, 4443, 4445, 4446, 5167, 5234, 5235, |
|
128 5252, 5318, 5424, 5644, 6987, 7054, 7055, 7071] |
|
129 >>> |
|
130 >>> p = psutil.Process(7055) |
|
131 >>> p.name |
|
132 'python' |
|
133 >>> p.exe |
|
134 '/usr/bin/python' |
|
135 >>> p.getcwd() |
|
136 '/home/giampaolo' |
|
137 >>> p.cmdline |
|
138 ['/usr/bin/python', 'main.py'] |
|
139 >>> |
|
140 >>> str(p.status) |
|
141 'running' |
|
142 >>> p.username |
|
143 'giampaolo' |
|
144 >>> p.create_time |
|
145 1267551141.5019531 |
|
146 >>> p.terminal |
|
147 '/dev/pts/0' |
|
148 >>> |
|
149 >>> p.uids |
|
150 user(real=1000, effective=1000, saved=1000) |
|
151 >>> p.gids |
|
152 group(real=1000, effective=1000, saved=1000) |
|
153 >>> |
|
154 >>> p.get_cpu_times() |
|
155 cputimes(user=1.02, system=0.31) |
|
156 >>> p.get_cpu_percent(interval=1.0) |
|
157 12.1 |
|
158 >>> p.get_cpu_affinity() |
|
159 [0, 1, 2, 3] |
|
160 >>> p.set_cpu_affinity([0]) |
|
161 >>> |
|
162 >>> p.get_memory_percent() |
|
163 0.63423 |
|
164 >>> |
|
165 >>> p.get_memory_info() |
|
166 meminfo(rss=7471104, vms=68513792) |
|
167 >>> p.get_ext_memory_info() |
|
168 meminfo(rss=9662464, vms=49192960, shared=3612672, text=2564096, lib=0, data=5754880, dirty=0) |
|
169 >>> p.get_memory_maps() |
|
170 [mmap(path='/lib/x86_64-linux-gnu/libutil-2.15.so', rss=16384, anonymous=8192, swap=0), |
|
171 mmap(path='/lib/x86_64-linux-gnu/libc-2.15.so', rss=6384, anonymous=15, swap=0), |
|
172 mmap(path='/lib/x86_64-linux-gnu/libcrypto.so.1.0.0', rss=34124, anonymous=1245, swap=0), |
|
173 mmap(path='[heap]', rss=54653, anonymous=8192, swap=0), |
|
174 mmap(path='[stack]', rss=1542, anonymous=166, swap=0), |
|
175 ...] |
|
176 >>> |
|
177 >>> p.get_io_counters() |
|
178 io(read_count=478001, write_count=59371, read_bytes=700416, write_bytes=69632) |
|
179 >>> |
|
180 >>> p.get_open_files() |
|
181 [openfile(path='/home/giampaolo/svn/psutil/somefile', fd=3)] |
|
182 >>> |
|
183 >>> p.get_connections() |
|
184 [connection(fd=115, family=2, type=1, laddr=('10.0.0.1', 48776), |
|
185 raddr=('93.186.135.91', 80), status='ESTABLISHED'), |
|
186 connection(fd=117, family=2, type=1, laddr=('10.0.0.1', 43761), |
|
187 raddr=('72.14.234.100', 80), status='CLOSING'), |
|
188 connection(fd=119, family=2, type=1, laddr=('10.0.0.1', 60759), |
|
189 raddr=('72.14.234.104', 80), status='ESTABLISHED'), |
|
190 connection(fd=123, family=2, type=1, laddr=('10.0.0.1', 51314), |
|
191 raddr=('72.14.234.83', 443), status='SYN_SENT')] |
|
192 >>> |
|
193 >>> p.get_num_threads() |
|
194 4 |
|
195 >>> p.get_num_fds() |
|
196 8 |
|
197 >>> p.get_threads() |
|
198 [thread(id=5234, user_time=22.5, system_time=9.2891), |
|
199 thread(id=5235, user_time=0.0, system_time=0.0), |
|
200 thread(id=5236, user_time=0.0, system_time=0.0), |
|
201 thread(id=5237, user_time=0.0707, system_time=1.1)] |
|
202 >>> |
|
203 >>> p.get_num_ctx_switches() |
|
204 amount(voluntary=78, involuntary=19) |
|
205 >>> |
|
206 >>> p.get_nice() |
|
207 0 |
|
208 >>> p.set_nice(10) |
|
209 >>> |
|
210 >>> p.suspend() |
|
211 >>> p.resume() |
|
212 >>> |
|
213 >>> p.terminate() |
|
214 >>> p.wait(timeout=3) |
|
215 0 |
|
216 >>> |
|
217 >>> psutil.test() |
|
218 USER PID %CPU %MEM VSZ RSS TTY START TIME COMMAND |
|
219 root 1 0.0 0.0 24584 2240 ? Jun17 00:00 init |
|
220 root 2 0.0 0.0 0 0 ? Jun17 00:00 kthreadd |
|
221 root 3 0.0 0.0 0 0 ? Jun17 00:05 ksoftirqd/0 |
|
222 ... |
|
223 giampaolo 31475 0.0 0.0 20760 3024 /dev/pts/0 Jun19 00:00 python2.4 |
|
224 giampaolo 31721 0.0 2.2 773060 181896 ? 00:04 10:30 chrome |
|
225 root 31763 0.0 0.0 0 0 ? 00:05 00:00 kworker/0:1 |
|
226 >>> |
|
227 |
|
228 Keywords: ps,top,kill,free,lsof,netstat,nice,tty,ionice,uptime,taskmgr,process,df,iotop,iostat,ifconfig,taskset,who,pidof,pmap,smem,monitoring |
|
229 Platform: Platform Independent |
|
230 Classifier: Development Status :: 5 - Production/Stable |
|
231 Classifier: Environment :: Console |
|
232 Classifier: Operating System :: MacOS :: MacOS X |
|
233 Classifier: Operating System :: Microsoft |
|
234 Classifier: Operating System :: Microsoft :: Windows :: Windows NT/2000 |
|
235 Classifier: Operating System :: POSIX |
|
236 Classifier: Operating System :: POSIX :: Linux |
|
237 Classifier: Operating System :: POSIX :: BSD :: FreeBSD |
|
238 Classifier: Operating System :: POSIX :: SunOS/Solaris |
|
239 Classifier: Operating System :: OS Independent |
|
240 Classifier: Programming Language :: C |
|
241 Classifier: Programming Language :: Python |
|
242 Classifier: Programming Language :: Python :: 2 |
|
243 Classifier: Programming Language :: Python :: 2.4 |
|
244 Classifier: Programming Language :: Python :: 2.5 |
|
245 Classifier: Programming Language :: Python :: 2.6 |
|
246 Classifier: Programming Language :: Python :: 2.7 |
|
247 Classifier: Programming Language :: Python :: 3 |
|
248 Classifier: Programming Language :: Python :: 3.0 |
|
249 Classifier: Programming Language :: Python :: 3.1 |
|
250 Classifier: Programming Language :: Python :: 3.2 |
|
251 Classifier: Programming Language :: Python :: 3.3 |
|
252 Classifier: Topic :: System :: Monitoring |
|
253 Classifier: Topic :: System :: Networking |
|
254 Classifier: Topic :: System :: Networking :: Monitoring |
|
255 Classifier: Topic :: System :: Benchmark |
|
256 Classifier: Topic :: System :: Hardware |
|
257 Classifier: Topic :: System :: Systems Administration |
|
258 Classifier: Topic :: Utilities |
|
259 Classifier: Topic :: Software Development :: Libraries |
|
260 Classifier: Topic :: Software Development :: Libraries :: Python Modules |
|
261 Classifier: Intended Audience :: Developers |
|
262 Classifier: Intended Audience :: System Administrators |
|
263 Classifier: License :: OSI Approved :: BSD License |