A Shell Script to Monitor Network, Disk Usage, Uptime, Load Average and RAM Usage in Linux

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Use our Linode referral link if you plan to buy VPS (it starts at only $10/month).
  4. Support us via PayPal donate - Make a Donation
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux course in 5 Days

We are thankful for your never ending support.

Receive Your Free Complimentary eBook NOW! -

Download Free Linux eBooks

Advanced Bash-Scripting Guide
Linux Bible
A Newbie's Getting Started Guide to Linux
Introduction to Linux - A Hands on Guide

You may also like...

114 Responses

  1. Ram says:

    hi I just edited the script for my ubuntu

    here it is

    #OS release
    echo “##########################”
    echo -e “\e[1;32mWELCOME TO SPIDY Ver 1.0.2\e[0m”
    echo “##########################”
    echo “”
    echo -e “\e[1;33mHello $cuser\e[0m”
    echo ” ”
    os=$(cat /etc/os-release | grep _NAME | cut -d= -f2)
    echo -e “\e[1;36mOS Release\e[0m: $os”
    #OS type
    type=$(uname -o)
    echo -e “\e[1;36mOS Type\e[0m: $type”
    #OS Version
    ver=$(cat /etc/os-release | grep -w “VERSION” |cut -d= -f2)
    echo -e “\e[1;36mOS Version\e[0m: $ver”
    #OS Architecture
    arc=$(uname -m)
    echo -e “\e[1;36mOS Architecture \e[0m: $arc”
    #Kernel Release
    knl=$(uname -r)
    echo -e “\e[1;36mKernel Release\e[0m: $knl”
    ping -c 1 &> /dev/null && echo -e “\e[1;36mNetwork\e[0m:\e[1;32m UP\e[0m” || echo -e ” \e[1;36mNetwork\e[0m :\e[1;31m Down\e[0m”
    ping -c 1 google.com &> /dev/null && echo -e “\e[1;36mInternet\e[0m:\e[1;32m Connected\e[0m” || echo -e “\e[1;36mInternet\e[0m :\e[1;31m Diconnected\e[0m”
    #Network speed
    rx=$(ifconfig eth0 | grep bytes | grep RX | cut -d ‘:’ -f2 | cut -d ‘ ‘ -f 1)
    tx=$(ifconfig eth0 | grep bytes | grep TX | cut -d ‘:’ -f3 | cut -d ‘ ‘ -f 1)
    rxd=$(echo $(($rx / 1000000))” MB”;)
    txd=$(echo $(($tx / 1000000))” MB”;)
    echo -e “\e[1;36mRecived \e[0m: \e[1;31m $rxd\e[0m”
    echo -e “\e[1;36mSent \e[0m: \e[1;35m $txd\e[0m”
    echo -e “\e[1;36mHostname\e[0m: \e[1;33m$hn\e[0m”
    #Internal IP
    ip=$( ifconfig |grep Bcast |cut -d: -f2 |cut -dB -f1)
    echo -e “\e[1;36mInternal IP\e[0m: \e[1;32m$ip\e[0m”
    #External IP
    eip=$(dig +short myip.opendns.com @resolver1.opendns.com)
    echo -e “\e[1;36mExternal IP\e[0m: \e[1;35m$eip\e[0m”
    dns=$(cat /etc/resolv.conf | sed ‘1 d’ | awk ‘{print $2}’| sed -n 4p)
    echo -e “\e[1;36mDNS Server\e[0m : $dns”
    #Current logged users
    echo -e “\e[1;36mCurrent user\e[0m: $cuser”
    #Logged users
    echo -e “\e[1;36mLoged in users\e[0m ”
    echo “$user”
    #RAM use
    t=$(free -h | grep -v + |grep total)
    echo ” $t ”
    ram=$(free -h | grep -v + |grep Mem)
    echo -e “\e[1;36mRam usage\e[0m : \e[1;31m$ram\e[0m”
    #SWAP use
    swap=$(free -h | grep -v + |grep Swap)
    echo -e “\e[1;36mSwap usage\e[0m : \e[1;34m$swap\e[0m”
    #Disk usage
    disk=$(df -h| grep ‘Filesystem\|/dev/sda*’)
    echo -e “\e[1;36mYour disk usage\e[0m ”
    echo -e “\e[1;33m$disk\e[0m ”
    #Load avaerage
    load=$(cat /proc/loadavg |cut -d. -f1)
    echo -e “\e[1;36mCurrent CPU Load is\e[0m : $load ”
    up=$(uptime | awk ‘{print $3,$4}’ | cut -f1 -d,)
    echo -e “\e[1;36mSystem Uptime\e[0m: \e[1;32m $up\e[0m”

    • Ravi Saive says:


      Thanks for making this script compatible to Ubuntu distribution and also thanks for sharing with us.

  2. Yuriy says:

    in Debian8 3.16.0-4-amd64,
    for load average, I usage {print $11 $12 $13}

  3. Razz says:

    #! /bin/bash
    for i in $(cat ping.txt)
    fping $i >/dev/null
    if [ $? -ne 0 ]
    echo “$i is down”|mailx -s “connectivity test” $email

    This script is working fine but the problem is it is sending the mail individually for each host ,suppose number of unreachable server is more ( in three digit ) .. i don’t think this is best practice to do this

    i want see list of down hosts in one email ,could you help me to modify the script .. i am new in shell scripting please help . Many Thanks

  4. Jeff Huckaby says:

    There is a utility named sysstat that is available on many Linux distributions. Sysstat collects a variety of metrics every few minutes. For RAM, CPU, Disk IO, Network, Swap, etc, systat is very useful. When having issues on servers, sometimes I script sysstat to email me data for key metrics, e.g. swap utilization.

  5. choudhry says:

    very very help full , i want to remove a large no of folders from centos 6 server any script because rm -rf does not work.

  6. Eric Wessel says:

    On Centos/RHEL the command to read /etc/os-release will not work, since these distros do not have those. Might need to have a search for *-release and check for centos or redhat, then parse differently from there, since those also do not put the info on separate lines..

    Example centos-release:
    [root@server bin]# cat /etc/centos-release
    CentOS release 6.7 (Final)

    Example redhat-release
    [root@cas ~]# cat /etc/redhat-release
    Red Hat Enterprise Linux Server release 6.7 (Santiago)

    • Ravi Saive says:


      That’s really a good findings, we really never thought of this, we will modify the script to work on all Red Hat and CentOS distributions..

  7. Preslav Panayotov says:

    ./tecmint_monitor.sh: 26: ./tecmint_monitor.sh: [[: not found
    ./tecmint_monitor.sh: 36: ./tecmint_monitor.sh: [[: not found
    ./tecmint_monitor.sh: 43: ./tecmint_monitor.sh: [[: not found

    • Ravi Saive says:


      On which Linux distribution you’ve tried it? let me know so that we can work around your issue and come up with right solution…

    • Marcos says:

      I got the same error, but it works if you launch it with ‘bash tecmint_monitor.sh’ , instead of ‘sh tecmint_monitor.sh’

      On the other hand, in Ubuntu 12.04.4 (i need to update, i know), there’s a problem with the command free.

      When I launch the script, I get ” free: invalid option — ‘h’ ” If I change the line “free -h” to “free” it works, by of course all in bytes.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

Join Over 150K+ Linux Users
  1. 100,756
  2. 5,113
  3. 36,418

Enter your email to get latest Linux Howto's