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.

Dependency

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.

Security

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.

Password: 
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

Conclusion

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 liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

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

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

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

  1. Hi, can you help me? your script tecmint_monitoring.sh not working to get data df -h because my server on AWS cloud.

    How to get data df -h to show inyour script tecmint_montoring.sh if i’ve filesystem like this:

    Filesystem      Size  Used Avail Use% Mounted on
    udev            2.0G     0  2.0G   0% /dev
    tmpfs           395M  804K  394M   1% /run
    /dev/xvda1       30G   18G   12G  60% /
    tmpfs           2.0G     0  2.0G   0% /dev/shm
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
    /dev/loop0       29M   29M     0 100% /snap/amazon-ssm-agent/2012
    /dev/loop1       97M   97M     0 100% /snap/core/9436
    /dev/loop2       18M   18M     0 100% /snap/amazon-ssm-agent/1566
    /dev/loop3       98M   98M     0 100% /snap/core/9289
    tmpfs           395M     0  395M   0% /run/user/1000
    

    thanks

    Reply
    • Hi Bayu,

      Just remove “| grep ‘Filesystem\|/dev/sda*'” from “# Check Disk Usages” line.

      You will get all the mount points in the display. You have run the installation command again to reflect the changes.

      regards,
      Omkar

      Reply
      • OK, thank you very much.

        that’s works for me, and now I will send the results using email. I have used this instruction

        #! / bin / bash
        ./tecmint_monitor.sh 2> & 1> script.out
        mail -r [email protected] -s "Server monitoring result" [email protected] <script.out
        

        but there is still an error like this:

        ./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
        

        can you help me again?

        thanks

        Reply

Leave a Reply to Rob Cancel reply

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.

This site uses Akismet to reduce spam. Learn how your comment data is processed.