Professional Documents
Culture Documents
Psutil
Psutil
psutil.cpu_stats()
Return various CPU statistics as a named tuple:
Return system swap memory statistics as a named tuple including the following
fields:
sin and sout on Windows are always set to 0. See meminfo.py script providing an
example on how to convert bytes in a human readable form.
Disks psutil.disk_partitions(all=False)
Return disk usage statistics about the partition which contains the
given path as a named tuple including total, used and free space
expressed in bytes, plus the percentage usage. OSError is raised if
path does not exist.
psutil.disk_io_counters(perdisk=False, nowrap=True)
If perdisk is True return the same information for every physical disk installed on the system
as a dictionary with partition names as the keys and the named tuple described above as the
values. See iotop.py for an example application. On some systems such as Linux, on a very
busy or long-lived system, the numbers returned by the kernel may overflow and wrap
(restart from zero). If nowrap is True psutil will detect and adjust those numbers across
function calls and add “old value” to “new value” so that the returned numbers will always
be increasing or remain the same, but never decrease. disk_io_counters.cache_clear() can be
used to invalidate the nowrap cache. On Windows it may be ncessary to issue diskperf -y
command from cmd.exe first in order to enable IO counters. On diskless machines this
function will return None or {} if perdisk is True.