#!/bin/bash
total=`free -m |grep Mem | awk '{print $2}'`
muse=`free -m |grep Mem | awk '{print $3}'`
cuse=`free -m |grep cache: | awk '{print $3}'`
warn=$(($muse*100/$total))
if [ $warn -ge 80 ]; then
echo "mem used exceed $warn%"
else
echo "mem ok"
fi
转载于:https://blog.51cto.com/cnmhl/1087481