Skip to content
Snippets Groups Projects
Commit dab2cee1 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

replace pipe to prevent start of metrics section

parent 67972e3d
No related branches found
No related tags found
1 merge request!32replace pipe to prevent start of metrics section
...@@ -19,13 +19,14 @@ ...@@ -19,13 +19,14 @@
# 2022-03-10 v1.8 <axel.hahn@iml.unibe.ch> add cli param -p; update help # 2022-03-10 v1.8 <axel.hahn@iml.unibe.ch> add cli param -p; update help
# 2022-03-22 v1.9 <axel.hahn@iml.unibe.ch> fix syntax error on 100% idle # 2022-03-22 v1.9 <axel.hahn@iml.unibe.ch> fix syntax error on 100% idle
# 2022-04-14 v1.10 <axel.hahn@iml.unibe.ch> show consuming cpu processes with top and ps # 2022-04-14 v1.10 <axel.hahn@iml.unibe.ch> show consuming cpu processes with top and ps
# 2022-08-29 v1.11 <axel.hahn@iml.unibe.ch> replace pipe to prevent start of metrics section
# ====================================================================== # ======================================================================
. $(dirname $0)/inc_pluginfunctions . $(dirname $0)/inc_pluginfunctions
self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] )
self_APPVERSION=1.9 self_APPVERSION=1.11
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# functions # functions
...@@ -45,6 +46,9 @@ ______________________________________________________________________ ...@@ -45,6 +46,9 @@ ______________________________________________________________________
check cpu usage and cpu wait check cpu usage and cpu wait
Cpu infos are taken from output of top command. Cpu infos are taken from output of top command.
Oh higher cpu usage it can show processes that cause cpu waits and
with most cpu consumption.
SYNTAX: SYNTAX:
$(basename $0) [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-i CRITICAL_IO_WAIT] [-p PROCESS_LIMIT] $(basename $0) [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-i CRITICAL_IO_WAIT] [-p PROCESS_LIMIT]
...@@ -147,7 +151,9 @@ ph.status "CPU-USAGE [%] ${cpuNonIdle} ... user: ${cpuUser} - system: ${cpuSyste ...@@ -147,7 +151,9 @@ ph.status "CPU-USAGE [%] ${cpuNonIdle} ... user: ${cpuUser} - system: ${cpuSyste
# v1.6: show processes of cpu wait (status D in proces list) # v1.6: show processes of cpu wait (status D in proces list)
plist=$( ps aux | awk '$8 ~ /(D|STAT)/ { print $0 }' ) plist=$( ps aux | awk '$8 ~ /(D|STAT)/ { print $0 }' )
echo "$plist" | grep "[0-9]" >/dev/null \
# replace pipe to prevent start of metrics section
echo "$plist" | tr '|' ':' | grep "[0-9]" >/dev/null \
&& echo \ && echo \
&& echo "For analysis of cpu waits - processes with status D:" \ && echo "For analysis of cpu waits - processes with status D:" \
&& echo "$plist" && echo "$plist"
...@@ -161,7 +167,7 @@ if [ $iUsed -gt $iMinCpuUsageToShowProcesses ]; then ...@@ -161,7 +167,7 @@ if [ $iUsed -gt $iMinCpuUsageToShowProcesses ]; then
topout=$( top -b -n 1 -d 0.1 ) topout=$( top -b -n 1 -d 0.1 )
typeset -i iStart=$( echo "$topout" | grep -n "PID.*USER" | cut -f 1 -d ':' ) typeset -i iStart=$( echo "$topout" | grep -n "PID.*USER" | cut -f 1 -d ':' )
typeset -i iEnd=$iStart+5 typeset -i iEnd=$iStart+5
echo "$topout" | sed -n "${iStart},${iEnd}p" echo "$topout" | sed -n "${iStart},${iEnd}p" | tr '|' ':'
echo echo
echo "output of ps:" echo "output of ps:"
ps aux | head -1; ps aux | sort -nrk 3,3 | head -n 5 ps aux | head -1; ps aux | sort -nrk 3,3 | head -n 5
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment