08-25-2020, 06:52 AM
At times, we need to monitor the high CPU usage in the system. We can use the below script to monitor the high CPU usage.
#!/bin/bash
while [ true ] ;do
used=`free -m |awk 'NR==3 {print $4}'`
if [ $used -lt 1000 ] && [ $used -gt 800 ]; then
echo "Free memory is below 1000MB. Possible memory leak!!!" | /bin/mail -s "HIGH MEMORY ALERT!!!" user@mydomain.com
fi
sleep 5
done
#!/bin/bash
while [ true ] ;do
used=`free -m |awk 'NR==3 {print $4}'`
if [ $used -lt 1000 ] && [ $used -gt 800 ]; then
echo "Free memory is below 1000MB. Possible memory leak!!!" | /bin/mail -s "HIGH MEMORY ALERT!!!" user@mydomain.com
fi
sleep 5
done