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

Share on Google Plus

About Penguin Technology

I am a passionate cloud and DevOps professional specializing in Linux and open-source solutions. Through this blog, I share my knowledge and experience with the community, offering tips and insights on cloud technologies and DevOps practices.
    Blogger Comment

1 comments:

  1. I gathered as much knowledge regarding to the Linux, web sever and database server from your site.Keep on updating with more interesting topic.
    Moreover to recover the lost file from Linux Click on:
    android data recovery review
    launch android data recovery
    backup and restore android apps and data
    android backup app data
    recover lost files
    diskdigger pro file recovery


    ReplyDelete