LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 10-25-2004, 04:54 PM   #1
Stingreen
Member
 
Registered: May 2001
Location: Baltimore,MD,USA,Earth,Some Galaxy, We haven't gone that far!
Distribution: Redhat 7.3
Posts: 103

Rep: Reputation: 15
Shell scripting - Adding many numbers in an array


I'd like to know what process is taking how much CPU, so a command like this ; ps waux | grep apache | awk '{print $3}' would give me
the following. However, I need to add those numbers one by one in order to see how much CPU my apache server is spending..
Any ideas? : )
Thanks in advance.

0.0
0.3
0.3
0.3
0.2
0.5
0.6
0.6
0.6
0.6
0.8
0.7
0.8
0.4
0.4
0.4
0.4
0.6
0.3
0.7
0.3
0.6
0.4
0.6
0.1
0.6
0.3
0.2
0.2
0.5
0.6
0.4
0.4
0.5
0.3
0.5
0.4
0.1
0.7
0.2
0.4
0.4
0.2
0.4
0.2
0.6
0.5
0.1
 
Old 10-25-2004, 05:10 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 39,832

Rep: Reputation: 1117Reputation: 1117Reputation: 1117Reputation: 1117Reputation: 1117Reputation: 1117Reputation: 1117Reputation: 1117Reputation: 1117
Code:
ps waux | grep apache | awk '{sum += $3} END {print sum}'
i love google
 
Old 10-25-2004, 05:25 PM   #3
Stingreen
Member
 
Registered: May 2001
Location: Baltimore,MD,USA,Earth,Some Galaxy, We haven't gone that far!
Distribution: Redhat 7.3
Posts: 103

Original Poster
Rep: Reputation: 15
Well, I googled too but couldn't find anything relevant to it. should've looked closer.
thank you acid.
 
  


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
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 03:32 PM
Shell scripting - Random numbers within a range felixc Linux - Newbie 2 10-09-2005 05:41 PM
How to use decimal numbers in in shell scripts a1ex_007 Programming 6 03-11-2005 09:05 AM
Adding numbers, break on non-numbers... Cruger Programming 1 03-22-2004 09:18 AM


All times are GMT -5. The time now is 08:49 AM.

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
Open Source Consulting | Domain Registration