From: Brett <brettspamacct@fastclick.com>
To: linux-kernel@vger.kernel.org
Cc: Kevin Kahley <kkahley@cs.uic.edu>
Subject: My stab at finding memory used by processes
Date: Mon, 06 Oct 2003 11:57:56 -0700 [thread overview]
Message-ID: <3F81BB34.3080008@fastclick.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 280 bytes --]
This perl script just goes through /proc/maps, finding inodes numbered
with 0 and adds those sizes. Seems to over-report things with our
servers, probably because it counts all pages even if they're copy on
write, don't know how to get around that.
Any comments are welcome.
[-- Attachment #2: getprocmem.pl --]
[-- Type: text/plain, Size: 869 bytes --]
#!/usr/bin/perl -w
use strict;
use File::Glob ':glob';
my $procregex = qr /^(\S+)-(\S+) \S+ \S+ \S+ (\S+)/;
sub process_mapsfile {
my ($path) = @_;
open(MAPSFD, $path);
my $totalsize = 0;
while(<MAPSFD>)
{
if (!/$procregex/)
{
#print "Couldn't match\n$_\n";
next;
}
else
{
#print "Matched\n$_\n";
}
#print "line = $_";
my $start = int(hex($1));
my $end = int(hex($2));
my $inode = int($3);
#print "inode = $inode, end = $end, start = $start\n";
if($inode == 0)
{
my $size = $end - $start;
$totalsize += $size;
}
}
close(MAPSFD);
return $totalsize;
}
my $totalsize = 0;
my @files = </proc/*>;
foreach my $file (@files)
{
# if we have a pid file, parse maps file
if($file =~ /\/proc\/\d+/)
{
$totalsize += process_mapsfile($file . "/maps");
}
}
print "size = $totalsize\n";
reply other threads:[~2003-10-06 18:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3F81BB34.3080008@fastclick.com \
--to=brettspamacct@fastclick.com \
--cc=kkahley@cs.uic.edu \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.