LinuxQuestions.org
Review your favorite Linux distribution.
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 03-05-2012, 03:07 PM   #1
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 160

Rep: Reputation: 3
Calculating CPU-Usage for Unix/Linux..?


Hello All,

I'm trying to monitor CPU-Usage on a SLES 10 Server.
My question is which "CPU percentages" should I use to calculate the CPU-Usage...?

I know when you run "top" you can see about 8 different percentages lined up at the top of the page, which are:
(%user, %system, %nice, %idle, %wait, %interrupts, %soft, %steal)
You also get the same 8 percentages when you run "mpstat -P ALL".

Running vmstat you can see 5 percentages for CPU:
(%user, %system, %idle, %wait, %steal)

If I misunderstood any of the abbreviations that they use for the cpu %, please let me know.
So which of those are the most important? Also, whichever one's are the most important can I just add them and average them out?


If anyone has any suggestion please feel free to let me know.
I've searched all over and couldn't find a definite answer.

Thanks in Advance,
Matt

Last edited by mrm5102; 03-05-2012 at 03:11 PM.
 
Old 03-05-2012, 03:32 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,552

Rep: Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112
I would use the load instead, but that's just me. It's time averaged, smooth, and incorporates everything that draws CPU time. You also have multiple values giving you the average load over different time scales, so you can see if the spike in load is just temporary or if it's been going on for a while.
 
Old 03-05-2012, 04:21 PM   #3
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 160

Original Poster
Rep: Reputation: 3
Hey suicidaleggroll, thanks for the reply.

How do I see the CPU load...?

Thanks,
Matt
 
Old 03-05-2012, 04:41 PM   #4
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 160

Original Poster
Rep: Reputation: 3
Or should I just take all 8 percentages add them up and divide by 8 and get the average..?
 
Old 03-05-2012, 05:54 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,949

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
That would be absolutely the worst thing to do.
For definitions see the manpage(s). Also see the manpage for proc - particularly /proc/stat as that is where all the numbers probably come from.
Given how rubbery the numbers are in the first place, might be simplest to merely use "100-idle-wait-steal".
idle and wait are complements of each other for unused CPU - steal should be zero for a stand-alone (non-virtualized) server.
Doesn't give any idea of balance across CPUs/cores of course - you could do it all yourself from /proc/stat if you feel inclined.
 
Old 03-05-2012, 06:05 PM   #6
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,552

Rep: Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112
Quote:
Originally Posted by mrm5102 View Post
Hey suicidaleggroll, thanks for the reply.

How do I see the CPU load...?

Thanks,
Matt
It should be the three numbers at the top right of "top", ie:
Code:
top - 16:04:55 up 199 days,  8:30, 30 users,  load average: 0.39, 0.24, 0.12
The three numbers next to "load average". Leftmost is the fastest, rightmost is the slowest (averaged over the longest amount of time).
 
1 members found this post helpful.
Old 03-05-2012, 07:36 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
You might want to read a few articles; its not as simple as it seems eg http://www.linuxjournal.com/article/9001
 
Old 03-08-2012, 04:16 PM   #8
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 160

Original Poster
Rep: Reputation: 3
Hey thanks to everyone who replied.

I wish they would make this a little bit harder and a bit more confusing to get something like CPU Usage in a percentage... But oh well!

suicidaleggroll,
I decided to go with your suggestion using the load average from the first line of the top command.
I think I'm just going to have a simple Perl script to extract the "load average" from the output of "top -n 1"... Simple enough.


Thanks Again,
Matt

Last edited by mrm5102; 03-08-2012 at 04:33 PM.
 
  


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
Problems Calculating Process Memory Usage swass Linux - General 7 05-14-2010 10:25 AM
Calculating protocol bandwidth usage buee Linux - Newbie 2 02-17-2010 07:45 PM
LXer: Measuring Heavy CPU Usage Over Time On Linux And Unix LXer Syndicated Linux News 0 03-31-2009 08:00 AM
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li rags2k Programming 4 08-21-2004 05:45 AM
Calculating total %cpu usage from /proc/stat gaijin Programming 1 07-07-2004 03:45 AM

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

All times are GMT -5. The time now is 03:20 AM.

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