OK, top is not really what I'm looking for because I'm wanting to script a
process taht upon vm overload approach a script checks the pid numbers from
the httpd access log, then calls something like ps and captures the response
and evaluates which are the highest etc.
Server sits at rest with 0 swap in use (according to free and top) Then 5
minutes later, I have 50 to 60% swap in use. I have looked at top using M
to sort by memory usage and nothing seems excessively high. (although httpd
and mysql are at the top) I chased this a couple of weeks ago without
finding anything solid. Since it did not noticeably affect the performance
of the server, I wrote it off to some internal process of swapping items by
the kernel that are normal. However, today the server locked up from
excessive memory usage. I have to get to the bottom of this and know how to
sluth this in the future. I'm hoping that by creating a script that pulls
together all the relavent pieces of information, I can simply run the script
and get a readout of exactly what is happening.
I have done a lot of googling today and came accross a pretty good article
on linux-tutorial.info.
http://ww.linux-tutorial.info/cgi-bin/display.pl?90&0&322&0&3
However, I'm still trying to get this down. All I really need to know is
how to get...
memory used by pid in physical memory
memory used by pid in swap memory
>From the article (from my understanding) ps -p <processid> -o "sz vsz rss"
gives the process core image size [size of the process at its inception
before growing as it performs its functions?], size of total memory for the
process [size of the process including virtual and physical memory?], and
size of physical memory taken up by the process.
The problem is that when I run free I get...
Swap: 265032 2296 262736
and when I run ps -p 3331 -o "sz vsz rss" I get ...
5491 21964 9428
according to that the difference between the physical memory 9428 and the
total memory size 21964 would have to be 12536 which is larger than the 2296
reported in use in swap by the "free" command.
The only descriptions I come accross in postings asking about memory use
come back with an explination of what free returns to explain how much
memory is actually available etc. I need to single out these processes and
be able to account for their usage.
Sorry for the book, but I'm looking for something pretty specific here and I
don't know how else to explain it.
-----Original Message-----
From: flalug@nks.net [mailto:flalug@nks.net]On Behalf Of Eben King
Sent: Wednesday, March 10, 2004 1:15 PM
To: Linux
Subject: Re: [flalug] more memory questions...
On Wed, 10 Mar 2004, Larry Brown wrote:
> Does anyone know how to get the exact amount of memory used for a process?
> In ps it renders a percentage number.
Is "top -b -n 1 | grep '^ *$pid ' | awk '{ print $5 }'" what you want?
That's RSS. I suppose you could take top's percentage and multiply it by
the total amount of memory, but the percentage is at most three
significant digits, usually fewer.
Also, /proc/<pid>/status is interesting. For an xterm, I get:
...
VmSize: 2448 kB
VmLck: 0 kB
VmRSS: 1436 kB
VmData: 348 kB
VmStk: 24 kB
VmExe: 588 kB
VmLib: 1420 kB
...
So I guess it kinda depends what you mean by "memory".
-- -eben ebQenW1@EtaRmpTabYayU.rIr.OcoPm home.tampabay.rr.com/hactarThis message was created using recycled electrons.
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:14:59 EDT