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 @@ ...@@ -12,6 +12,7 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# 2020-03-02 v1.0 initial version # 2020-03-02 v1.0 initial version
# 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions # 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 # --- tmp files for internal usage
...@@ -30,19 +31,19 @@ typeset -i iCountCritical=0 ...@@ -30,19 +31,19 @@ typeset -i iCountCritical=0
rm -f $tmpfile $tmpfile2 $outCritical $outWarning 2>/dev/null rm -f $tmpfile $tmpfile2 $outCritical $outWarning 2>/dev/null
. `dirname $0`/inc_pluginfunctions . $(dirname $0)/inc_pluginfunctions
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# MAIN # MAIN
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# set default / override from command line params # set default / override from command line params
typeset -i iWarnLimit=` ph.getValueWithParam 100 w "$@"` typeset -i iWarnLimit=$( ph.getValueWithParam 100 w "$@")
typeset -i iCriticalLimit=` ph.getValueWithParam 500 c "$@"` typeset -i iCriticalLimit=$( ph.getValueWithParam 500 c "$@")
# --- read processlist and create helper table # --- read processlist and create helper table
ps -yle >$tmpfile 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 do
#echo -n "$processname; ">>$tmpfile2 #echo -n "$processname; ">>$tmpfile2
ps -ylC $processname | awk ' ps -ylC $processname | awk '
...@@ -54,10 +55,10 @@ done ...@@ -54,10 +55,10 @@ done
# --- check limits # --- check limits
while read line while read line
do 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 if [ $iSizeMB -ge $iWarnLimit ]; then
processname=`echo $line | awk '{ print $1 }'` processname=$(echo $line | awk '{ print $1 }')
processcount=`echo $line | awk '{ print $3 }'` processcount=$(echo $line | awk '{ print $3 }')
if [ $iSizeMB -ge $iCriticalLimit ]; then if [ $iSizeMB -ge $iCriticalLimit ]; then
iCountCritical=$iCountCritical+1 iCountCritical=$iCountCritical+1
echo "Critical: $iSizeMB MB - $processname ($processcount)" >>$outCritical 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