Module: check_mk
Branch: master
Commit: 4d117f66ee69de0b21655eb40185f5414f7e881d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4d117f66ee69de…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jul 27 23:00:56 2018 +0200
6376 FIX Analyze configuration: Fixed "Apache number of processes" on SLES
An exception could occur for the test "Apache number of processes" on at
least SLES12:
CRIT:
Failed to execute the test ACTestApacheNumberOfProcesses: Traceback (most recent call
last):
File "/omd/sites/TESTSITE/share/check_mk/web/htdocs/watolib.py", line 9591, in
run
total_result = ACResult.merge(*list(self.execute()))
File "/omd/sites/TESTSITE/share/check_mk/web/plugins/wato/ac_tests.py", line
388, in execute
average_process_size = self._get_average_process_size()
File "/omd/sites/TESTSITE/share/check_mk/web/plugins/wato/ac_tests.py", line
408, in _get_average_process_size
sizes.append(int(summary_line.split()[3][:-1])*1024.0)
ValueError: invalid literal for int() with base 10: 'readonly-private'
Change-Id: I8ab0e3a43985bcd8d803a4bd2909eb2166aee50a
---
.werks/6376 | 22 ++++++++++++++++++++++
cmk/gui/plugins/wato/ac_tests.py | 26 ++++++++++++++++++++++++--
2 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/.werks/6376 b/.werks/6376
new file mode 100644
index 0000000..d91d799
--- /dev/null
+++ b/.werks/6376
@@ -0,0 +1,22 @@
+Title: Analyze configuration: Fixed "Apache number of processes" on SLES
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1532725076
+
+An exception could occur for the test "Apache number of processes" on at
+least SLES12:
+
+CRIT:
+Failed to execute the test ACTestApacheNumberOfProcesses: Traceback (most recent call
last):
+File "/omd/sites/TESTSITE/share/check_mk/web/htdocs/watolib.py", line 9591, in
run
+total_result = ACResult.merge(*list(self.execute()))
+File "/omd/sites/TESTSITE/share/check_mk/web/plugins/wato/ac_tests.py", line
388, in execute
+average_process_size = self._get_average_process_size()
+File "/omd/sites/TESTSITE/share/check_mk/web/plugins/wato/ac_tests.py", line
408, in _get_average_process_size
+sizes.append(int(summary_line.split()[3][:-1])*1024.0)
+ValueError: invalid literal for int() with base 10: 'readonly-private'
diff --git a/cmk/gui/plugins/wato/ac_tests.py b/cmk/gui/plugins/wato/ac_tests.py
index d50cc70..1e4c544 100644
--- a/cmk/gui/plugins/wato/ac_tests.py
+++ b/cmk/gui/plugins/wato/ac_tests.py
@@ -501,8 +501,7 @@ class ACTestApacheNumberOfProcesses(ACTest, BPApacheTest):
sizes = []
for pid in subprocess.check_output(["ps", "--ppid",
"%d" % ppid, "h", "o", "pid"]).splitlines():
- summary_line = subprocess.check_output(["pmap", "-d",
"%d" % int(pid)]).splitlines()[-1]
- sizes.append(int(summary_line.split()[3][:-1])*1024.0)
+ sizes.append(self._get_process_size(pid))
if not sizes:
raise MKGeneralException(_("Failed to estimate the apache process
size"))
@@ -510,6 +509,29 @@ class ACTestApacheNumberOfProcesses(ACTest, BPApacheTest):
return sum(sizes) / float(len(sizes))
+ def _get_process_size(self, pid):
+ # Summary line seems to be different on the supported distros
+ # Ubuntu 17.10 (pmap from procps-ng 3.3.12):
+ # mapped: 25036K writeable/private: 2704K shared: 28K
+ # SLES12
+ # 4020K writable-private, 102960K readonly-private, 1856K shared, and 636K
referenced
+ # SLES12SP3 (pmap using library of procps-ng 3.3.9)
+ # 2784K writable-private, 21052K readonly-private, and 28K shared
+ # CentOS 5.5 (pmap procps version 3.2.7)
+ # mapped: 66176K writeable/private: 548K shared: 28K
+ # CentOS 7 (pmap from procps-ng 3.3.10)
+ # mapped: 115524K writeable/private: 684K shared: 28K
+ summary_line = subprocess.check_output(["pmap", "-d",
"%d" % int(pid)]).splitlines()[-1]
+
+ parts = summary_line.split()
+ if parts[1] == "writable-private,":
+ writable_private = parts[0]
+ else:
+ writable_private = parts[3]
+
+ return int(writable_private[:-1]) * 1024.0
+
+
class ACTestApacheProcessUsage(ACTest, BPApacheTest):
def category(self):