Hackonology Forums
High CPU Usage Script - Printable Version

+- Hackonology Forums (https://hackonology.com/forum)
+-- Forum: Technology & Configuration (https://hackonology.com/forum/forumdisplay.php?fid=3)
+--- Forum: Configuration Scripts (https://hackonology.com/forum/forumdisplay.php?fid=6)
+--- Thread: High CPU Usage Script (/showthread.php?tid=20)



High CPU Usage Script - SysAdmin - 08-25-2020

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