LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-30-2015, 11:36 PM   #1
hruday
Member
 
Registered: Jun 2015
Posts: 88

Rep: Reputation: Disabled
Calculate RAM and CPU Usage in CentOS 7


I want to calculate actual RAM and CPU usage of CentOS 7.

My output for "free -hg" is as follows

#free -hg
total used free shared buff/cache available
Mem: 3.6G 828M 1.8G 231M 1.0G 2.3G
Swap: 2.0G 0B 2.0G
I dont suppose 828M is used.

And for CPU usage which command output should i use?

So how can i calculate actual RAM and CPU usage in centOS 7?
 
Old 12-30-2015, 11:58 PM   #2
ardvark71
LQ Veteran
 
Registered: Feb 2015
Location: Oregon, USA
Distribution: Lubuntu 14.04, Windows Vista
Posts: 6,277
Blog Entries: 3

Rep: Reputation: 839Reputation: 839Reputation: 839Reputation: 839Reputation: 839Reputation: 839Reputation: 839
Quote:
Originally Posted by hruday View Post
And for CPU usage which command output should i use?
Hi...

Take a look at the commands mentioned here, although some will require the download of a specific program, such as Htop.

For a single process, take a look at this page.

Regards...

Last edited by ardvark71; 12-31-2015 at 12:05 AM. Reason: Added information and greeting.
 
Old 12-31-2015, 12:24 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 18,143

Rep: Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935Reputation: 2935
Quote:
Originally Posted by hruday View Post
I dont suppose 828M is used.
Why don't you suppose that ?.
You asked for data, then reject it without reason.

You probably don't know what you are asking, so perhaps you could enlighten us why "free" is wrong. Start by looking at /proc/meminfo.
For rough CPU%, vmstat might suffice. But again, what are you really asking ?. How many CPU/cores do you have - do you want numbers for each, or an overall average ?. For what period ?. etc.
 
Old 12-31-2015, 02:43 AM   #4
hruday
Member
 
Registered: Jun 2015
Posts: 88

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
Why don't you suppose that ?.
You asked for data, then reject it without reason.

You probably don't know what you are asking, so perhaps you could enlighten us why "free" is wrong. Start by looking at /proc/meminfo.
For rough CPU%, vmstat might suffice. But again, what are you really asking ?. How many CPU/cores do you have - do you want numbers for each, or an overall average ?. For what period ?. etc.
I actually want a shell script to calculate RAM and overall average CPU usage in % and send a mail when it reaches a threshold value.
 
Old 12-31-2015, 03:08 AM   #5
sag47
Senior Member
 
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,860
Blog Entries: 36

Rep: Reputation: 458Reputation: 458Reputation: 458Reputation: 458Reputation: 458
No need for a shell script. Compile/install nagios or icinga plugins which come with utilities for doing exactly as you describe. If you want fancier things then you can install icinga fully and get the benefit of real time monitoring software.

https://www.icinga.org

Also, this forum doesn't typically operate as a shell script factory. The normal etiquette is to attempt to write a script yourself, provide sources and research, and ask for feedback for improvement.

Reading the bash man page from top to bottom is surprisingly enlightening once you know the basics of shell scripting. Here's a shell script I wrote which helpfully turns a man page into a PDF ebook. Execute "./man2pdf bash" on the terminal.

Last edited by sag47; 12-31-2015 at 03:15 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Squid 3 near 100% cpu usage and high RAM usage piman Linux - Software 1 11-16-2013 02:20 AM
Problem of calculate the cpu usage freebaihu Linux - Software 0 07-10-2012 08:58 PM
SLES9 snmp calculate CPU usage peter72 Linux - Software 0 11-04-2009 08:57 PM
CPU and RAM usage rslinks Linux - Server 3 10-06-2008 01:39 PM
How to calculate cpu and memory usage of a process narendra1310 Ubuntu 1 08-30-2008 02:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration