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

174 Responses

  1. John Hosie says:

    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 :  208.82.219.167
    Name Servers :  204.117.214.10 199.2.252.10
    Logged In users :
    jhosie   pts/2        2019-03-05 15:45 (65.123.231.210)
    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.

    • Ravi Saive says:

      @John,

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

  2. Junaid says:

    How to send its output as an email?

    • Mansur Ul Hasan says:

      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

      #!/bin/bash
      ./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
      
  3. Baljit Singh says:

    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

  4. Prasad M says:

    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.

  5. Rasheed says:

    the information loads up really slow on my server

  6. joejoe says:

    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

    • Andres Tarallo says:

      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.

Leave a Reply to Rasheed Cancel reply

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

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