Module: check_mk
Branch: master
Commit: 3184460a0216e9017649a538f6fdbc8021d4cf78
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3184460a0216e9…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Apr 21 16:57:50 2016 +0200
3389 FIX ps: Fixed stripped command lines for process checking on solaris systems
---
.werks/3389 | 10 ++++++++++
ChangeLog | 1 +
agents/check_mk_agent.solaris | 23 +++++++++++++++++++++--
3 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/.werks/3389 b/.werks/3389
new file mode 100644
index 0000000..26f9987
--- /dev/null
+++ b/.werks/3389
@@ -0,0 +1,10 @@
+Title: ps: Fixed stripped command lines for process checking on solaris systems
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1461250626
+
+
diff --git a/ChangeLog b/ChangeLog
index 29b051d..ebb8499 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -167,6 +167,7 @@
* 3387 FIX: ps: Fixed crash during service discovery on AIX hosts having defunct
processes
* 3417 FIX: wmi_cpuload: fix exception in case of missing NumberOfLogicalProcessors
on some OS versions
* 3124 FIX: workaround for overrunnig counters in a couple of wmi checks...
+ * 3389 FIX: ps: Fixed stripped command lines for process checking on solaris systems
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/agents/check_mk_agent.solaris b/agents/check_mk_agent.solaris
index da5b85c..d251723 100755
--- a/agents/check_mk_agent.solaris
+++ b/agents/check_mk_agent.solaris
@@ -189,8 +189,27 @@ fi
# Processes
echo '<<<ps>>>'
-ps -o user,vsz,rss,pcpu,args $pszone | \
-sed -e 1d -e 's/ *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) */(\1,\2,\3,\4) /'
+# The default solaris ps command strips the command lines of the processes. But for good
process
+# matching on the server we really need to whole command line. On linux there are
arguments to
+# make ps output the whole command line, but on solaris this seems to be missing. We use
the ucb
+# ps command to get the full command line instead. What a hack.
+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) /')
+while read -r LINE; do
+ STATS=${LINE%) *}
+ PID=${STATS##*,}
+
+ CMD=$(echo "$UCB_PS" | grep "\s*$PID " | head -n1 | \
+ awk '{ s = ""; for (i = 5; i <= NF; i++) s = s $i "
"; print s }')
+ # Only use the ucb ps line when it's not empty (process might already been gone)
and the
+ # ps line is long enough the be potentially stripped.
+ if [ -z "$CMD" ] || [ ${#LINE} -lt 100 ]; then
+ echo "$LINE"
+ else
+ echo "${STATS}) ${CMD}"
+ fi
+done <<< "$PS"
# Statgrab