Skip to content

Commit

Permalink
cpu-usage: On Windows, exclude "System Idle Process" from the Top3 list
Browse files Browse the repository at this point in the history
  • Loading branch information
markuslf committed Sep 21, 2023
1 parent 3fbfbff commit 95062d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Monitoring Plugins:

* All plugins: Consistently reporting errors using cu() instead of oao()
* about-me: Show systemd timers with next runtime
* cpu-usage: On Windows, exclude "System Idle Process" from the Top3 list
* disk-smart: Skip unsupported disks (fix #672)
* fail2ban: Improve output, add unit-test
* grafana-version: Add Grafana v9.5
Expand Down
8 changes: 7 additions & 1 deletion check-plugins/cpu-usage/cpu-usage
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ except ImportError:


__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
__version__ = '2023071301'
__version__ = '2023092101'

DESCRIPTION = """Mainly provides utilization percentages for each specific CPU time. Takes a time
period into account: the cpu usage within a certain amount of time has to be equal
Expand Down Expand Up @@ -217,12 +217,18 @@ def main():
if lib.version.version(psutil.__version__) >= lib.version.version('5.3.0'):
try:
for p in psutil.process_iter(attrs=['name', 'cpu_times']):
if lib.base.WINDOWS and p.info['name'] == 'System Idle Process':
# yes, the System Idle Process on Windows consumes CPU time
continue
cnt[p.info['name']] += sum(p.info['cpu_times'][:2])
except psutil.NoSuchProcess:
pass
else:
try:
for p in [x.as_dict(attrs=['name', 'cpu_times']) for x in psutil.process_iter()]:
if lib.base.WINDOWS and p['name'] == 'System Idle Process':
# yes, the System Idle Process on Windows consumes CPU time
continue
cnt[p['name']] += sum(p['cpu_times'][:2])
except psutil.NoSuchProcess:
pass
Expand Down

0 comments on commit 95062d3

Please sign in to comment.