diff --git a/check_proc_mem b/check_proc_mem index f553f39aa31b9eae610fc34f313bbeee54b97f7a..91b2bbe26a082ab9e07d87cabb145204523c57ea 100755 --- a/check_proc_mem +++ b/check_proc_mem @@ -12,6 +12,7 @@ # ---------------------------------------------------------------------- # 2020-03-02 v1.0 initial version # 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions +# 2023-02-13 v1.2 <axel.hahn@unibe.ch> some shell fixes # ====================================================================== # --- tmp files for internal usage @@ -30,19 +31,19 @@ typeset -i iCountCritical=0 rm -f $tmpfile $tmpfile2 $outCritical $outWarning 2>/dev/null -. `dirname $0`/inc_pluginfunctions +. $(dirname $0)/inc_pluginfunctions # ---------------------------------------------------------------------- # MAIN # ---------------------------------------------------------------------- # set default / override from command line params -typeset -i iWarnLimit=` ph.getValueWithParam 100 w "$@"` -typeset -i iCriticalLimit=` ph.getValueWithParam 500 c "$@"` +typeset -i iWarnLimit=$( ph.getValueWithParam 100 w "$@") +typeset -i iCriticalLimit=$( ph.getValueWithParam 500 c "$@") # --- read processlist and create helper table ps -yle >$tmpfile -for processname in `cat $tmpfile | awk {'print $13'} | sort -u | fgrep -v "/"` +for processname in $(cat $tmpfile | awk {'print $13'} | sort -u | grep -Fv "/") do #echo -n "$processname; ">>$tmpfile2 ps -ylC $processname | awk ' @@ -54,10 +55,10 @@ done # --- check limits while read line do - typeset -i iSizeMB=`echo $line | awk '{ print $2 }' | sed "s#\..*##"` + typeset -i iSizeMB=$(echo $line | awk '{ print $2 }' | sed "s#\..*##") if [ $iSizeMB -ge $iWarnLimit ]; then - processname=`echo $line | awk '{ print $1 }'` - processcount=`echo $line | awk '{ print $3 }'` + processname=$(echo $line | awk '{ print $1 }') + processcount=$(echo $line | awk '{ print $3 }') if [ $iSizeMB -ge $iCriticalLimit ]; then iCountCritical=$iCountCritical+1 echo "Critical: $iSizeMB MB - $processname ($processcount)" >>$outCritical