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. Get your own self-hosted blog with a Free Domain at ($3.95/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

159 Responses

  1. Mansur says:

    I was having some issues while running on centos so i made some edits.

    #! /bin/bash
    # unset any variable which system may be using

    # clear the screen

    unset tecreset os architecture kernelrelease internalip externalip nameserver loadaverage

    while getopts iv name
    case $name in
    *)echo "Invalid arg";;

    if [[ ! -z $iopt ]]
    basename "$(test -L "$0" && readlink "$0" || echo "$0")" > /tmp/scriptname
    scriptname=$(echo -e -n $wd/ && cat /tmp/scriptname)
    su -c "cp $scriptname /usr/bin/monitor" root && echo "Congratulations! Script Installed, now run monitor Command" || echo "Installation failed"

    if [[ ! -z $vopt ]]
    echo -e "tecmint_monitor version 0.1\nDesigned by Tecmint.com\nReleased Under Apache 2.0 License"

    if [[ $# -eq 0 ]]

    # Define Variable tecreset
    tecreset=$(tput sgr0)

    # Check if connected to Internet or not
    ping -c 1 google.com &> /dev/null && echo -e '\E[32m'"Internet: $tecreset Connected" || echo -e '\E[32m'"Internet: $tecreset Disconnected"

    # Check OS Type
    os=$(uname -o)
    echo -e '\E[32m'"Operating System Type :" $tecreset $os

    # Check OS Release Version and Name
    cat /etc/issue |head -n 1 > /tmp/osrelease
    osname=$(cat /tmp/osrelease |awk '{print $1}')
    osrelease=$(cat /tmp/osrelease |awk '{print $3}')
    #cat /etc/os-release | grep 'NAME\|VERSION' | grep -v 'VERSION_ID' | grep -v 'PRETTY_NAME' > /tmp/osrelease
    echo -n -e '\E[32m'"OS Name :" $tecreset ; echo $osname \"
    echo -n -e '\E[32m'"OS Version :" $tecreset ; echo $osrelease \"

    # Check Architecture
    architecture=$(uname -m)
    echo -e '\E[32m'"Architecture :" $tecreset $architecture

    # Check Kernel Release
    kernelrelease=$(uname -r)
    echo -e '\E[32m'"Kernel Release :" $tecreset $kernelrelease

    # Check hostname
    echo -e '\E[32m'"Hostname :" $tecreset $HOSTNAME

    # Check Internal IP
    internalip=$(hostname -i)
    echo -e '\E[32m'"Internal IP :" $tecreset $internalip

    # Check External IP
    externalip=$(curl -s ipecho.net/plain;echo)
    echo -e '\E[32m'"External IP : $tecreset "$externalip

    # Check DNS
    nameservers=$(cat /etc/resolv.conf | sed '1 d' | awk '{print $2}')
    echo -e '\E[32m'"Name Servers :" $tecreset $nameservers

    # Check Logged In Users
    echo -e '\E[32m'"Logged In users :" $tecreset && cat /tmp/who

    # Check RAM and SWAP Usages
    free -m | grep -v "+\|You" > /tmp/ramcache
    echo -e '\E[32m'"Ram Usages :" $tecreset
    cat /tmp/ramcache | grep -v "Swap"
    echo -e '\E[32m'"Swap Usages :" $tecreset
    cat /tmp/ramcache | grep -v "Mem"

    # Check Disk Usages
    df -h| grep 'Filesystem\|da*' |grep -v tmpfs> /tmp/diskusage
    echo -e '\E[32m'"Disk Usages :" $tecreset
    cat /tmp/diskusage

    # Check Load Average
    loadaverage=$(top -n 1 -b | grep "load average:" | awk '{print $10 $11 $12}')
    echo -e '\E[32m'"Load Average :" $tecreset $loadaverage

    # Check System Uptime
    tecuptime=$(uptime | awk '{print $3,$4}' | cut -f1 -d,)
    echo -e '\E[32m'"System Uptime Days/(HH:MM) :" $tecreset $tecuptime

    # Unset Variables
    unset tecreset os architecture kernelrelease internalip externalip nameserver loadaverage

    # Remove Temporary Files
    rm /tmp/osrelease /tmp/who /tmp/ramcache /tmp/diskusage
    shift $(($OPTIND -1))

  2. interminable says:

    elif [ -f /etc/gentoo-release ] ; then
    PSUEDONAME=`cat /etc/gentoo-release | sed s/.*\(// | sed s/\)//`
    REV=`cat /etc/gentoo-release | sed s/.*release\ // | sed s/\ .*//`

    # Check Internal IP
    internalip=$(hostname -i)
    echo -e ‘\E[32m'”Internal IP :” $tecreset $internalip

  3. roger says:

    Hi, very good script
    i change>>

    # Check RAM and SWAP Usages
    free -h | grep -v + > /tmp/ramcache
    i change >>
    free -m | grep -v + > /tmp/ramcache
    df -h| grep ‘Filesystem\|/dev/sda*’ > /tmp/diskusage
    i change>>
    df -h| grep ‘Filesystem\|/dev/*’ > /tmp/diskusage

  4. Arash says:

    nice script
    but how can i make it live and dynamic!

  5. trash.80 says:

    Give inxi a try: https://github.com/smxi/inxi

    It’s already in most distributions, including Ubuntu, just a simple apt-get.

    inxi shows most everything you have here and has over 10 years development.

  6. Ariel says:

    Hi. I’m looking at the script and see ‘\E[32m’ before almost every echo string. Should it actually be there? What about support for other os types?

    • Ravi Saive says:


      The updated version of script is available at Github, the link can be found at the bottom of the article, and about compatibility, yes it works on almost all flavors of Linux distributions..

    • @Ariel, those are scape codes that make certain messages appear in color. Making the script work on other UNIXES (*BSD, AIX or Solaris) is not my priority. When I have time I’ll be testing it on AIX, that I have availiable.

  7. Immanuel says:

    Just tested the script. I made the following changes to get in working on Ubuntu and derivatives.

    removed the use of su.

    sudo cp $scriptname /usr/bin/monitor && echo “Congratulations! Script Installed, now run monitor Command” || echo “Installation failed”

    Added virtual hard disk and multiple hard disk.

    df -h| grep ‘Filesystem\|/dev/[s|v]d[a-z]*’ > /tmp/diskusage

    • Ravi Saive says:


      Thanks for making the script compatible for Ubuntu and its derivatives, hope it will help all Ubuntu users…

  8. ex_rat says:

    Hi, i like your script ! :)

    # Check Disk Usages
    df -h| grep ‘Filesystem\|/dev/sda*’ > /tmp/diskusage

    Disk Usages :
    /dev/sda2 439G 71M 417G 1% /home

    i change >>

    df -h| grep ‘Filesystem\|/dev’| sed ‘/tmpfs/d’ > /tmp/diskusage

    Disk Usages :
    /dev/root 20G 661M 18G 4% /
    /dev/sda2 439G 71M 417G 1% /home

    Bye Ex.

  9. Andres Tarallo says:


    I’ve discovered your script a month ago, thanks a former colleague. I’ve executed it on SuSE Enterprise (SLES), with some failures. I’m debugging it and making capable of running on other Linux other than Ubuntu.

    I want to upload the original script to GITHUB, to upload there my contributions. May I count with your blessing to do so?

    • Ravi Saive says:


      Thanks for making the script compatible for all Linux distributions, but make sure you should give credit to Tecmint.

      • Andres Tarallo says:

        I’ll credit Tecmint. It’s not my intention to delete the header or remove references to Tecmint.

        As said before it would be nice to have your blessing to upload the original Script to GITHUB, then I’ll be uploading there my changes.

        Feel free to write me a private message, the original script is great.

      • tushar jambhekar says:

        HI Ravi,

        I’m also using SuSE Enterprise 11 Sp3 & getting many incorrect out-put.Here I’m attaching it:

        OS Name : OS Version : Architecture : x86_64
        Kernel Release : 3.0.76-0.11-default
        Hostname : DC1SAPCSSRT
        hostname: invalid option — ‘I’
        Usage: hostname [-v] {hostname|-F file} set hostname (from file)
        domainname [-v] {nisdomain|-F file} set NIS domainname (from file)
        hostname [-v] [-d|-f|-s|-a|-i|-y|-n] display formatted name
        hostname [-v] display hostname

        hostname -V|–version|-h|–help print info and exit

        dnsdomainname=hostname -d, {yp,nis,}domainname=hostname -y

        -s, –short short host name
        -a, –alias alias names
        -i, –ip-address addresses for the hostname
        -f, –fqdn, –long long host name (FQDN)
        -d, –domain DNS domain name
        -y, –yp, –nis NIS/YP domainname
        -F, –file read hostname or NIS domainname from given file

        This command can read or set the hostname or the NIS domainname. You can
        also read the DNS domain or the FQDN (fully qualified domain name).
        Unless you are using bind or NIS for host lookups you can change the
        FQDN (Fully Qualified Domain Name) and the DNS domain name (which is
        part of the FQDN) in the /etc/hosts file.
        Internal IP :
        External IP :
        Name Servers : Before static /etc/sysconfig/network/config NETCONFIG_DNS_STATIC_SEARCHLIST NETCONFIG_DNS_STATIC_SERVERS NETCONFIG_DNS_FORWARDER or NETCONFIG_DNS_POLICY=” See Note: may only, file Please intelenetglobal.com
        Logged In users :
        tushar pts/0 Jul 22 10:35 (
        free: invalid option — ‘h’
        usage: free [-b|-k|-m|-g] [-l] [-o] [-t] [-s delay] [-c count] [-V]
        -b,-k,-m,-g show output in bytes, KB, MB, or GB
        -l show detailed low and high memory statistics
        -o use old format (no -/+buffers/cache line)
        -t display total for RAM + swap
        -s update every [delay] seconds
        -c update [count] times
        -V display version information and exit
        Ram Usages :
        Swap Usages :
        Disk Usages :
        Filesystem Size Used Avail Use% Mounted on
        /dev/sda1 18G 12G 5.1G 70% /
        /dev/sda3 9.9G 1.2G 8.3G 12% /tmp
        /dev/sda5 9.9G 2.5G 6.9G 27% /usr/sap/SRT
        /dev/sda6 5.0G 970M 3.8G 21% /sapmnt/SRT
        /dev/sda7 2.0G 172M 1.7G 9% /usr/sap/hostctrl
        /dev/sda8 9.9G 1.4G 8.0G 15% /usr/sap/trans
        /dev/sda10 1.4T 1.2T 140G 90% /oracle
        /dev/sda9 20G 5.1G 14G 27% /oracle/SRT/112_64
        Load Average : loadaverage:0.24,
        System Uptime Days/(HH:MM) : 21 days

        • Ravi Saive says:


          You just need to change the options available on your Linux distribution in the script to make it compatible with your Linux OS, because every Linux flavor has different options, so just use accordingly..

        • Hi !!!!

          I’ve been working on fixing that Issues on SuSE. I have them working on the script uploaded to github: https://github.com/atarallo/TECMINT_MONITOR/

          The fixes that are specific to SuSE/OpenSuSE are in the Development branch. Please take the script from there, you’re also welcome to contribute code and suggestions.

          • Ravi Saive says:


            Thanks for putting your efforts in making the script compatible with SuSE distribution, I haven’t yet checked the script on SuSE, but will certainly give a try today and see how it works..

          • Ravi Saive says:


            I’ve included the Github link to script in the article, so that users can download and keep further development of script under Tecmint license..

  10. emmanuelbuhay says:

    At first my public ip address wasn’t displaying so i changed ipecho.net to myipaddress.com via vim but still didn’t work, found out i didn’t install curl yet because i did a “curl -s ipecho.net” or was it “curl -s myipaddress.com” and it didn’t recognize curl, since i changed tecmint.sh and forgot the exact syntax in the “curl -s ipecho.net” line, i just re-downloaded it and re-executed it and it finally worked! was happy to see all values, i had fun hahaha thanks and keep the educational contents coming! :)

    • Andres Tarallo says:

      CURL is not mandatory to any distro I’m aware off. It’s very popular so many people think that it’s installed by default.

      I’ll add to the modified script (I’m working actually) to check for CURL availability.

    • I’ve added a check for availiability of CURL, you can find the script on:https://github.com/atarallo/TECMINT_MONITOR/ .Please download the development branch, all bugfixes and contributions are there.

      • Ravi Saive says:


        Thanks a ton for uploading the script to Github and also making the script available for development, will download and test it, if its works perfectly on all Linux distributions, will replace the current script with this new one..

Got something to say? Join the discussion.

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