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

check_proc_mem shell fixes

parent 9f77025f
Branches
No related tags found
1 merge request!55Add check requirement
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment