Giter Site home page Giter Site logo

cpu_usage's Introduction

SCRIPT TO MONITOR CPU, MEMORY AND DISK USAGE.

This bash/shell script is going to output a table with four columns showing date and the percentages of Memory, Disk and CPU used on our machine. The script is going to run for a certain amount of time every 1 second and save the date to a log file in a table form. Later on, the data file can then be imported into an Microsoft Excel sheet for analysis and graphing.

Let’s get started!

The script is basically made up of three main parts:

#1- Memory:

free -m | awk 'NR==2{printf "%.2f%%\t\t", $3*100/$2 }' 9.24%

#2- Disk:

df -h | awk '$NF=="/"{printf "%s\t\t", $5}' 7%

#3- CPU

top -bn1 | grep load | awk '{printf "%.2f%%\t\t\n", $(NF-2)}'

You can always output the data to a log file:

[root@localhost]# ./cpu_usage.sh >> log.txt

Once the data is ready, you can use Microsoft Excel to import the data into a table and use Excel’s graphing capabilities to view the changes.

cpu_usage's People

Contributors

basiljose1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.