Module: check_mk
Branch: master
Commit: c692ef970dc319ed22d52b19b6cb98c8d05a89a2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c692ef970dc319…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jan 27 09:54:24 2017 +0100
4313 FIX ps: Improved performance of ps check on systems with a large number of processes
Change-Id: Ibc118fd46156bf9d33b6873f5f49feb7ea579489
---
.werks/4313 | 9 +++++++++
ChangeLog | 1 +
checks/ps | 4 ++--
checks/ps.include | 6 +++++-
4 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/.werks/4313 b/.werks/4313
new file mode 100644
index 0000000..d9b32b2
--- /dev/null
+++ b/.werks/4313
@@ -0,0 +1,9 @@
+Title: ps: Improved performance of ps check on systems with a large number of processes
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i4
+Date: 1485507240
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 74bf3eb..7daf617 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -74,6 +74,7 @@
* 4214 FIX: jolokia_metrics.tp: Fix crash in case of partial thread information...
* 4304 FIX: mk_inventory.linux: fixed missing redirection to null device in if
statement
* 4305 FIX: postgres_stat_database.size: fixed missing database size perfometer
+ * 4313 FIX: ps: Improved performance of ps check on systems with a large number of
processes
Multisite:
* 4169 View action: Default values of sticky, notification and persistent options can
now be configured via global settings....
diff --git a/checks/ps b/checks/ps
index 394b106..0fa7087 100644
--- a/checks/ps
+++ b/checks/ps
@@ -117,11 +117,11 @@ def ps_get_counters_to_delete(pids):
def ps_get_current_pids(parsed):
- pids = []
+ pids = set()
for line in parsed:
process_info = line[1]
if ps_has_extended_perfdata(process_info):
- pids.append(process_info[4])
+ pids.add(process_info[4])
return pids
diff --git a/checks/ps.include b/checks/ps.include
index 4112294..13d35d3 100644
--- a/checks/ps.include
+++ b/checks/ps.include
@@ -327,7 +327,11 @@ def ps_cleanup_params(params):
def ps_has_extended_perfdata(process_info):
- return len(process_info) > 4
+ try:
+ process_info[4]
+ return True
+ except IndexError:
+ return False
def check_ps_common(item, params, parsed, cpu_cores = 1, info_name =
"processes", total_ram = None):