Skip to content

Commit 6af2340

Browse files
committed
chg: plugin(percpu) - show times based on host OS
1 parent 46abd4b commit 6af2340

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

glances/cpu_percent.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class PerCpuPercentInfo(TypedDict):
3838
steal: Optional[float]
3939
guest: Optional[float]
4040
guest_nice: Optional[float]
41+
dpc: Optional[float]
42+
interrupt: Optional[float]
4143

4244

4345
class CpuPercent:
@@ -146,6 +148,8 @@ def _compute_percpu(self) -> List[PerCpuPercentInfo]:
146148
'steal': cpu_times.steal if hasattr(cpu_times, 'steal') else None,
147149
'guest': cpu_times.guest if hasattr(cpu_times, 'guest') else None,
148150
'guest_nice': cpu_times.steal if hasattr(cpu_times, 'guest_nice') else None,
151+
'dpc': cpu_times.dpc if hasattr(cpu_times, 'dpc') else None,
152+
'interrupt': cpu_times.interrupt if hasattr(cpu_times, 'interrupt') else None,
149153
}
150154
for cpu_number, cpu_times in psutil_percpu
151155
]

glances/plugins/percpu/__init__.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"""Per-CPU plugin."""
1010

1111
from glances.cpu_percent import cpu_percent
12+
from glances.globals import BSD, LINUX, MACOS, WINDOWS
1213
from glances.plugins.plugin.model import GlancesPluginModel
1314

1415
# Fields description
@@ -76,6 +77,14 @@
7677
'description': '*(Linux)*: percent of time spent handling software interrupts.',
7778
'unit': 'percent',
7879
},
80+
'dpc': {
81+
'description': '*(Windows)*: percent of time spent handling deferred procedure calls.',
82+
'unit': 'percent',
83+
},
84+
'interrupt': {
85+
'description': '*(Windows)*: percent of time spent handling software interrupts.',
86+
'unit': 'percent',
87+
},
7988
}
8089

8190
# Define the history items list
@@ -140,11 +149,17 @@ def msg_curse(self, args=None, max_width=None):
140149
if not self.stats or not self.args.percpu or self.is_disabled():
141150
return ret
142151

143-
# Define the default header
144-
all_headers = ['user', 'system', 'idle', 'iowait', 'steal']
145-
146-
# Determine applicable headers
147-
header = [h for h in all_headers if self.stats[0].get(h) is not None]
152+
# Define the headers based on OS
153+
header = ['user', 'system']
154+
155+
if LINUX:
156+
header.extend(['iowait', 'idle', 'irq', 'nice', 'steal', 'guest'])
157+
elif MACOS:
158+
header.extend(['idle', 'nice'])
159+
elif BSD:
160+
header.extend(['idle', 'irq', 'nice'])
161+
elif WINDOWS:
162+
header.extend(['dpc', 'interrupt'])
148163

149164
# Build the string message
150165
if self.is_disabled('quicklook'):

0 commit comments

Comments
 (0)