Module: check_mk
Branch: master
Commit: 3c32f096ff6b806fec536dec94d5a3c978af85ce
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3c32f096ff6b80…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed May 11 08:28:42 2016 +0200
3573 FIX ps: Fixed possible wrong matching of ps and ucb ps commands
---
.werks/3573 | 10 ++++++++++
ChangeLog | 1 +
agents/check_mk_agent.solaris | 39 ++++++++++++++++++++++-----------------
3 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/.werks/3573 b/.werks/3573
new file mode 100644
index 0000000..f8beadb
--- /dev/null
+++ b/.werks/3573
@@ -0,0 +1,10 @@
+Title: ps: Fixed possible wrong matching of ps and ucb ps commands
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1462948016
+
+
diff --git a/ChangeLog b/ChangeLog
index d7a6e93..59f4122 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -210,6 +210,7 @@
* 3565 FIX: wmi checks: Fixed deprecation warning when WMI keys can not be found in
agent output
* 3528 FIX: netapp_api_protocol: fixed service discovery problem with older 7mode
versions
* 3529 FIX: agent_netapp: fixed problem with older netapp versions (7Mode - Version
8.0)...
+ * 3573 FIX: ps: Fixed possible wrong matching of ps and ucb ps commands
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 d251723..721b611 100755
--- a/agents/check_mk_agent.solaris
+++ b/agents/check_mk_agent.solaris
@@ -193,23 +193,28 @@ echo '<<<ps>>>'
# 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"
+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) /')
+ 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"
+else
+ ps -o user,vsz,rss,pcpu,args $pszone | \
+ sed -e 1d -e 's/ *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) */(\1,\2,\3,\4)
/'
+fi
# Statgrab