Closed wwuck closed 3 months ago
I can confirm that the following changes to the method appear to fix this issue:
diff --git a/check-plugins/disk-io/disk-io b/check-plugins/disk-io/disk-io
index a6f2ed9a..02872ca4 100755
--- a/check-plugins/disk-io/disk-io
+++ b/check-plugins/disk-io/disk-io
@@ -153,6 +153,7 @@ def top(count):
"""Get top X processes that generated the most I/O traffic.
"""
cnt = {}
+ msg = ''
try:
for p in [x.as_dict(attrs=['name', 'io_counters']) for x in psutil.process_iter()]:
if p['io_counters']:
@@ -166,7 +167,7 @@ def top(count):
# ('WebKitNetworkProcess', {'r': 1716224, 'w': 0}),
# ('ibus-x11', {'r': 0, 'w': 0}), ...
if not cnt:
- return ''
+ return msg
cnt = sorted(cnt.items(), key=lambda x: x[1]['r']+x[1]['w'], reverse=True)
if cnt[0][1]['r'] + cnt[0][1]['w'] > 0: # don't print "1. any-proc: 0.0B/0.0B (r/w)"
msg = '\nTop {} processes that generate the most I/O traffic (r/w):\n'.format(count)
Perfect, thank you!
This issue respects the following points:
Which variant of the Monitoring Plugins do you use?
Bug description
I'm trying to run
disk-io
check on lots of VMs and on some VMs it is reporting a traceback error.I set a pdb trace on the line above https://github.com/Linuxfabrik/monitoring-plugins/blob/main/check-plugins/disk-io/disk-io#L182 and get the following results:
Steps to reproduce - Plugin call
/usr/lib64/nagios/plugins/disk-io
Steps to reproduce - Data
No response
Environment
uname -a
Linux gitlab-runner-01 6.1.0-23-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.99-1 (2024-07-15) x86_64 GNU/Linux
cat /etc/os-release
PRETTY_NAME="Devuan GNU/Linux 5 (daedalus)" NAME="Devuan GNU/Linux" VERSION_ID="5" VERSION="5 (daedalus)" VERSION_CODENAME="daedalus" ID=devuan ID_LIKE=debian HOME_URL="https://www.devuan.org/" SUPPORT_URL="https://devuan.org/os/community" BUG_REPORT_URL="https://bugs.devuan.org/"
cat /etc/debian_version
12.0
apt-cache policy linuxfabrik-monitoring-plugins
linuxfabrik-monitoring-plugins: Installed: 2024060401-1 Candidate: 2024060401-1 Version table: *** 2024060401-1 500 500 https://repo.linuxfabrik.ch/monitoring-plugins/debian bookworm-release/main amd64 Packages 100 /var/lib/dpkg/status 2023112901-1 500 500 https://repo.linuxfabrik.ch/monitoring-plugins/debian bookworm-release/main amd64 Packages 2023051201-1 500 500 https://repo.linuxfabrik.ch/monitoring-plugins/debian bookworm-release/main amd64 Packages
Plugin Version
disk-io: v2024071701 by Linuxfabrik GmbH, Zurich/Switzerland
Python version
No response
List of Python modules
No response
Additional Information
No response