LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-30-2008, 11:57 PM   #1
scbops
Member
 
Registered: Feb 2006
Posts: 97

Rep: Reputation: 15
CPU utilization


does anyone has a script to get cpu average ?
 
Old 12-31-2008, 05:46 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Probably yes.
 
Old 12-31-2008, 06:16 AM   #3
scbops
Member
 
Registered: Feb 2006
Posts: 97

Original Poster
Rep: Reputation: 15
appreciate if someone provide one script to me
 
Old 12-31-2008, 06:36 AM   #4
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 179Reputation: 179
Most of us are busy with our own projects, so we're not likely to actually write scripts for you, but if you have a specific question about the behavior of a script you've already written, here's the place to ask it!

In the meantime, these aren't exactly scripts, but for a start, go here.
 
Old 12-31-2008, 08:00 AM   #5
scbops
Member
 
Registered: Feb 2006
Posts: 97

Original Poster
Rep: Reputation: 15
top - 19:37:42 up 14 days, 9:17, 6 users, load average: 0.00, 0.00, 0.00
Tasks: 91 total, 1 running, 90 sleeping, 0 stopped, 0 zombie
Cpu(s): 3.2% us, 0.4% sy, 0.0% ni, 94.5% id, 1.7% wa, 0.1% hi, 0.0% si
Mem: 1555972k total, 949324k used, 606648k free, 92004k buffers
Swap: 2031608k total, 160k used, 2031448k free, 627112k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
13754 root 16 0 1948 832 652 R 3.9 0.1 0:00.02 top
1 root 16 0 3568 560 480 S 0.0 0.0 0:02.25 init



This the output of top command, as you can see there are seven outputs in cpu(s) row, how can I get CPU% as one value?
 
Old 12-31-2008, 08:49 AM   #6
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 179Reputation: 179
Those numbers add up to 99.9%. You can pretty well predict that the "one value" will always be very, very close to 100.0%. That makes your initial problem very, very simple, if I understand it correctly.

But if you want the sum of only some of those, use sed to isolate the numbers you want.
 
Old 12-31-2008, 06:43 PM   #7
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
I'll give you a hint. 94.5% id means 94.5 percent IDLE.
 
  


Reply



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
Linux desktop GUI tool for CPU utilization and bandwidth utilization karimasif Linux - Software 4 03-03-2008 01:09 PM
CPU utilization ust Linux - Software 1 10-11-2007 06:05 AM
CPU utilization in 2.4 vs 2.6.. lynz Linux - Software 2 06-04-2007 01:40 PM
Thread CPU Utilization frakman1 Programming 3 01-20-2006 01:27 PM
getting total cpu utilization using c theog Programming 2 03-19-2005 04:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:54 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
Open Source Consulting | Domain Registration