You are here:
ActiveXperts.com > Support > ActiveXperts Network Monitor > Online > Linux > Memory Usage
Quicklinks
The following script can be used in ActiveXperts Network Monitor to check memory usage on a remote LINUX machine:
#################################################################################
# ActiveXperts Network Monitor - shell script checks
# © 1999-2008, ActiveXperts Software B.V.
#
# For more information about ActiveXperts Network Monitor and SSH, please
# visit the online ActiveXperts Network Monitor Shell Script Guidelines at:
# http://www.activexperts.com/support/network-monitor/online/linux/
#################################################################################
#!/bin/sh
# Macro definitiions
FREE=`free -m | awk '/^Mem:/ { printf( "%s\n", $4 ); }'`
USED=`free -m | awk '/^Mem:/ { printf( "%s\n", $3 ); }'`
# Validate number of arguments
if [ $# -ne 2 ] ; then
echo "UNCERTAIN: Invalid number of arguments - Usage: memory ";
exit 1;
fi
# Validate arguments
if [ $1 != "free" ] && [ $1 != "used" ]; then
echo "ERROR: Invalid parameter: $1 DATA:0";
fi
# Check free memory
if [ $1 == "free" ] ; then
if [ $FREE -ge $2 ] ; then
echo "SUCCESS: Free memory is [$FREE MB], minimum required=[$2 MB] DATA:$FREE";
else
echo "ERROR: Free memory is [$FREE MB], minimum required=[$2 MB] DATA:$FREE";
fi
fi
# Check used memory
if [ $1 == "used" ] ; then
if [ $USED -le $2 ] ; then
echo "SUCCESS: Used memory is [$USED MB], maximum allowed=[$2 MB] DATA:$USED";
else
echo "ERROR: Used memory is [$USED MB], maximum allowed=[$2 MB] DATA:$USED";
fi
fi