From e405e41fd79c8976e3eedf49b7b33dbbea01d0b8 Mon Sep 17 00:00:00 2001 From: Adnan Hodzic Date: Sun, 13 Sep 2020 21:33:32 +0200 Subject: [PATCH] Display CPU usage per each core --- README.md | 4 ++-- snap/snapcraft.yaml | 2 +- source/core.py | 16 ++++++++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8c459b0..ef2dfb7 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ Supported devices must have an Intel, AMD or ARM CPU's. This tool was developed * Monitoring * Basic system information - * CPU frequency - * CPU temperatures + * CPU frequency (system total & per core) + * CPU usage (system total & per core) * Battery state * System load * CPU frequency scaling, governor and [turbo boost](https://en.wikipedia.org/wiki/Intel_Turbo_Boost) management based on diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 2bf8a67..19644d4 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: auto-cpufreq base: core20 -version: '1.3' +version: '1.3.1' summary: Automatic CPU speed & power optimizer for Linux description: | Automatic CPU speed & power optimizer for Linux based on active diff --git a/source/core.py b/source/core.py index 11ddaf2..2ffdecb 100644 --- a/source/core.py +++ b/source/core.py @@ -482,8 +482,8 @@ def sysinfo(): print("\n" + "-" * 30 + " Current CPU states " + "-" * 30 + "\n") - print(f"CPU max frequency: {psutil.cpu_freq().max:.0f}MHz") - print(f"CPU min frequency: {psutil.cpu_freq().min:.0f}MHz") + print(f"CPU max frequency: {psutil.cpu_freq().max:.0f} MHz") + print(f"CPU min frequency: {psutil.cpu_freq().min:.0f} MHz") core_usage = psutil.cpu_freq(percpu=True) @@ -498,6 +498,18 @@ def sysinfo(): # get hardware temperatures core_temp = psutil.sensors_temperatures() + print("\nCPU usage per each core:\n") + usage_per_core = psutil.cpu_percent(interval=1, percpu=True) + + for core_num in range(len(usage_per_core)): + print(f"CPU{core_num}: {usage_per_core[core_num]} %") + core_num += 1 + + # get number of core temp sensors + core_temp_num = psutil.cpu_count(logical=False) + # get hardware temperatures + core_temp = psutil.sensors_temperatures() + print("\nTemperature for each physical core:\n") core_num = 0 while core_num < core_temp_num: