Search Suggest

Monitor RAM utilization on Server using Shell Script

This tutorial will help you to find out RAM utilization on linux server using shell scripting. you can deploy this script on your  production server and set the maximum utilization limit so that when RAM utilization will be high you will get alert using this script.

Create a script file named as memoryalert.sh and make it executable 

#vim memoryalert.sh

#/bin/bash
Host=`hostname -d`
Memuse=`free -m | awk '{print $3}'| head -n 2 | tail -n 1`
Subject="Current RAM Use: $Memuse MB"
Mail="salam843@gmail.com"
Current_use="1200"
if (( Memuse > Current_use ))
then
echo "At $Host MailServer RAM utilization is very Hight. Kindly check. " | mail -s "$Subject" "$Mail"
else
echo "Normal utilization"
fi

#===========================

Command to make script file executable

# chmod o+x  memoryalert.sh

Now set this script in cron and run the script in every 1 or 2 minute with cron parameter

#crontab -e

2 * * * * /bin/sh /root/.disk.sh

Đăng nhận xét