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

The duty of System Administrator is really tough as he/she has to monitor the servers, users, logs, create backup and blah blah blah. For the most repetitive task most of the administrator write a script to automate their day-to-day repetitive task. Here we have written a shell Script that do not aims to automate the task of a typical system admin, but it may be helpful at places and specially for those newbies who can get most of the information they require about their System, Network, Users, Load, Ram, host, Internal IP, External IP, Uptime, etc.

We have taken care of formatting the output (to certain extent). The Script don’t contains any Malicious contents and it can be run using Normal user Account. In-fact it is recommended to run this script as user and not as root.

Linux Server Health Monitoring
Shell Script to Monitor Linux System Health

You are free to use/modify/redistribute the below piece of code by giving proper credit to Tecmint and Author. We have tried to customize the output to the extent that nothing other than the required output is generated. We have tried to use those variables which are generally not used by Linux System and are probably free.

Minimum System Requirement

All you need to have is a working Linux box.


There is no dependency required to use this package for a standard Linux Distribution. Moreover the script don’t requires root permission for execution purpose. However if you want to Install it, you need to enter root password once.


We have taken care to ensure security of the system. Nothing additional package is required/installed. No root access required to run. Moreover code has been released under Apache 2.0 License, that means you are free to edit, modify and re-distribute by keeping Tecmint copyright.

How Do I Install and Run Script?

First, use following wget command to download the monitor script "tecmint_monitor.sh" and make it executable by setting appropriate permissions.

# wget https://tecmint.com/wp-content/scripts/tecmint_monitor.sh
# chmod 755 tecmint_monitor.sh

It is strongly advised to install the script as user and not as root. It will ask for root password and will install the necessary components at required places.

To install "tecmint_monitor.sh" script, simple use -i (install) option as shown below.

./tecmint_monitor.sh -i 

Enter root password when prompted. If everything goes well you will get a success message like shown below.

Congratulations! Script Installed, now run monitor Command

After installation, you can run the script by calling command 'monitor' from any location or user. If you don’t like to install it, you need to include the location every-time you want to run it.

# ./Path/to/script/tecmint_monitor.sh

Now run monitor command from anywhere using any user account simply as:

$ monitor

TecMint Monitor Script in Action

As soon as you run the command you get various System related information which are:

  1. Internet Connectivity
  2. OS Type
  3. OS Name
  4. OS Version
  5. Architecture
  6. Kernel Release
  7. Hostname
  8. Internal IP
  9. External IP
  10. Name Servers
  11. Logged In users
  12. Ram Usages
  13. Swap Usages
  14. Disk Usages
  15. Load Average
  16. System Uptime

Check the installed version of script using -v (version) switch.

$ monitor -v

tecmint_monitor version 0.1
Designed by Tecmint.com
Released Under Apache 2.0 License


This script is working out of the box on a few machines I have checked. It should work the same for you as well. If you find any bug let us know in the comments. This is not the end. This is the beginning. You can take it to any level from here.

We’ve received few complaints that the script is not working on the few Linux distributions, and one of our regular reader Mr. Andres Tarallo, has taken the initiative and made the script compatible with all Linux distributions, you can find the updated script on GitHub at https://github.com/atarallo/TECMINT_MONITOR/.

If you feel like editing the script and carry it further you are free to do so giving us proper credit and also share the updated script with us so that we can update this article by giving you proper credit.

Don’t forget to share your thoughts or your script with us. We will be here to help you. Thank you for all the love you have given us. Keep Connected! Stay tuned.

If you read this far, tweet to the author to show them you care. Tweet a thanks
Ronav Saive
A Passionate GNU/Linux Enthusiast and Software Developer with over a decade in the field of Linux and Open Source technologies.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

186 thoughts on “A Shell Script to Monitor Network, Disk Usage, Uptime, Load Average and RAM Usage in Linux”

  1. For ‘OS Version’ : Linux Debian GNU/Linux 9 (stretch) 4.9.0-11-amd64(4.9.0-11-amd64 x86_64)
    ‘top -n 1 -b’ stdout:
    top – 22:27:53 up 13 min, 9 users, load average: 1.70, 2.23, 1.63
    So ‘tecmint_monitor.sh’ display:
    Load Average : average:2.02,2.35,

  2. Include this also in GitHub link.

    # Last Reboot Time
    lastreboottime=$(who -b | awk '{print $3,$4}')
    echo -e '\E[32m'"Last Reboot Time :" $tecreset $lastreboottime
  3. While running the given script in Ubuntu 18.04.3 LTS by using sh command, it throughout error like below.

    tecmint_monitor.sh: 23: tecmint_monitor.sh: [[: not found
    tecmint_monitor.sh: 33: tecmint_monitor.sh: [[: not found
    tecmint_monitor.sh: 40: tecmint_monitor.sh: [[: not found

    Please check and do the needful

  4. Followed your instructions to install on RHEL 5.8, and then ran “monitor”, with the results below:

    [[email protected] ~]# monitor
    Sample Output
    Internet:  Connected
    Operating System Type :  GNU/Linux
    cat: /etc/os-release: No such file or directory
    OS Name : OS Version : Architecture :  x86_64
    Kernel Release :  2.6.18-308.13.1.el5
    Hostname :  civaky3.truthtechnologies.com
    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 :
    Logged In users :
    jhosie   pts/2        2019-03-05 15:45 (
    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/sda3              97M   40M   52M  44% /boot
    Load Average :  loadaverage:0.18,
    System Uptime Days/(HH:MM) :  331 days

    It would be nice to know what it was supposed to do. I’m sure it wasn’t what happened.

    • @John,

      You are using very old distribution, just update the hostname and free command options supported by your distro in the script.

    • Redirect stdout to file and then use mail function to mail to your email

      for this wrap your script into another bash script and run that

      vim anotherscript.sh 

      Put below content into script

      ./Path/to/script/tecmint_monitor.sh 2>&1 > script.out
      mail -r [email protected] -s "Server monitoring result "  [email protected] < script.out

      Now run your script

      # sh anotherscript.sh
  5. How to run this script against multiple servers?
    Do I need to install this script to all the servers then extract the data, Please advise

  6. Hi Andres Tarallo,

    Good day!, as I am working on Migration work for 250+ servers, wanted to collect the server related info along with cluster details.

    I would need your help to how to identify the servers are configured in cluster (VCS, RedHat Cluster, SCS, VxVM).

    Please suggest.

  7. What if I want to run this script against a list of 100 remote servers and put that all that data in a nice spreadsheet how do I get that accomplished

    • You could run the script via ssh. It won’t be a difficult task to make it run. Putting data on a Spreadsheet will require more work, maybe programming in Python/PERL or your favourite language with a API for dealing with spreadsheets.


Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.