Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/psutil-5.7.2-py3.7.egg-info/PKG-INFO @ 1:56ad4e20f292 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
| author | guerler |
|---|---|
| date | Fri, 31 Jul 2020 00:32:28 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:d30785e31577 | 1:56ad4e20f292 |
|---|---|
| 1 Metadata-Version: 2.1 | |
| 2 Name: psutil | |
| 3 Version: 5.7.2 | |
| 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 <https://gmpy.dev/tags/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+**, `PyPy <http://pypy.org/>`__ 2.7 and 3.X. | |
| 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 Donate | |
| 143 ====== | |
| 144 | |
| 145 A lot of time and effort went into making psutil as it is today. If you whish | |
| 146 to help its future development consider making me a `donation <https://gmpy.dev/donate>`__. | |
| 147 | |
| 148 Projects using psutil | |
| 149 ===================== | |
| 150 | |
| 151 psutil has roughly the following monthly downloads: | |
| 152 | |
| 153 .. image:: https://img.shields.io/pypi/dm/psutil.svg | |
| 154 :target: https://pepy.tech/project/psutil | |
| 155 :alt: Downloads | |
| 156 | |
| 157 ...and has over 45,000 projects on GitHub depending from it. | |
| 158 Here's some I find particularly interesting: | |
| 159 | |
| 160 - https://github.com/google/grr | |
| 161 - https://github.com/facebook/osquery/ | |
| 162 - https://github.com/nicolargo/glances | |
| 163 - https://github.com/Jahaja/psdash | |
| 164 - https://github.com/ajenti/ajenti | |
| 165 - https://github.com/home-assistant/home-assistant/ | |
| 166 | |
| 167 Portings | |
| 168 ======== | |
| 169 | |
| 170 - Go: https://github.com/shirou/gopsutil | |
| 171 - C: https://github.com/hamon-in/cpslib | |
| 172 - Rust: https://github.com/borntyping/rust-psutil | |
| 173 - Nim: https://github.com/johnscillieri/psutil-nim | |
| 174 | |
| 175 Example usages | |
| 176 ============== | |
| 177 | |
| 178 This represents pretty much the whole psutil API. | |
| 179 | |
| 180 CPU | |
| 181 --- | |
| 182 | |
| 183 .. code-block:: python | |
| 184 | |
| 185 >>> import psutil | |
| 186 >>> | |
| 187 >>> psutil.cpu_times() | |
| 188 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) | |
| 189 >>> | |
| 190 >>> for x in range(3): | |
| 191 ... psutil.cpu_percent(interval=1) | |
| 192 ... | |
| 193 4.0 | |
| 194 5.9 | |
| 195 3.8 | |
| 196 >>> | |
| 197 >>> for x in range(3): | |
| 198 ... psutil.cpu_percent(interval=1, percpu=True) | |
| 199 ... | |
| 200 [4.0, 6.9, 3.7, 9.2] | |
| 201 [7.0, 8.5, 2.4, 2.1] | |
| 202 [1.2, 9.0, 9.9, 7.2] | |
| 203 >>> | |
| 204 >>> for x in range(3): | |
| 205 ... psutil.cpu_times_percent(interval=1, percpu=False) | |
| 206 ... | |
| 207 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) | |
| 208 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) | |
| 209 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) | |
| 210 >>> | |
| 211 >>> psutil.cpu_count() | |
| 212 4 | |
| 213 >>> psutil.cpu_count(logical=False) | |
| 214 2 | |
| 215 >>> | |
| 216 >>> psutil.cpu_stats() | |
| 217 scpustats(ctx_switches=20455687, interrupts=6598984, soft_interrupts=2134212, syscalls=0) | |
| 218 >>> | |
| 219 >>> psutil.cpu_freq() | |
| 220 scpufreq(current=931.42925, min=800.0, max=3500.0) | |
| 221 >>> | |
| 222 >>> psutil.getloadavg() # also on Windows (emulated) | |
| 223 (3.14, 3.89, 4.67) | |
| 224 | |
| 225 Memory | |
| 226 ------ | |
| 227 | |
| 228 .. code-block:: python | |
| 229 | |
| 230 >>> psutil.virtual_memory() | |
| 231 svmem(total=10367352832, available=6472179712, percent=37.6, used=8186245120, free=2181107712, active=4748992512, inactive=2758115328, buffers=790724608, cached=3500347392, shared=787554304) | |
| 232 >>> psutil.swap_memory() | |
| 233 sswap(total=2097147904, used=296128512, free=1801019392, percent=14.1, sin=304193536, sout=677842944) | |
| 234 >>> | |
| 235 | |
| 236 Disks | |
| 237 ----- | |
| 238 | |
| 239 .. code-block:: python | |
| 240 | |
| 241 >>> psutil.disk_partitions() | |
| 242 [sdiskpart(device='/dev/sda1', mountpoint='/', fstype='ext4', opts='rw,nosuid'), | |
| 243 sdiskpart(device='/dev/sda2', mountpoint='/home', fstype='ext, opts='rw')] | |
| 244 >>> | |
| 245 >>> psutil.disk_usage('/') | |
| 246 sdiskusage(total=21378641920, used=4809781248, free=15482871808, percent=22.5) | |
| 247 >>> | |
| 248 >>> psutil.disk_io_counters(perdisk=False) | |
| 249 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) | |
| 250 >>> | |
| 251 | |
| 252 Network | |
| 253 ------- | |
| 254 | |
| 255 .. code-block:: python | |
| 256 | |
| 257 >>> psutil.net_io_counters(pernic=True) | |
| 258 {'eth0': netio(bytes_sent=485291293, bytes_recv=6004858642, packets_sent=3251564, packets_recv=4787798, errin=0, errout=0, dropin=0, dropout=0), | |
| 259 'lo': netio(bytes_sent=2838627, bytes_recv=2838627, packets_sent=30567, packets_recv=30567, errin=0, errout=0, dropin=0, dropout=0)} | |
| 260 >>> | |
| 261 >>> psutil.net_connections() | |
| 262 [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), | |
| 263 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), | |
| 264 ...] | |
| 265 >>> | |
| 266 >>> psutil.net_if_addrs() | |
| 267 {'lo': [snicaddr(family=<AddressFamily.AF_INET: 2>, address='127.0.0.1', netmask='255.0.0.0', broadcast='127.0.0.1', ptp=None), | |
| 268 snicaddr(family=<AddressFamily.AF_INET6: 10>, address='::1', netmask='ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', broadcast=None, ptp=None), | |
| 269 snicaddr(family=<AddressFamily.AF_LINK: 17>, address='00:00:00:00:00:00', netmask=None, broadcast='00:00:00:00:00:00', ptp=None)], | |
| 270 'wlan0': [snicaddr(family=<AddressFamily.AF_INET: 2>, address='192.168.1.3', netmask='255.255.255.0', broadcast='192.168.1.255', ptp=None), | |
| 271 snicaddr(family=<AddressFamily.AF_INET6: 10>, address='fe80::c685:8ff:fe45:641%wlan0', netmask='ffff:ffff:ffff:ffff::', broadcast=None, ptp=None), | |
| 272 snicaddr(family=<AddressFamily.AF_LINK: 17>, address='c4:85:08:45:06:41', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)]} | |
| 273 >>> | |
| 274 >>> psutil.net_if_stats() | |
| 275 {'lo': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_UNKNOWN: 0>, speed=0, mtu=65536), | |
| 276 'wlan0': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_FULL: 2>, speed=100, mtu=1500)} | |
| 277 >>> | |
| 278 | |
| 279 Sensors | |
| 280 ------- | |
| 281 | |
| 282 .. code-block:: python | |
| 283 | |
| 284 >>> import psutil | |
| 285 >>> psutil.sensors_temperatures() | |
| 286 {'acpitz': [shwtemp(label='', current=47.0, high=103.0, critical=103.0)], | |
| 287 'asus': [shwtemp(label='', current=47.0, high=None, critical=None)], | |
| 288 'coretemp': [shwtemp(label='Physical id 0', current=52.0, high=100.0, critical=100.0), | |
| 289 shwtemp(label='Core 0', current=45.0, high=100.0, critical=100.0)]} | |
| 290 >>> | |
| 291 >>> psutil.sensors_fans() | |
| 292 {'asus': [sfan(label='cpu_fan', current=3200)]} | |
| 293 >>> | |
| 294 >>> psutil.sensors_battery() | |
| 295 sbattery(percent=93, secsleft=16628, power_plugged=False) | |
| 296 >>> | |
| 297 | |
| 298 Other system info | |
| 299 ----------------- | |
| 300 | |
| 301 .. code-block:: python | |
| 302 | |
| 303 >>> import psutil | |
| 304 >>> psutil.users() | |
| 305 [suser(name='giampaolo', terminal='pts/2', host='localhost', started=1340737536.0, pid=1352), | |
| 306 suser(name='giampaolo', terminal='pts/3', host='localhost', started=1340737792.0, pid=1788)] | |
| 307 >>> | |
| 308 >>> psutil.boot_time() | |
| 309 1365519115.0 | |
| 310 >>> | |
| 311 | |
| 312 Process management | |
| 313 ------------------ | |
| 314 | |
| 315 .. code-block:: python | |
| 316 | |
| 317 >>> import psutil | |
| 318 >>> psutil.pids() | |
| 319 [1, 2, 3, 4, 5, 6, 7, 46, 48, 50, 51, 178, 182, 222, 223, 224, 268, 1215, 1216, 1220, 1221, 1243, 1244, | |
| 320 1301, 1601, 2237, 2355, 2637, 2774, 3932, 4176, 4177, 4185, 4187, 4189, 4225, 4243, 4245, 4263, 4282, | |
| 321 4306, 4311, 4312, 4313, 4314, 4337, 4339, 4357, 4358, 4363, 4383, 4395, 4408, 4433, 4443, 4445, 4446, | |
| 322 5167, 5234, 5235, 5252, 5318, 5424, 5644, 6987, 7054, 7055, 7071] | |
| 323 >>> | |
| 324 >>> p = psutil.Process(7055) | |
| 325 >>> p | |
| 326 psutil.Process(pid=7055, name='python3', status='running', started='09:04:44') | |
| 327 >>> p.name() | |
| 328 'python' | |
| 329 >>> p.exe() | |
| 330 '/usr/bin/python' | |
| 331 >>> p.cwd() | |
| 332 '/home/giampaolo' | |
| 333 >>> p.cmdline() | |
| 334 ['/usr/bin/python', 'main.py'] | |
| 335 >>> | |
| 336 >>> p.pid | |
| 337 7055 | |
| 338 >>> p.ppid() | |
| 339 7054 | |
| 340 >>> p.children(recursive=True) | |
| 341 [psutil.Process(pid=29835, name='python3', status='sleeping', started='11:45:38'), | |
| 342 psutil.Process(pid=29836, name='python3', status='waking', started='11:43:39')] | |
| 343 >>> | |
| 344 >>> p.parent() | |
| 345 psutil.Process(pid=4699, name='bash', status='sleeping', started='09:06:44') | |
| 346 >>> p.parents() | |
| 347 [psutil.Process(pid=4699, name='bash', started='09:06:44'), | |
| 348 psutil.Process(pid=4689, name='gnome-terminal-server', status='sleeping', started='0:06:44'), | |
| 349 psutil.Process(pid=1, name='systemd', status='sleeping', started='05:56:55')] | |
| 350 >>> | |
| 351 >>> p.status() | |
| 352 'running' | |
| 353 >>> p.username() | |
| 354 'giampaolo' | |
| 355 >>> p.create_time() | |
| 356 1267551141.5019531 | |
| 357 >>> p.terminal() | |
| 358 '/dev/pts/0' | |
| 359 >>> | |
| 360 >>> p.uids() | |
| 361 puids(real=1000, effective=1000, saved=1000) | |
| 362 >>> p.gids() | |
| 363 pgids(real=1000, effective=1000, saved=1000) | |
| 364 >>> | |
| 365 >>> p.cpu_times() | |
| 366 pcputimes(user=1.02, system=0.31, children_user=0.32, children_system=0.1, iowait=0.0) | |
| 367 >>> p.cpu_percent(interval=1.0) | |
| 368 12.1 | |
| 369 >>> p.cpu_affinity() | |
| 370 [0, 1, 2, 3] | |
| 371 >>> p.cpu_affinity([0, 1]) # set | |
| 372 >>> p.cpu_num() | |
| 373 1 | |
| 374 >>> | |
| 375 >>> p.memory_info() | |
| 376 pmem(rss=10915840, vms=67608576, shared=3313664, text=2310144, lib=0, data=7262208, dirty=0) | |
| 377 >>> p.memory_full_info() # "real" USS memory usage (Linux, macOS, Win only) | |
| 378 pfullmem(rss=10199040, vms=52133888, shared=3887104, text=2867200, lib=0, data=5967872, dirty=0, uss=6545408, pss=6872064, swap=0) | |
| 379 >>> p.memory_percent() | |
| 380 0.7823 | |
| 381 >>> p.memory_maps() | |
| 382 [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), | |
| 383 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), | |
| 384 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), | |
| 385 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), | |
| 386 ...] | |
| 387 >>> | |
| 388 >>> p.io_counters() | |
| 389 pio(read_count=478001, write_count=59371, read_bytes=700416, write_bytes=69632, read_chars=456232, write_chars=517543) | |
| 390 >>> | |
| 391 >>> p.open_files() | |
| 392 [popenfile(path='/home/giampaolo/monit.py', fd=3, position=0, mode='r', flags=32768), | |
| 393 popenfile(path='/var/log/monit.log', fd=4, position=235542, mode='a', flags=33793)] | |
| 394 >>> | |
| 395 >>> p.connections() | |
| 396 [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'), | |
| 397 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')] | |
| 398 >>> | |
| 399 >>> p.num_threads() | |
| 400 4 | |
| 401 >>> p.num_fds() | |
| 402 8 | |
| 403 >>> p.threads() | |
| 404 [pthread(id=5234, user_time=22.5, system_time=9.2891), | |
| 405 pthread(id=5237, user_time=0.0707, system_time=1.1)] | |
| 406 >>> | |
| 407 >>> p.num_ctx_switches() | |
| 408 pctxsw(voluntary=78, involuntary=19) | |
| 409 >>> | |
| 410 >>> p.nice() | |
| 411 0 | |
| 412 >>> p.nice(10) # set | |
| 413 >>> | |
| 414 >>> p.ionice(psutil.IOPRIO_CLASS_IDLE) # IO priority (Win and Linux only) | |
| 415 >>> p.ionice() | |
| 416 pionice(ioclass=<IOPriority.IOPRIO_CLASS_IDLE: 3>, value=0) | |
| 417 >>> | |
| 418 >>> p.rlimit(psutil.RLIMIT_NOFILE, (5, 5)) # set resource limits (Linux only) | |
| 419 >>> p.rlimit(psutil.RLIMIT_NOFILE) | |
| 420 (5, 5) | |
| 421 >>> | |
| 422 >>> p.environ() | |
| 423 {'LC_PAPER': 'it_IT.UTF-8', 'SHELL': '/bin/bash', 'GREP_OPTIONS': '--color=auto', | |
| 424 'XDG_CONFIG_DIRS': '/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg', | |
| 425 ...} | |
| 426 >>> | |
| 427 >>> p.as_dict() | |
| 428 {'status': 'running', 'num_ctx_switches': pctxsw(voluntary=63, involuntary=1), 'pid': 5457, ...} | |
| 429 >>> p.is_running() | |
| 430 True | |
| 431 >>> p.suspend() | |
| 432 >>> p.resume() | |
| 433 >>> | |
| 434 >>> p.terminate() | |
| 435 >>> p.kill() | |
| 436 >>> p.wait(timeout=3) | |
| 437 <Exitcode.EX_OK: 0> | |
| 438 >>> | |
| 439 >>> psutil.test() | |
| 440 USER PID %CPU %MEM VSZ RSS TTY START TIME COMMAND | |
| 441 root 1 0.0 0.0 24584 2240 Jun17 00:00 init | |
| 442 root 2 0.0 0.0 0 0 Jun17 00:00 kthreadd | |
| 443 ... | |
| 444 giampaolo 31475 0.0 0.0 20760 3024 /dev/pts/0 Jun19 00:00 python2.4 | |
| 445 giampaolo 31721 0.0 2.2 773060 181896 00:04 10:30 chrome | |
| 446 root 31763 0.0 0.0 0 0 00:05 00:00 kworker/0:1 | |
| 447 >>> | |
| 448 | |
| 449 Further process APIs | |
| 450 -------------------- | |
| 451 | |
| 452 .. code-block:: python | |
| 453 | |
| 454 >>> import psutil | |
| 455 >>> for proc in psutil.process_iter(['pid', 'name']): | |
| 456 ... print(proc.info) | |
| 457 ... | |
| 458 {'pid': 1, 'name': 'systemd'} | |
| 459 {'pid': 2, 'name': 'kthreadd'} | |
| 460 {'pid': 3, 'name': 'ksoftirqd/0'} | |
| 461 ... | |
| 462 >>> | |
| 463 >>> psutil.pid_exists(3) | |
| 464 True | |
| 465 >>> | |
| 466 >>> def on_terminate(proc): | |
| 467 ... print("process {} terminated".format(proc)) | |
| 468 ... | |
| 469 >>> # waits for multiple processes to terminate | |
| 470 >>> gone, alive = psutil.wait_procs(procs_list, timeout=3, callback=on_terminate) | |
| 471 >>> | |
| 472 | |
| 473 Popen wrapper: | |
| 474 | |
| 475 .. code-block:: python | |
| 476 | |
| 477 >>> import psutil | |
| 478 >>> from subprocess import PIPE | |
| 479 >>> p = psutil.Popen(["/usr/bin/python", "-c", "print('hello')"], stdout=PIPE) | |
| 480 >>> p.name() | |
| 481 'python' | |
| 482 >>> p.username() | |
| 483 'giampaolo' | |
| 484 >>> p.communicate() | |
| 485 ('hello\n', None) | |
| 486 >>> p.wait(timeout=2) | |
| 487 0 | |
| 488 >>> | |
| 489 | |
| 490 Windows services | |
| 491 ---------------- | |
| 492 | |
| 493 .. code-block:: python | |
| 494 | |
| 495 >>> list(psutil.win_service_iter()) | |
| 496 [<WindowsService(name='AeLookupSvc', display_name='Application Experience') at 38850096>, | |
| 497 <WindowsService(name='ALG', display_name='Application Layer Gateway Service') at 38850128>, | |
| 498 <WindowsService(name='APNMCP', display_name='Ask Update Service') at 38850160>, | |
| 499 <WindowsService(name='AppIDSvc', display_name='Application Identity') at 38850192>, | |
| 500 ...] | |
| 501 >>> s = psutil.win_service_get('alg') | |
| 502 >>> s.as_dict() | |
| 503 {'binpath': 'C:\\Windows\\System32\\alg.exe', | |
| 504 'description': 'Provides support for 3rd party protocol plug-ins for Internet Connection Sharing', | |
| 505 'display_name': 'Application Layer Gateway Service', | |
| 506 'name': 'alg', | |
| 507 'pid': None, | |
| 508 'start_type': 'manual', | |
| 509 'status': 'stopped', | |
| 510 'username': 'NT AUTHORITY\\LocalService'} | |
| 511 | |
| 512 | |
| 513 .. _`Giampaolo Rodola`: https://gmpy.dev/about | |
| 514 .. _`donation`: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A9ZS7PKKRM3S8 | |
| 515 .. _Tidelift security contact: https://tidelift.com/security | |
| 516 .. _Tidelift Subscription: https://tidelift.com/subscription/pkg/pypi-psutil?utm_source=pypi-psutil&utm_medium=referral&utm_campaign=readme | |
| 517 | |
| 518 | |
| 519 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 | |
| 520 Platform: Platform Independent | |
| 521 Classifier: Development Status :: 5 - Production/Stable | |
| 522 Classifier: Environment :: Console | |
| 523 Classifier: Environment :: Win32 (MS Windows) | |
| 524 Classifier: Intended Audience :: Developers | |
| 525 Classifier: Intended Audience :: Information Technology | |
| 526 Classifier: Intended Audience :: System Administrators | |
| 527 Classifier: License :: OSI Approved :: BSD License | |
| 528 Classifier: Operating System :: MacOS :: MacOS X | |
| 529 Classifier: Operating System :: Microsoft :: Windows :: Windows 10 | |
| 530 Classifier: Operating System :: Microsoft :: Windows :: Windows 7 | |
| 531 Classifier: Operating System :: Microsoft :: Windows :: Windows 8 | |
| 532 Classifier: Operating System :: Microsoft :: Windows :: Windows 8.1 | |
| 533 Classifier: Operating System :: Microsoft :: Windows :: Windows Server 2003 | |
| 534 Classifier: Operating System :: Microsoft :: Windows :: Windows Server 2008 | |
| 535 Classifier: Operating System :: Microsoft :: Windows :: Windows Vista | |
| 536 Classifier: Operating System :: Microsoft | |
| 537 Classifier: Operating System :: OS Independent | |
| 538 Classifier: Operating System :: POSIX :: AIX | |
| 539 Classifier: Operating System :: POSIX :: BSD :: FreeBSD | |
| 540 Classifier: Operating System :: POSIX :: BSD :: NetBSD | |
| 541 Classifier: Operating System :: POSIX :: BSD :: OpenBSD | |
| 542 Classifier: Operating System :: POSIX :: BSD | |
| 543 Classifier: Operating System :: POSIX :: Linux | |
| 544 Classifier: Operating System :: POSIX :: SunOS/Solaris | |
| 545 Classifier: Operating System :: POSIX | |
| 546 Classifier: Programming Language :: C | |
| 547 Classifier: Programming Language :: Python :: 2 | |
| 548 Classifier: Programming Language :: Python :: 2.6 | |
| 549 Classifier: Programming Language :: Python :: 2.7 | |
| 550 Classifier: Programming Language :: Python :: 3 | |
| 551 Classifier: Programming Language :: Python :: Implementation :: CPython | |
| 552 Classifier: Programming Language :: Python :: Implementation :: PyPy | |
| 553 Classifier: Programming Language :: Python | |
| 554 Classifier: Topic :: Software Development :: Libraries :: Python Modules | |
| 555 Classifier: Topic :: Software Development :: Libraries | |
| 556 Classifier: Topic :: System :: Benchmark | |
| 557 Classifier: Topic :: System :: Hardware :: Hardware Drivers | |
| 558 Classifier: Topic :: System :: Hardware | |
| 559 Classifier: Topic :: System :: Monitoring | |
| 560 Classifier: Topic :: System :: Networking :: Monitoring :: Hardware Watchdog | |
| 561 Classifier: Topic :: System :: Networking :: Monitoring | |
| 562 Classifier: Topic :: System :: Networking | |
| 563 Classifier: Topic :: System :: Operating System | |
| 564 Classifier: Topic :: System :: Systems Administration | |
| 565 Classifier: Topic :: Utilities | |
| 566 Requires-Python: >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* | |
| 567 Provides-Extra: test |
