diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-03-12 15:44:02 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-03-12 15:44:02 +0100 |
commit | 841bd1af77f49e33fe5ba60041f575dbe3bb2f8f (patch) | |
tree | af50b5b63caf4fc60d174d0627bf0f9bf332ff86 | |
parent | 8563d432f795ebc7cbaadb926970e4063ced0642 (diff) | |
download | psutil-841bd1af77f49e33fe5ba60041f575dbe3bb2f8f.tar.gz |
unify cpu stats by getting rid of some info
-rw-r--r-- | README.rst | 2 | ||||
-rw-r--r-- | docs/index.rst | 17 | ||||
-rw-r--r-- | psutil/_common.py | 3 | ||||
-rw-r--r-- | psutil/_psbsd.py | 5 | ||||
-rw-r--r-- | psutil/_pslinux.py | 6 | ||||
-rw-r--r-- | psutil/_psosx.py | 7 | ||||
-rw-r--r-- | psutil/_pssunos.py | 6 | ||||
-rw-r--r-- | psutil/_pswindows.py | 6 |
8 files changed, 23 insertions, 29 deletions
@@ -118,7 +118,7 @@ CPU 2 >>> >>> psutil.cpu_stats() - scpustats(ctx_switches=20455687, interrupts=6598984, soft_interrupts=2134212) + scpustats(ctx_switches=20455687, interrupts=6598984, soft_interrupts=2134212, syscalls=0) Memory ====== diff --git a/docs/index.rst b/docs/index.rst index d236e64b..797e6b78 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -152,20 +152,17 @@ CPU .. function:: cpu_stats() - Return various CPU statistics as a namedtuple whose fields change depending - on the platform: + Return various CPU statistics as a namedtuple: - **ctx_switches**: number of context switches (voluntary + involuntary) since boot. - **interrupts**: number of interrupts since boot. - - **soft_interrupts** *(POSIX)*: - number of software interrupts since boot. - - **syscalls** *(all platforms except Linux)*: number of system calls since boot. - - **traps** *(BSD, OSX, SunOS)*: number of kernel traps since boot. - - **dpcs** *(Windows)*: number of - `delayed procedure calls <https://technet.microsoft.com/en-us/library/cc938646.aspx>`__ - since boot. + - **soft_interrupts**: + number of software interrupts since boot. Always set to ``0`` on Windows + and SunOS. + - **syscalls***: number of system calls since boot. Always set to ``0`` on + Linux. Example (Linux): @@ -173,7 +170,7 @@ CPU >>> import psutil >>> psutil.cpu_stats() - scpustats(ctx_switches=20455687, interrupts=6598984, soft_interrupts=2134212) + scpustats(ctx_switches=20455687, interrupts=6598984, soft_interrupts=2134212, syscalls=0) .. versionadded:: 4.1.0 diff --git a/psutil/_common.py b/psutil/_common.py index b146c736..fe68c6b6 100644 --- a/psutil/_common.py +++ b/psutil/_common.py @@ -306,6 +306,9 @@ sconn = namedtuple('sconn', ['fd', 'family', 'type', 'laddr', 'raddr', snic = namedtuple('snic', ['family', 'address', 'netmask', 'broadcast', 'ptp']) # psutil.net_if_stats() snicstats = namedtuple('snicstats', ['isup', 'duplex', 'speed', 'mtu']) +# psutil.cpu_stats() +scpustats = namedtuple( + 'scpustats', ['ctx_switches', 'interrupts', 'soft_interrupts', 'syscalls']) # --- namedtuples for psutil.Process methods diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py index 6ea54bde..29211cb6 100644 --- a/psutil/_psbsd.py +++ b/psutil/_psbsd.py @@ -106,9 +106,6 @@ pmmap_grouped = namedtuple( 'pmmap_grouped', 'path rss, private, ref_count, shadow_count') pmmap_ext = namedtuple( 'pmmap_ext', 'addr, perms path rss, private, ref_count, shadow_count') -scpustats = namedtuple( - 'scpustats', ['ctx_switches', 'interrupts', 'soft_interrupts', 'syscalls', - 'traps']) if FREEBSD: sdiskio = namedtuple('sdiskio', ['read_count', 'write_count', 'read_bytes', 'write_bytes', @@ -250,7 +247,7 @@ def cpu_stats(): # faults and forks. ctxsw, intrs, soft_intrs, syscalls, traps, faults, forks = \ cext.cpu_stats() - return scpustats(ctxsw, intrs, soft_intrs, syscalls, traps) + return _common.scpustats(ctxsw, intrs, soft_intrs, syscalls) def boot_time(): diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index b97313a3..c03ba523 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -246,8 +246,6 @@ sdiskio = namedtuple('sdiskio', ['read_count', 'write_count', 'read_time', 'write_time', 'read_merged_count', 'write_merged_count', 'busy_time']) -scpustats = namedtuple('scpustats', - ['ctx_switches', 'interrupts', 'soft_interrupts']) popenfile = namedtuple('popenfile', ['path', 'fd', 'position', 'mode', 'flags']) pmem = namedtuple('pmem', 'rss vms shared text lib data dirty') @@ -445,7 +443,9 @@ def cpu_stats(): if ctx_switches is not None and soft_interrupts is not None \ and interrupts is not None: break - return scpustats(ctx_switches, interrupts, soft_interrupts) + syscalls = 0 + return _common.scpustats( + ctx_switches, interrupts, soft_interrupts, syscalls) # --- other system functions diff --git a/psutil/_psosx.py b/psutil/_psosx.py index db21d542..77e5ed58 100644 --- a/psutil/_psosx.py +++ b/psutil/_psosx.py @@ -60,9 +60,6 @@ svmem = namedtuple( pmem = namedtuple('pmem', ['rss', 'vms', 'pfaults', 'pageins']) pfullmem = namedtuple('pfullmem', pmem._fields + ('uss', )) -scpustats = namedtuple( - 'scpustats', ['ctx_switches', 'interrupts', 'soft_interrupts', - 'syscalls', 'traps']) pmmap_grouped = namedtuple( 'pmmap_grouped', @@ -126,8 +123,8 @@ def cpu_count_physical(): def cpu_stats(): ctx_switches, interrupts, soft_interrupts, syscalls, traps = \ cext.cpu_stats() - return scpustats( - ctx_switches, interrupts, soft_interrupts, syscalls, traps) + return _common.scpustats( + ctx_switches, interrupts, soft_interrupts, syscalls) def boot_time(): diff --git a/psutil/_pssunos.py b/psutil/_pssunos.py index 33799e76..cc9931b3 100644 --- a/psutil/_pssunos.py +++ b/psutil/_pssunos.py @@ -68,8 +68,6 @@ pmmap_grouped = namedtuple('pmmap_grouped', ['path', 'rss', 'anonymous', 'locked']) pmmap_ext = namedtuple( 'pmmap_ext', 'addr perms ' + ' '.join(pmmap_grouped._fields)) -scpustats = namedtuple( - 'scpustats', ['ctx_switches', 'interrupts', 'syscalls', 'traps']) # set later from __init__.py @@ -173,7 +171,9 @@ def cpu_count_physical(): def cpu_stats(): ctx_switches, interrupts, syscalls, traps = cext.cpu_stats() - return scpustats(ctx_switches, interrupts, syscalls, traps) + soft_interrupts = 0 + return _common.scpustats(ctx_switches, interrupts, soft_interrupts, + syscalls) def boot_time(): diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py index 731c2051..835816e1 100644 --- a/psutil/_pswindows.py +++ b/psutil/_pswindows.py @@ -98,8 +98,6 @@ ntpinfo = namedtuple( 'ntpinfo', ['num_handles', 'ctx_switches', 'user_time', 'kernel_time', 'create_time', 'num_threads', 'io_rcount', 'io_wcount', 'io_rbytes', 'io_wbytes']) -ssysinfo = namedtuple( - 'ssysinfo', ['ctx_switches', 'interrupts', 'dpcs', 'syscalls']) # set later from __init__.py @@ -215,7 +213,9 @@ def cpu_count_physical(): def cpu_stats(): """Return CPU statistics.""" ctx_switches, interrupts, dpcs, syscalls = cext.cpu_stats() - return ssysinfo(ctx_switches, interrupts, dpcs, syscalls) + soft_interrupts = 0 + return _common.scpustats(ctx_switches, interrupts, soft_interrupts, + syscalls) def boot_time(): |