Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/psutil-5.7.0-py3.7.egg-info/PKG-INFO @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author | shellac |
---|---|
date | Sat, 02 May 2020 07:14:21 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:26e78fe6e8c4 |
---|---|
1 Metadata-Version: 1.2 | |
2 Name: psutil | |
3 Version: 5.7.0 | |
4 Summary: Cross-platform lib for process and system monitoring in Python. | |
5 Home-page: https://github.com/giampaolo/psutil | |
6 Author: Giampaolo Rodola | |
7 Author-email: g.rodola@gmail.com | |
8 License: BSD | |
9 Description: | |downloads| |stars| |forks| |contributors| |coverage| |quality| | |
10 | |version| |py-versions| |packages| |license| | |
11 | |travis| |appveyor| |cirrus| |doc| |twitter| |tidelift| | |
12 | |
13 .. |downloads| image:: https://img.shields.io/pypi/dm/psutil.svg | |
14 :target: https://pepy.tech/project/psutil | |
15 :alt: Downloads | |
16 | |
17 .. |stars| image:: https://img.shields.io/github/stars/giampaolo/psutil.svg | |
18 :target: https://github.com/giampaolo/psutil/stargazers | |
19 :alt: Github stars | |
20 | |
21 .. |forks| image:: https://img.shields.io/github/forks/giampaolo/psutil.svg | |
22 :target: https://github.com/giampaolo/psutil/network/members | |
23 :alt: Github forks | |
24 | |
25 .. |contributors| image:: https://img.shields.io/github/contributors/giampaolo/psutil.svg | |
26 :target: https://github.com/giampaolo/psutil/graphs/contributors | |
27 :alt: Contributors | |
28 | |
29 .. |quality| image:: https://img.shields.io/codacy/grade/ce63e7f7f69d44b5b59682196e6fbfca.svg | |
30 :target: https://www.codacy.com/app/g-rodola/psutil?utm_source=github.com&utm_medium=referral&utm_content=giampaolo/psutil&utm_campaign=Badge_Grade | |
31 :alt: Code quality | |
32 | |
33 .. |travis| image:: https://img.shields.io/travis/giampaolo/psutil/master.svg?maxAge=3600&label=Linux,%20OSX,%20PyPy | |
34 :target: https://travis-ci.org/giampaolo/psutil | |
35 :alt: Linux tests (Travis) | |
36 | |
37 .. |appveyor| image:: https://img.shields.io/appveyor/ci/giampaolo/psutil/master.svg?maxAge=3600&label=Windows | |
38 :target: https://ci.appveyor.com/project/giampaolo/psutil | |
39 :alt: Windows tests (Appveyor) | |
40 | |
41 .. |cirrus| image:: https://img.shields.io/cirrus/github/giampaolo/psutil?label=FreeBSD | |
42 :target: https://cirrus-ci.com/github/giampaolo/psutil-cirrus-ci | |
43 :alt: FreeBSD tests (Cirrus-Ci) | |
44 | |
45 .. |coverage| image:: https://img.shields.io/coveralls/github/giampaolo/psutil.svg?label=test%20coverage | |
46 :target: https://coveralls.io/github/giampaolo/psutil?branch=master | |
47 :alt: Test coverage (coverall.io) | |
48 | |
49 .. |doc| image:: https://readthedocs.org/projects/psutil/badge/?version=latest | |
50 :target: http://psutil.readthedocs.io/en/latest/?badge=latest | |
51 :alt: Documentation Status | |
52 | |
53 .. |version| image:: https://img.shields.io/pypi/v/psutil.svg?label=pypi | |
54 :target: https://pypi.org/project/psutil | |
55 :alt: Latest version | |
56 | |
57 .. |py-versions| image:: https://img.shields.io/pypi/pyversions/psutil.svg | |
58 :target: https://pypi.org/project/psutil | |
59 :alt: Supported Python versions | |
60 | |
61 .. |packages| image:: https://repology.org/badge/tiny-repos/python:psutil.svg | |
62 :target: https://repology.org/metapackage/python:psutil/versions | |
63 :alt: Binary packages | |
64 | |
65 .. |license| image:: https://img.shields.io/pypi/l/psutil.svg | |
66 :target: https://github.com/giampaolo/psutil/blob/master/LICENSE | |
67 :alt: License | |
68 | |
69 .. |twitter| image:: https://img.shields.io/twitter/follow/grodola.svg?label=follow&style=flat&logo=twitter&logoColor=4FADFF | |
70 :target: https://twitter.com/grodola | |
71 :alt: Twitter Follow | |
72 | |
73 .. |tidelift| image:: https://tidelift.com/badges/github/giampaolo/psutil?style=flat | |
74 :target: https://tidelift.com/subscription/pkg/pypi-psutil?utm_source=pypi-psutil&utm_medium=referral&utm_campaign=readme | |
75 :alt: Tidelift | |
76 | |
77 ----- | |
78 | |
79 Quick links | |
80 =========== | |
81 | |
82 - `Home page <https://github.com/giampaolo/psutil>`_ | |
83 - `Install <https://github.com/giampaolo/psutil/blob/master/INSTALL.rst>`_ | |
84 - `Documentation <http://psutil.readthedocs.io>`_ | |
85 - `Download <https://pypi.org/project/psutil/#files>`_ | |
86 - `Forum <http://groups.google.com/group/psutil/topics>`_ | |
87 - `StackOverflow <https://stackoverflow.com/questions/tagged/psutil>`_ | |
88 - `Blog <http://grodola.blogspot.com/search/label/psutil>`_ | |
89 - `Development guide <https://github.com/giampaolo/psutil/blob/master/docs/DEVGUIDE.rst>`_ | |
90 - `What's new <https://github.com/giampaolo/psutil/blob/master/HISTORY.rst>`_ | |
91 | |
92 Summary | |
93 ======= | |
94 | |
95 psutil (process and system utilities) is a cross-platform library for | |
96 retrieving information on **running processes** and **system utilization** | |
97 (CPU, memory, disks, network, sensors) in Python. | |
98 It is useful mainly for **system monitoring**, **profiling and limiting process | |
99 resources** and **management of running processes**. | |
100 It implements many functionalities offered by classic UNIX command line tools | |
101 such as *ps, top, iotop, lsof, netstat, ifconfig, free* and others. | |
102 psutil currently supports the following platforms: | |
103 | |
104 - **Linux** | |
105 - **Windows** | |
106 - **macOS** | |
107 - **FreeBSD, OpenBSD**, **NetBSD** | |
108 - **Sun Solaris** | |
109 - **AIX** | |
110 | |
111 ...both **32-bit** and **64-bit** architectures. Supported Python versions are **2.6**, **2.7** and **3.4+**. `PyPy3 <http://pypy.org/>`__ is also known to work. | |
112 | |
113 psutil for enterprise | |
114 ===================== | |
115 | |
116 .. |tideliftlogo| image:: https://nedbatchelder.com/pix/Tidelift_Logos_RGB_Tidelift_Shorthand_On-White_small.png | |
117 :width: 150 | |
118 :alt: Tidelift | |
119 :target: https://tidelift.com/subscription/pkg/pypi-psutil?utm_source=pypi-psutil&utm_medium=referral&utm_campaign=readme | |
120 | |
121 .. list-table:: | |
122 :widths: 10 150 | |
123 | |
124 * - |tideliftlogo| | |
125 - The maintainer of psutil and thousands of other packages are working | |
126 with Tidelift to deliver commercial support and maintenance for the open | |
127 source dependencies you use to build your applications. Save time, | |
128 reduce risk, and improve code health, while paying the maintainers of | |
129 the exact dependencies you use. | |
130 `Learn more <https://tidelift.com/subscription/pkg/pypi-psutil?utm_source=pypi-psutil&utm_medium=referral&utm_campaign=enterprise&utm_term=repo>`__. | |
131 | |
132 By subscribing to Tidelift you will help me (`Giampaolo Rodola`_) support | |
133 psutil future development. Alternatively consider making a small | |
134 `donation`_. | |
135 | |
136 Security | |
137 ======== | |
138 | |
139 To report a security vulnerability, please use the `Tidelift security | |
140 contact`_. Tidelift will coordinate the fix and disclosure. | |
141 | |
142 Example applications | |
143 ==================== | |
144 | |
145 +------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------+ | |
146 | .. image:: https://github.com/giampaolo/psutil/blob/master/docs/_static/procinfo-small.png | .. image:: https://github.com/giampaolo/psutil/blob/master/docs/_static/top-small.png | | |
147 | :target: https://github.com/giampaolo/psutil/blob/master/docs/_static/procinfo.png | :target: https://github.com/giampaolo/psutil/blob/master/docs/_static/top.png | | |
148 +------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------+ | |
149 | .. image:: https://github.com/giampaolo/psutil/blob/master/docs/_static/procsmem-small.png | .. image:: https://github.com/giampaolo/psutil/blob/master/docs/_static/pmap-small.png | | |
150 | :target: https://github.com/giampaolo/psutil/blob/master/docs/_static/procsmem.png | :target: https://github.com/giampaolo/psutil/blob/master/docs/_static/pmap.png | | |
151 +------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------+ | |
152 | |
153 Also see `scripts directory <https://github.com/giampaolo/psutil/tree/master/scripts>`__ | |
154 and `doc recipes <http://psutil.readthedocs.io/#recipes/>`__. | |
155 | |
156 Projects using psutil | |
157 ===================== | |
158 | |
159 psutil has roughly the following monthly downloads: | |
160 | |
161 .. image:: https://img.shields.io/pypi/dm/psutil.svg | |
162 :target: https://pepy.tech/project/psutil | |
163 :alt: Downloads | |
164 | |
165 There are over | |
166 `10.000 open source projects <https://libraries.io/pypi/psutil/dependent_repositories?page=1>`__ | |
167 on github which depend from psutil. | |
168 Here's some I find particularly interesting: | |
169 | |
170 - https://github.com/google/grr | |
171 - https://github.com/facebook/osquery/ | |
172 - https://github.com/nicolargo/glances | |
173 - https://github.com/Jahaja/psdash | |
174 - https://github.com/ajenti/ajenti | |
175 - https://github.com/home-assistant/home-assistant/ | |
176 | |
177 | |
178 Portings | |
179 ======== | |
180 | |
181 - Go: https://github.com/shirou/gopsutil | |
182 - C: https://github.com/hamon-in/cpslib | |
183 - Rust: https://github.com/borntyping/rust-psutil | |
184 - Nim: https://github.com/johnscillieri/psutil-nim | |
185 | |
186 | |
187 Example usages | |
188 ============== | |
189 | |
190 This represents pretty much the whole psutil API. | |
191 | |
192 CPU | |
193 --- | |
194 | |
195 .. code-block:: python | |
196 | |
197 >>> import psutil | |
198 >>> | |
199 >>> psutil.cpu_times() | |
200 scputimes(user=3961.46, nice=169.729, system=2150.659, idle=16900.540, iowait=629.59, irq=0.0, softirq=19.42, steal=0.0, guest=0, nice=0.0) | |
201 >>> | |
202 >>> for x in range(3): | |
203 ... psutil.cpu_percent(interval=1) | |
204 ... | |
205 4.0 | |
206 5.9 | |
207 3.8 | |
208 >>> | |
209 >>> for x in range(3): | |
210 ... psutil.cpu_percent(interval=1, percpu=True) | |
211 ... | |
212 [4.0, 6.9, 3.7, 9.2] | |
213 [7.0, 8.5, 2.4, 2.1] | |
214 [1.2, 9.0, 9.9, 7.2] | |
215 >>> | |
216 >>> for x in range(3): | |
217 ... psutil.cpu_times_percent(interval=1, percpu=False) | |
218 ... | |
219 scputimes(user=1.5, nice=0.0, system=0.5, idle=96.5, iowait=1.5, irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0) | |
220 scputimes(user=1.0, nice=0.0, system=0.0, idle=99.0, iowait=0.0, irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0) | |
221 scputimes(user=2.0, nice=0.0, system=0.0, idle=98.0, iowait=0.0, irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0) | |
222 >>> | |
223 >>> psutil.cpu_count() | |
224 4 | |
225 >>> psutil.cpu_count(logical=False) | |
226 2 | |
227 >>> | |
228 >>> psutil.cpu_stats() | |
229 scpustats(ctx_switches=20455687, interrupts=6598984, soft_interrupts=2134212, syscalls=0) | |
230 >>> | |
231 >>> psutil.cpu_freq() | |
232 scpufreq(current=931.42925, min=800.0, max=3500.0) | |
233 >>> | |
234 >>> psutil.getloadavg() # also on Windows (emulated) | |
235 (3.14, 3.89, 4.67) | |
236 | |
237 Memory | |
238 ------ | |
239 | |
240 .. code-block:: python | |
241 | |
242 >>> psutil.virtual_memory() | |
243 svmem(total=10367352832, available=6472179712, percent=37.6, used=8186245120, free=2181107712, active=4748992512, inactive=2758115328, buffers=790724608, cached=3500347392, shared=787554304) | |
244 >>> psutil.swap_memory() | |
245 sswap(total=2097147904, used=296128512, free=1801019392, percent=14.1, sin=304193536, sout=677842944) | |
246 >>> | |
247 | |
248 Disks | |
249 ----- | |
250 | |
251 .. code-block:: python | |
252 | |
253 >>> psutil.disk_partitions() | |
254 [sdiskpart(device='/dev/sda1', mountpoint='/', fstype='ext4', opts='rw,nosuid'), | |
255 sdiskpart(device='/dev/sda2', mountpoint='/home', fstype='ext, opts='rw')] | |
256 >>> | |
257 >>> psutil.disk_usage('/') | |
258 sdiskusage(total=21378641920, used=4809781248, free=15482871808, percent=22.5) | |
259 >>> | |
260 >>> psutil.disk_io_counters(perdisk=False) | |
261 sdiskio(read_count=719566, write_count=1082197, read_bytes=18626220032, write_bytes=24081764352, read_time=5023392, write_time=63199568, read_merged_count=619166, write_merged_count=812396, busy_time=4523412) | |
262 >>> | |
263 | |
264 Network | |
265 ------- | |
266 | |
267 .. code-block:: python | |
268 | |
269 >>> psutil.net_io_counters(pernic=True) | |
270 {'eth0': netio(bytes_sent=485291293, bytes_recv=6004858642, packets_sent=3251564, packets_recv=4787798, errin=0, errout=0, dropin=0, dropout=0), | |
271 'lo': netio(bytes_sent=2838627, bytes_recv=2838627, packets_sent=30567, packets_recv=30567, errin=0, errout=0, dropin=0, dropout=0)} | |
272 >>> | |
273 >>> psutil.net_connections() | |
274 [sconn(fd=115, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=48776), raddr=addr(ip='93.186.135.91', port=80), status='ESTABLISHED', pid=1254), | |
275 sconn(fd=117, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=43761), raddr=addr(ip='72.14.234.100', port=80), status='CLOSING', pid=2987), | |
276 ...] | |
277 >>> | |
278 >>> psutil.net_if_addrs() | |
279 {'lo': [snicaddr(family=<AddressFamily.AF_INET: 2>, address='127.0.0.1', netmask='255.0.0.0', broadcast='127.0.0.1', ptp=None), | |
280 snicaddr(family=<AddressFamily.AF_INET6: 10>, address='::1', netmask='ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', broadcast=None, ptp=None), | |
281 snicaddr(family=<AddressFamily.AF_LINK: 17>, address='00:00:00:00:00:00', netmask=None, broadcast='00:00:00:00:00:00', ptp=None)], | |
282 'wlan0': [snicaddr(family=<AddressFamily.AF_INET: 2>, address='192.168.1.3', netmask='255.255.255.0', broadcast='192.168.1.255', ptp=None), | |
283 snicaddr(family=<AddressFamily.AF_INET6: 10>, address='fe80::c685:8ff:fe45:641%wlan0', netmask='ffff:ffff:ffff:ffff::', broadcast=None, ptp=None), | |
284 snicaddr(family=<AddressFamily.AF_LINK: 17>, address='c4:85:08:45:06:41', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)]} | |
285 >>> | |
286 >>> psutil.net_if_stats() | |
287 {'lo': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_UNKNOWN: 0>, speed=0, mtu=65536), | |
288 'wlan0': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_FULL: 2>, speed=100, mtu=1500)} | |
289 >>> | |
290 | |
291 Sensors | |
292 ------- | |
293 | |
294 .. code-block:: python | |
295 | |
296 >>> import psutil | |
297 >>> psutil.sensors_temperatures() | |
298 {'acpitz': [shwtemp(label='', current=47.0, high=103.0, critical=103.0)], | |
299 'asus': [shwtemp(label='', current=47.0, high=None, critical=None)], | |
300 'coretemp': [shwtemp(label='Physical id 0', current=52.0, high=100.0, critical=100.0), | |
301 shwtemp(label='Core 0', current=45.0, high=100.0, critical=100.0)]} | |
302 >>> | |
303 >>> psutil.sensors_fans() | |
304 {'asus': [sfan(label='cpu_fan', current=3200)]} | |
305 >>> | |
306 >>> psutil.sensors_battery() | |
307 sbattery(percent=93, secsleft=16628, power_plugged=False) | |
308 >>> | |
309 | |
310 Other system info | |
311 ----------------- | |
312 | |
313 .. code-block:: python | |
314 | |
315 >>> import psutil | |
316 >>> psutil.users() | |
317 [suser(name='giampaolo', terminal='pts/2', host='localhost', started=1340737536.0, pid=1352), | |
318 suser(name='giampaolo', terminal='pts/3', host='localhost', started=1340737792.0, pid=1788)] | |
319 >>> | |
320 >>> psutil.boot_time() | |
321 1365519115.0 | |
322 >>> | |
323 | |
324 Process management | |
325 ------------------ | |
326 | |
327 .. code-block:: python | |
328 | |
329 >>> import psutil | |
330 >>> psutil.pids() | |
331 [1, 2, 3, 4, 5, 6, 7, 46, 48, 50, 51, 178, 182, 222, 223, 224, 268, 1215, 1216, 1220, 1221, 1243, 1244, | |
332 1301, 1601, 2237, 2355, 2637, 2774, 3932, 4176, 4177, 4185, 4187, 4189, 4225, 4243, 4245, 4263, 4282, | |
333 4306, 4311, 4312, 4313, 4314, 4337, 4339, 4357, 4358, 4363, 4383, 4395, 4408, 4433, 4443, 4445, 4446, | |
334 5167, 5234, 5235, 5252, 5318, 5424, 5644, 6987, 7054, 7055, 7071] | |
335 >>> | |
336 >>> p = psutil.Process(7055) | |
337 >>> p | |
338 psutil.Process(pid=7055, name='python', started='09:04:44') | |
339 >>> p.name() | |
340 'python' | |
341 >>> p.exe() | |
342 '/usr/bin/python' | |
343 >>> p.cwd() | |
344 '/home/giampaolo' | |
345 >>> p.cmdline() | |
346 ['/usr/bin/python', 'main.py'] | |
347 >>> | |
348 >>> p.pid | |
349 7055 | |
350 >>> p.ppid() | |
351 7054 | |
352 >>> p.children(recursive=True) | |
353 [psutil.Process(pid=29835, name='python2.7', started='11:45:38'), | |
354 psutil.Process(pid=29836, name='python2.7', started='11:43:39')] | |
355 >>> | |
356 >>> p.parent() | |
357 psutil.Process(pid=4699, name='bash', started='09:06:44') | |
358 >>> p.parents() | |
359 [psutil.Process(pid=4699, name='bash', started='09:06:44'), | |
360 psutil.Process(pid=4689, name='gnome-terminal-server', started='0:06:44'), | |
361 psutil.Process(pid=1, name='systemd', started='05:56:55')] | |
362 >>> | |
363 >>> p.status() | |
364 'running' | |
365 >>> p.username() | |
366 'giampaolo' | |
367 >>> p.create_time() | |
368 1267551141.5019531 | |
369 >>> p.terminal() | |
370 '/dev/pts/0' | |
371 >>> | |
372 >>> p.uids() | |
373 puids(real=1000, effective=1000, saved=1000) | |
374 >>> p.gids() | |
375 pgids(real=1000, effective=1000, saved=1000) | |
376 >>> | |
377 >>> p.cpu_times() | |
378 pcputimes(user=1.02, system=0.31, children_user=0.32, children_system=0.1, iowait=0.0) | |
379 >>> p.cpu_percent(interval=1.0) | |
380 12.1 | |
381 >>> p.cpu_affinity() | |
382 [0, 1, 2, 3] | |
383 >>> p.cpu_affinity([0, 1]) # set | |
384 >>> p.cpu_num() | |
385 1 | |
386 >>> | |
387 >>> p.memory_info() | |
388 pmem(rss=10915840, vms=67608576, shared=3313664, text=2310144, lib=0, data=7262208, dirty=0) | |
389 >>> p.memory_full_info() # "real" USS memory usage (Linux, macOS, Win only) | |
390 pfullmem(rss=10199040, vms=52133888, shared=3887104, text=2867200, lib=0, data=5967872, dirty=0, uss=6545408, pss=6872064, swap=0) | |
391 >>> p.memory_percent() | |
392 0.7823 | |
393 >>> p.memory_maps() | |
394 [pmmap_grouped(path='/lib/x8664-linux-gnu/libutil-2.15.so', rss=32768, size=2125824, pss=32768, shared_clean=0, shared_dirty=0, private_clean=20480, private_dirty=12288, referenced=32768, anonymous=12288, swap=0), | |
395 pmmap_grouped(path='/lib/x8664-linux-gnu/libc-2.15.so', rss=3821568, size=3842048, pss=3821568, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=3821568, referenced=3575808, anonymous=3821568, swap=0), | |
396 pmmap_grouped(path='[heap]', rss=32768, size=139264, pss=32768, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=32768, referenced=32768, anonymous=32768, swap=0), | |
397 pmmap_grouped(path='[stack]', rss=2465792, size=2494464, pss=2465792, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=2465792, referenced=2277376, anonymous=2465792, swap=0), | |
398 ...] | |
399 >>> | |
400 >>> p.io_counters() | |
401 pio(read_count=478001, write_count=59371, read_bytes=700416, write_bytes=69632, read_chars=456232, write_chars=517543) | |
402 >>> | |
403 >>> p.open_files() | |
404 [popenfile(path='/home/giampaolo/monit.py', fd=3, position=0, mode='r', flags=32768), | |
405 popenfile(path='/var/log/monit.log', fd=4, position=235542, mode='a', flags=33793)] | |
406 >>> | |
407 >>> p.connections() | |
408 [pconn(fd=115, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=48776), raddr=addr(ip='93.186.135.91', port=80), status='ESTABLISHED'), | |
409 pconn(fd=117, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=43761), raddr=addr(ip='72.14.234.100', port=80), status='CLOSING')] | |
410 >>> | |
411 >>> p.num_threads() | |
412 4 | |
413 >>> p.num_fds() | |
414 8 | |
415 >>> p.threads() | |
416 [pthread(id=5234, user_time=22.5, system_time=9.2891), | |
417 pthread(id=5237, user_time=0.0707, system_time=1.1)] | |
418 >>> | |
419 >>> p.num_ctx_switches() | |
420 pctxsw(voluntary=78, involuntary=19) | |
421 >>> | |
422 >>> p.nice() | |
423 0 | |
424 >>> p.nice(10) # set | |
425 >>> | |
426 >>> p.ionice(psutil.IOPRIO_CLASS_IDLE) # IO priority (Win and Linux only) | |
427 >>> p.ionice() | |
428 pionice(ioclass=<IOPriority.IOPRIO_CLASS_IDLE: 3>, value=0) | |
429 >>> | |
430 >>> p.rlimit(psutil.RLIMIT_NOFILE, (5, 5)) # set resource limits (Linux only) | |
431 >>> p.rlimit(psutil.RLIMIT_NOFILE) | |
432 (5, 5) | |
433 >>> | |
434 >>> p.environ() | |
435 {'LC_PAPER': 'it_IT.UTF-8', 'SHELL': '/bin/bash', 'GREP_OPTIONS': '--color=auto', | |
436 'XDG_CONFIG_DIRS': '/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg', | |
437 ...} | |
438 >>> | |
439 >>> p.as_dict() | |
440 {'status': 'running', 'num_ctx_switches': pctxsw(voluntary=63, involuntary=1), 'pid': 5457, ...} | |
441 >>> p.is_running() | |
442 True | |
443 >>> p.suspend() | |
444 >>> p.resume() | |
445 >>> | |
446 >>> p.terminate() | |
447 >>> p.kill() | |
448 >>> p.wait(timeout=3) | |
449 0 | |
450 >>> | |
451 >>> psutil.test() | |
452 USER PID %CPU %MEM VSZ RSS TTY START TIME COMMAND | |
453 root 1 0.0 0.0 24584 2240 Jun17 00:00 init | |
454 root 2 0.0 0.0 0 0 Jun17 00:00 kthreadd | |
455 ... | |
456 giampaolo 31475 0.0 0.0 20760 3024 /dev/pts/0 Jun19 00:00 python2.4 | |
457 giampaolo 31721 0.0 2.2 773060 181896 00:04 10:30 chrome | |
458 root 31763 0.0 0.0 0 0 00:05 00:00 kworker/0:1 | |
459 >>> | |
460 | |
461 Further process APIs | |
462 -------------------- | |
463 | |
464 .. code-block:: python | |
465 | |
466 >>> import psutil | |
467 >>> for proc in psutil.process_iter(['pid', 'name']): | |
468 ... print(proc.info) | |
469 ... | |
470 {'pid': 1, 'name': 'systemd'} | |
471 {'pid': 2, 'name': 'kthreadd'} | |
472 {'pid': 3, 'name': 'ksoftirqd/0'} | |
473 ... | |
474 >>> | |
475 >>> psutil.pid_exists(3) | |
476 True | |
477 >>> | |
478 >>> def on_terminate(proc): | |
479 ... print("process {} terminated".format(proc)) | |
480 ... | |
481 >>> # waits for multiple processes to terminate | |
482 >>> gone, alive = psutil.wait_procs(procs_list, timeout=3, callback=on_terminate) | |
483 >>> | |
484 | |
485 Popen wrapper: | |
486 | |
487 .. code-block:: python | |
488 | |
489 >>> import psutil | |
490 >>> from subprocess import PIPE | |
491 >>> p = psutil.Popen(["/usr/bin/python", "-c", "print('hello')"], stdout=PIPE) | |
492 >>> p.name() | |
493 'python' | |
494 >>> p.username() | |
495 'giampaolo' | |
496 >>> p.communicate() | |
497 ('hello\n', None) | |
498 >>> p.wait(timeout=2) | |
499 0 | |
500 >>> | |
501 | |
502 Windows services | |
503 ---------------- | |
504 | |
505 .. code-block:: python | |
506 | |
507 >>> list(psutil.win_service_iter()) | |
508 [<WindowsService(name='AeLookupSvc', display_name='Application Experience') at 38850096>, | |
509 <WindowsService(name='ALG', display_name='Application Layer Gateway Service') at 38850128>, | |
510 <WindowsService(name='APNMCP', display_name='Ask Update Service') at 38850160>, | |
511 <WindowsService(name='AppIDSvc', display_name='Application Identity') at 38850192>, | |
512 ...] | |
513 >>> s = psutil.win_service_get('alg') | |
514 >>> s.as_dict() | |
515 {'binpath': 'C:\\Windows\\System32\\alg.exe', | |
516 'description': 'Provides support for 3rd party protocol plug-ins for Internet Connection Sharing', | |
517 'display_name': 'Application Layer Gateway Service', | |
518 'name': 'alg', | |
519 'pid': None, | |
520 'start_type': 'manual', | |
521 'status': 'stopped', | |
522 'username': 'NT AUTHORITY\\LocalService'} | |
523 | |
524 | |
525 .. _`Giampaolo Rodola`: http://grodola.blogspot.com/p/about.html | |
526 .. _`donation`: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A9ZS7PKKRM3S8 | |
527 .. _Tidelift security contact: https://tidelift.com/security | |
528 .. _Tidelift Subscription: https://tidelift.com/subscription/pkg/pypi-psutil?utm_source=pypi-psutil&utm_medium=referral&utm_campaign=readme | |
529 | |
530 | |
531 Keywords: ps,top,kill,free,lsof,netstat,nice,tty,ionice,uptime,taskmgr,process,df,iotop,iostat,ifconfig,taskset,who,pidof,pmap,smem,pstree,monitoring,ulimit,prlimit,smem,performance,metrics,agent,observability | |
532 Platform: Platform Independent | |
533 Classifier: Development Status :: 5 - Production/Stable | |
534 Classifier: Environment :: Console | |
535 Classifier: Environment :: Win32 (MS Windows) | |
536 Classifier: Intended Audience :: Developers | |
537 Classifier: Intended Audience :: Information Technology | |
538 Classifier: Intended Audience :: System Administrators | |
539 Classifier: License :: OSI Approved :: BSD License | |
540 Classifier: Operating System :: MacOS :: MacOS X | |
541 Classifier: Operating System :: Microsoft :: Windows :: Windows 10 | |
542 Classifier: Operating System :: Microsoft :: Windows :: Windows 7 | |
543 Classifier: Operating System :: Microsoft :: Windows :: Windows 8 | |
544 Classifier: Operating System :: Microsoft :: Windows :: Windows 8.1 | |
545 Classifier: Operating System :: Microsoft :: Windows :: Windows Server 2003 | |
546 Classifier: Operating System :: Microsoft :: Windows :: Windows Server 2008 | |
547 Classifier: Operating System :: Microsoft :: Windows :: Windows Vista | |
548 Classifier: Operating System :: Microsoft | |
549 Classifier: Operating System :: OS Independent | |
550 Classifier: Operating System :: POSIX :: AIX | |
551 Classifier: Operating System :: POSIX :: BSD :: FreeBSD | |
552 Classifier: Operating System :: POSIX :: BSD :: NetBSD | |
553 Classifier: Operating System :: POSIX :: BSD :: OpenBSD | |
554 Classifier: Operating System :: POSIX :: BSD | |
555 Classifier: Operating System :: POSIX :: Linux | |
556 Classifier: Operating System :: POSIX :: SunOS/Solaris | |
557 Classifier: Operating System :: POSIX | |
558 Classifier: Programming Language :: C | |
559 Classifier: Programming Language :: Python :: 2 | |
560 Classifier: Programming Language :: Python :: 2.6 | |
561 Classifier: Programming Language :: Python :: 2.7 | |
562 Classifier: Programming Language :: Python :: 3 | |
563 Classifier: Programming Language :: Python :: Implementation :: CPython | |
564 Classifier: Programming Language :: Python :: Implementation :: PyPy | |
565 Classifier: Programming Language :: Python | |
566 Classifier: Topic :: Software Development :: Libraries :: Python Modules | |
567 Classifier: Topic :: Software Development :: Libraries | |
568 Classifier: Topic :: System :: Benchmark | |
569 Classifier: Topic :: System :: Hardware :: Hardware Drivers | |
570 Classifier: Topic :: System :: Hardware | |
571 Classifier: Topic :: System :: Monitoring | |
572 Classifier: Topic :: System :: Networking :: Monitoring :: Hardware Watchdog | |
573 Classifier: Topic :: System :: Networking :: Monitoring | |
574 Classifier: Topic :: System :: Networking | |
575 Classifier: Topic :: System :: Operating System | |
576 Classifier: Topic :: System :: Systems Administration | |
577 Classifier: Topic :: Utilities | |
578 Requires-Python: >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* |