LinuxQuestions.org
Visit Jeremy's Blog.
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
 
LinkBack Search this Thread
Old 05-15-2009, 12:05 PM   #1
sanpnair
LQ Newbie
 
Registered: May 2009
Posts: 1

Rep: Reputation: 0
Total CPU utilization returned by "top" command


Techies,

I searched this form to get an answer for my question below. But could not find.

I am looking for a "top" command option which returns the total "CPU"% used on Linux server.

Details below - ( This is a Vmware server )

[sam@mytestserver mother]$ uname -a
Linux mytestserver 2.4.21-57.ELvmnix #1 Wed Oct 15 19:00:05 PDT 2008 i686 athlon i386 GNU/Linux


[mother@mytestserver sam]$ /usr/bin/top n 1 d 2 b -p 1 | sed 's/cpu0/CPU/'

09:37:29 up 122 days, 11:39, 3 users, load average: 0.48, 0.26, 0.20
1 processes: 1 sleeping, 0 running, 0 zombie, 0 stopped
CPU states: cpu user nice system irq softirq iowait idle
total 3.7% 0.0% 0.0% 0.0% 0.0% 0.0% 96.2%
Mem: 268568k av, 255628k used, 12940k free, 0k shrd, 2404k buff
186084k actv, 27668k in_d, 3152k in_c
Swap: 4192956k av, 350180k used, 3842776k free 52548k cached

PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
1 root 15 0 492 460 436 S 0.0 0.1 0:40 0 init

==================================================================


Is it possible to create a single line "top" command which returns the total CPU utiliztion% only?


Thanks
SPN
 
Old 05-15-2009, 12:19 PM   #2
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,178

Rep: Reputation: 49
This link seems to have some good information on alternate ways to read CPU utilization, though it may use packages your distribution doesn't use.

If you run `man top` there are flags which you can set to pass the data to other programs -- such as a perl or bash script to parse out the data you want. Alternatively, if you want the load average, there are built-in commands to return that as well.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding the top CPU-using processes? "top" command does not help... catalytical Linux - Server 1 04-06-2009 04:50 PM
"TOP" Command keeps going to "stopped" state mudtoe Linux - Newbie 3 03-09-2009 11:15 PM
Generate alert with "CPU load average" "CPU utilization" viky Linux - Hardware 3 07-25-2007 04:24 AM
Alert used "cpu load" and "cpu utilization" viky General 0 07-23-2007 03:19 AM
"us" CPU usage in "TOP" bastupungen Linux - Server 6 11-04-2006 07:02 AM


All times are GMT -5. The time now is 07:06 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration