summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBharath Vignesh J K <52282402+RazCrimson@users.noreply.github.com>2024-07-01 10:27:33 +0530
committerBharath Vignesh J K <52282402+RazCrimson@users.noreply.github.com>2024-07-01 10:27:33 +0530
commit6af2340c5cb3493130c12c8642f34d77ecd97a74 (patch)
treece1458981fd42e42962a777720b8241ac8b273f5
parent46abd4b4c9b8486f4547590b3c005456d74780f0 (diff)
chg: plugin(percpu) - show times based on host OS
-rw-r--r--glances/cpu_percent.py4
-rw-r--r--glances/plugins/percpu/__init__.py25
2 files changed, 24 insertions, 5 deletions
diff --git a/glances/cpu_percent.py b/glances/cpu_percent.py
index 4ae0f1b0..0f76e7d8 100644
--- a/glances/cpu_percent.py
+++ b/glances/cpu_percent.py
@@ -38,6 +38,8 @@ class PerCpuPercentInfo(TypedDict):
steal: Optional[float]
guest: Optional[float]
guest_nice: Optional[float]
+ dpc: Optional[float]
+ interrupt: Optional[float]
class CpuPercent:
@@ -146,6 +148,8 @@ class CpuPercent:
'steal': cpu_times.steal if hasattr(cpu_times, 'steal') else None,
'guest': cpu_times.guest if hasattr(cpu_times, 'guest') else None,
'guest_nice': cpu_times.steal if hasattr(cpu_times, 'guest_nice') else None,
+ 'dpc': cpu_times.dpc if hasattr(cpu_times, 'dpc') else None,
+ 'interrupt': cpu_times.interrupt if hasattr(cpu_times, 'interrupt') else None,
}
for cpu_number, cpu_times in psutil_percpu
]
diff --git a/glances/plugins/percpu/__init__.py b/glances/plugins/percpu/__init__.py
index 285ca440..2c6aa79d 100644
--- a/glances/plugins/percpu/__init__.py
+++ b/glances/plugins/percpu/__init__.py
@@ -9,6 +9,7 @@
"""Per-CPU plugin."""
from glances.cpu_percent import cpu_percent
+from glances.globals import BSD, LINUX, MACOS, WINDOWS
from glances.plugins.plugin.model import GlancesPluginModel
# Fields description
@@ -76,6 +77,14 @@ guest operating systems under the control of the Linux kernel.',
'description': '*(Linux)*: percent of time spent handling software interrupts.',
'unit': 'percent',
},
+ 'dpc': {
+ 'description': '*(Windows)*: percent of time spent handling deferred procedure calls.',
+ 'unit': 'percent',
+ },
+ 'interrupt': {
+ 'description': '*(Windows)*: percent of time spent handling software interrupts.',
+ 'unit': 'percent',
+ },
}
# Define the history items list
@@ -140,11 +149,17 @@ class PluginModel(GlancesPluginModel):
if not self.stats or not self.args.percpu or self.is_disabled():
return ret
- # Define the default header
- all_headers = ['user', 'system', 'idle', 'iowait', 'steal']
-
- # Determine applicable headers
- header = [h for h in all_headers if self.stats[0].get(h) is not None]
+ # Define the headers based on OS
+ header = ['user', 'system']
+
+ if LINUX:
+ header.extend(['iowait', 'idle', 'irq', 'nice', 'steal', 'guest'])
+ elif MACOS:
+ header.extend(['idle', 'nice'])
+ elif BSD:
+ header.extend(['idle', 'irq', 'nice'])
+ elif WINDOWS:
+ header.extend(['dpc', 'interrupt'])
# Build the string message
if self.is_disabled('quicklook'):