Memmap, a tool for listing the WebSpere Application Server threads and processes

Downloadable files
Abstract
Under Linux, the "ps" command lists indistinctly all the processes and threads. The memmap tool identifies which are real processes and which are threads sharing the same storage.
Download Description
The memmap tool scans the output of the "ps" command and identifies the processes running for WAS. Then, for each process, it reads the info in /proc and determines whether the current entry is a real process or just a thread sharing the same storage as the parent process.

Then, for each group of threads sharing the same storage, memmap displays the following statistics:

VmSize: Virtual memory size

VmRss: Resident Set Size that the process has in real memory, minus 3 for administrative purposes. This is just the pages which count towards text, data, or stack space. This does not include pages which have not been demand-loaded in, or which are swapped out.

VmData: Data (heap) allocated

VmStk: Size of the stack

VmExe: Size of the code (text) portion

VmLib: Shared memory mapped to libraries and shared code.

The source code follows (My server will go down shortly, no URL). See installation instructions below.

#--------------------------------- cut here ------------------
#! /usr/bin/perl -w
# This program scans the process list of the Linux machine and finds
# all the WebSphere threads. It counts the threads and display statistics.

use File::Basename;

my $ProgName;
my $line;
my $pid;
my $ppid;
my $pgid;
my $session;
my $rss;
my $vsz;
my $ThdCnt = 0; # Number of threads in a group
my $GrpIdent=""; # Process group identifier
my $ProcIdent=""; # Process identifier

$ProgName = basename($0);

# This ps command gets a hierarchical tree of all processes
open PSOUT, "ps -eo 'pid,ppid,pgid,session,rss,vsz,command' -H |" or
die "$ProgName: cannot execute command ps: $!";

while (<PSOUT>) {
next unless /WebSphere/; # Skip everything not related to WAS
$line= $_; # Current line from ps output
$line =~ s/^ +//; # Remove blanks from beginning
($pid, $ppid, $pgid, $session, $rss, $vsz) = split / +/, $line;
# print "$pid, $ppid, $pgid, $session, $rss, $vsz\n"; ## DEBUG

# To decide that a set of processes are actually in the same group, we
# verify that: 1. they are in a hierachy (same tree branch),
# 2. they have the same PGID, SESSION, RSS and VSZ values,

## Process identifier = concatenation of PGID, SESSION, RSS and VSZ
$ProcIdent = $pgid . $session . $rss . $vsz;
if ($ProcIdent ne $GrpIdent) { # Is this a new thread group?
DisplayThd(); # Display the stats for previous group if any
$ThdCnt = 1;
$Parent = $pid;
$GrpIdent = $ProcIdent;
# Grab the content of the /proc/X/status entry
@Status=`cat /proc/$pid/status |grep '^Vm'`;
}
else {
$ThdCnt++;
}
}

close PSOUT;

DisplayThd(); # Might be needed

exit 0;

############################################
sub DisplayThd {
if ($ThdCnt != 0) {
print "Group of $ThdCnt threads, parent PID=$Parent\n";
my $i;
foreach $i (@Status) { print $i;}

}

}

#example of short cmdline display:
#(cat /proc/10755/cmdline; echo) | tr "\000""\n" |grep -v '^-[A-Z]'
#--------------------------------------- cut here ------------------
Prerequisites
Version of linux that uses a /proc pseudo-file system. Tested on x86 Linux and zSeries SuSE Linux (both with a Linux kernel version 2.4).
Installation instructions
Copy the script between the "cut here" lines in the description above. Paste it into a file called memmap.pl (unset auto-wrap if you're using Notepad or another of those editors too clever for their own good) . Save the file. FTP it to your Linux machine. Make it executable (chmod a+x memmap.pl). Make sure WAS is running on the Linux machine. Run the tool with
memmap.pl
(no parameters required)
Download package
DownloadRELEASE DATELANGUAGESIZE(Bytes)Download Options
See above9/1/2002English1
Technical support
If you are familiar with Perl and with the /proc data structure, you can add extra info in the output display.











Document Information

Product categories: Software, Application Servers, Distributed Application & Web Servers, WebSphere Application Server, Servlet Engine/Web Container
Operating system(s): Linux
Software version: 3.5, 4.0, 5.0, 5.1, 6.0
Reference #: 4007880
IBM Group: Software Group
Modified date: 2005-01-17