diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-01-16 11:12:31 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-01-16 11:12:31 +0100 |
commit | 678292f90c6961a0d0fe9f5bd80f7fbde8f79e85 (patch) | |
tree | feada50e667b7335cc9b257b5fd0a5ef4b346eb3 | |
parent | efaa9e0169e790310e19cea1c4d8389395387c0d (diff) | |
download | psutil-678292f90c6961a0d0fe9f5bd80f7fbde8f79e85.tar.gz |
AD script: print AD percentage + elapsed time
-rw-r--r-- | HISTORY.rst | 2 | ||||
-rwxr-xr-x | psutil/tests/test_contracts.py | 2 | ||||
-rw-r--r-- | scripts/internal/print_access_denied.py | 9 |
3 files changed, 9 insertions, 4 deletions
diff --git a/HISTORY.rst b/HISTORY.rst index 4ca36b81..4841d26e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,7 @@ XXXX-XX-XX **Enhancements** +- 1637_: [SunOS] Add partial support for old SunOS 5.10 Update 0 to 3. - 1648_: [Linux] sensors_temperatures() looks into an additional /sys/device/ directory for additional data. (patch by Javad Karabi) - 1652_: [Windows] dropped support for Windows XP and Windows Server 2003. @@ -14,7 +15,6 @@ XXXX-XX-XX **Bug fixes** -- 1637_: [SunOS] Add partial support for old SunOS 5.10 Update 0 to 3. - 1642_: [SunOS] querying basic info for PID 0 results in FileNotFoundError. - 1646_: [FreeBSD] many Process methods may cause a segfault on FreeBSD 12.0 due to a backward incompatible change in a C type introduced in 12.0. diff --git a/psutil/tests/test_contracts.py b/psutil/tests/test_contracts.py index ec1aeb1a..509ffc0c 100755 --- a/psutil/tests/test_contracts.py +++ b/psutil/tests/test_contracts.py @@ -238,7 +238,7 @@ class TestSystemAPITypes(unittest.TestCase): @unittest.skipIf(not HAS_CPU_FREQ, "not supported") def test_cpu_freq(self): - self.assert_ntuple_of_nums(psutil.cpu_freq(), type_=(float, int)) + self.assert_ntuple_of_nums(psutil.cpu_freq(), type_=(float, int, long)) def test_disk_io_counters(self): # Duplicate of test_system.py. Keep it anyway. diff --git a/scripts/internal/print_access_denied.py b/scripts/internal/print_access_denied.py index 1519c94b..b94e6e00 100644 --- a/scripts/internal/print_access_denied.py +++ b/scripts/internal/print_access_denied.py @@ -47,6 +47,7 @@ Totals: access-denied=1744, calls=10020, processes=334 from __future__ import print_function, division from collections import defaultdict +import time import psutil from scriptutils import hilite @@ -59,6 +60,7 @@ def main(): tot_calls = 0 signaler = object() d = defaultdict(int) + start = time.time() for p in psutil.process_iter(attrs=[], ad_value=signaler): tot_procs += 1 for methname, value in p.info.items(): @@ -68,6 +70,7 @@ def main(): d[methname] += 1 else: d[methname] += 0 + elapsed = time.time() - start # print templ = "%-20s %-5s %-9s %s" @@ -79,9 +82,11 @@ def main(): s = templ % (methname, ads, "%6.1f%%" % perc, outcome) s = hilite(s, ok=not ads) print(s) + tot_perc = round((tot_ads / tot_calls) * 100, 1) print("-" * 50) - print("Totals: access-denied=%s, calls=%s, processes=%s" % ( - tot_ads, tot_calls, tot_procs)) + print("Totals: access-denied=%s (%s%%), calls=%s, processes=%s, " + "elapsed=%ss" % (tot_ads, tot_perc, tot_calls, tot_procs, + round(elapsed, 2))) if __name__ == '__main__': |