Module: check_mk
Branch: master
Commit: c1e00bd6c81cb7101bf74ec7baa1e7e34e87974d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c1e00bd6c81cb7…
Author: Óscar Nájera <on(a)mathias-kettner.de>
Date: Mon Oct 22 12:53:21 2018 +0200
6645 FIX Solaris Agent: Correctly separate cputime and elapsed time
The process information delivered by the agent has been upgrated multiple
times by requirements of users or information available from the OS. The ps
agent tracked the memory outilization of a process by its name, but could
not access information of process id and the time of life(elapsed time) of
a running process, as such information was misplaced by the agent and thus
ignored by the check. This fix brings this data into consideration by the
check.
Change-Id: Ia6f2df3ee5c074c258ed9a301716c923a3a11451
---
.werks/6645 | 11 +++++++++++
agents/check_mk_agent.solaris | 2 +-
checks/ps.include | 27 ++++++++++++++++-----------
3 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/.werks/6645 b/.werks/6645
new file mode 100644
index 0000000..b85a4a1
--- /dev/null
+++ b/.werks/6645
@@ -0,0 +1,11 @@
+Title: Solaris Agent: Correctly separate cputime and elapsed time in agent info
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1540280877
+Class: fix
+
+The process information delivered by the agent has been upgrated multiple times by
requirements of users or information available from the OS. The ps agent tracked the
memory outilization of a process by its name, but could not access information of process
id and the time of life(elapsed time) of a running process, as such information was
misplaced by the agent and thus ignored by the check. This fix brings this data into
consideration by the check.
+
diff --git a/agents/check_mk_agent.solaris b/agents/check_mk_agent.solaris
index 5810ee2..fbab57b 100755
--- a/agents/check_mk_agent.solaris
+++ b/agents/check_mk_agent.solaris
@@ -228,7 +228,7 @@ echo '<<<ps>>>'
if [ -x /usr/ucb/ps ]; then
UCB_PS=$(/usr/ucb/ps -agwwwx)
PS=$(ps -o user,vsz,rss,pcpu,etime,pid,args $pszone | \
- sed -e 1d -e 's/ *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\)
*\([^ ]*\) */(\1,\2,\3,\4,\5,\6) /')
+ sed -e 1d -e 's/ *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\)
*\([^ ]*\) */(\1,\2,\3,\4\/\5,\6) /')
while read -r LINE; do
STATS=${LINE%) *}
PID=${STATS##*,}
diff --git a/checks/ps.include b/checks/ps.include
index 9ca4c99..c3a11a0 100644
--- a/checks/ps.include
+++ b/checks/ps.include
@@ -418,18 +418,21 @@ def check_ps_common(item, params, parsed, cpu_cores = 1, info_name =
"processes"
else:
# process_info[3] contains the used CPU time and possibly,
separated by /, also
# the total elapsed time since the birth of the process.
- if ":" in process_info[3]:
- if '/' in process_info[3]:
- pcpu_text, elapsed_text =
process_info[3].split('/')
- elapsed = parse_ps_time(elapsed_text)
- max_elapsed = max(max_elapsed, elapsed)
- if min_elapsed is None:
- min_elapsed = elapsed
- else:
- min_elapsed = min(min_elapsed, elapsed)
+ if '/' in process_info[3]:
+ pcpu_text, elapsed_text = process_info[3].split('/')
+ else:
+ pcpu_text = process_info[3]
+ elapsed_text = None
+
+ if elapsed_text:
+ elapsed = parse_ps_time(elapsed_text)
+ max_elapsed = max(max_elapsed, elapsed)
+ if min_elapsed is None:
+ min_elapsed = elapsed
else:
- pcpu_text = process_info[3]
+ min_elapsed = min(min_elapsed, elapsed)
+ if ":" in pcpu_text:
total_seconds = parse_ps_time(pcpu_text)
pid = process_info[4]
try:
@@ -440,10 +443,12 @@ def check_ps_common(item, params, parsed, cpu_cores = 1, info_name =
"processes"
pcpu = cputime * 100
process.append(("pid", (pid, "")))
else:
- pcpu = savefloat(process_info[3])
+ pcpu = float(pcpu_text)
+
percent_cpu += pcpu
process.append(("cpu usage", (pcpu, "%")))
+
elif command_line:
# otherwise we have only two fields, one of which is the node. if the
remaining
# field is not the process name, that ps makes no sense at all