comparison env/lib/python3.9/site-packages/psutil-5.8.0.dist-info/METADATA @ 0:4f3585e2f14b draft default tip

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