LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 09-12-2010, 10:17 PM   #1
j0hnsmith
LQ Newbie
 
Registered: Apr 2009
Posts: 23

Rep: Reputation: 0
How to find total apache memory usage?


Top only show the memory usage for individual processes. Apache often runs hundreds of processes, each of which may use only a small amount of memory, however the total memory consumed by all apache processes can be fairly large.

Is there a way to see the total memory usage for all apache processes?
 
Old 09-12-2010, 10:49 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 162Reputation: 162
Are you familiar with perl? The info here might help if you are.
 
Old 09-13-2010, 01:31 AM   #3
j0hnsmith
LQ Newbie
 
Registered: Apr 2009
Posts: 23

Original Poster
Rep: Reputation: 0
I am familiar with perl but don't use it myself (I'm a python man), that script looks cool though. I tried to run it and got an error related to `use Statistics:escriptive;`, a module I don't have I assume.
 
Old 09-13-2010, 02:04 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,445

Rep: Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068
Wellll .... in that case, try this.
Much better - handles shared libraries.
 
Old 09-13-2010, 02:05 AM   #5
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
Code:
ps aux| awk '/apach[e]/{total+=$4}END{print total}'
 
Old 09-13-2010, 02:26 AM   #6
j0hnsmith
LQ Newbie
 
Registered: Apr 2009
Posts: 23

Original Poster
Rep: Reputation: 0
Using the python script recommended by syg00 I get
Code:
 Private  +   Shared  =  RAM used	Program 

252.0 KiB +  89.0 KiB = 341.0 KiB	fishd
476.0 KiB + 120.5 KiB = 596.5 KiB	memcached
696.0 KiB + 124.0 KiB = 820.0 KiB	init
  1.1 MiB + 188.0 KiB =   1.3 MiB	fish
960.0 KiB + 681.0 KiB =   1.6 MiB	nginx (2)
  1.8 MiB + 711.5 KiB =   2.5 MiB	sshd (2)
  3.6 MiB +   2.3 MiB =   5.8 MiB	postgres (5)
 32.7 MiB +   5.5 MiB =  38.3 MiB	apache2 (4)
---------------------------------
                         51.2 MiB
=================================
However top shows about 250mb total memory used, so the majority is unaccounted for.
 
Old 09-13-2010, 02:41 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,445

Rep: Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068
That is because the script takes into account the (common) shared libraries that most utilities count multiple times.
Memory accounting is a real can of worms - try looking at this for example.
 
Old 09-13-2010, 03:49 AM   #8
j0hnsmith
LQ Newbie
 
Registered: Apr 2009
Posts: 23

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by syg00 View Post
Memory accounting is a real can of worms - try looking at this for example.
Indeed. I was hoping there was an easy way to get the number that accounts for the difference between total memory used when apache is and isn't running, without stopping apache. Seems that top > stop apache > top > start apache is the only 'real' way.

Thanks for all your replies.
 
  


Reply

Tags
apache


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
Query: Embedded System - Total Memory Usage EmbeddedSteve Linux - Embedded & Single-board computer 1 08-20-2010 01:40 PM
most, er, universal way to get system memory total and usage lumix Linux - Newbie 1 06-03-2007 10:30 AM
Command to show each application/process memory usage and its total gn00kie Linux - Enterprise 2 09-21-2006 04:08 AM
memory usage (apache related?) stonecrest Linux - General 3 08-10-2005 06:52 AM
Limiting the total amount of memory usage by apache. SplashHost.com Linux - General 8 08-30-2002 10:56 AM


All times are GMT -5. The time now is 06:40 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