Relative MEM free script:

If you have information, script, utility, or idea that can be useful for HostMonitor community, you welcome to share information in this forum.
Post Reply
mos-eisley
Posts: 76
Joined: Wed Mar 21, 2007 5:51 am
Location: Klarup (AAlborg), Demark

Relative MEM free script:

Post by mos-eisley »

We have made an alternative script (for Linux), showing how much memory are free ( in %):

# Test for the 2 arguments
if [ ! $# -eq 2 ]
then
echo "ScriptRes:Unknown:Missing Parameter(s)"
exit
fi

CRITICAL=$1
WARNING=$2

USED=`free -lm | awk 'NR < 3 && NR > 1 {printf("%.0f", (($7 '+' $4) '/' $2) '*' 100)}'`
FREE=`echo $USED | awk '{print (100 '-' $1)}'`

if [ $USED -gt $CRITICAL ]
then
echo "ScriptRes:Bad:$FREE% Free "
exit
else
if [ $USED -gt $WARNING ]
then
echo "ScriptRes:Warning:$FREE% Free"
exit
else
echo "ScriptRes:Ok:$FREE% Free"
fi
fi
Post Reply