[Durham] Swap usage by process

Oliver Burnett-Hall olly at burnett-hall.co.uk
Thu Mar 22 23:16:33 UTC 2012


This one's for Dougie following this week's meeting -- the attached file
is a better script for analysing swap usage as reported
by /proc/*/smaps.

Save it somewhere, chmod it so that it's executable, and run it
(possibly via sudo if you can't read all of the files in /proc/*/smaps)
and it will output swap usage (in kB), process PID and process name.
You can bung it though sort -n to order by swap usage.

Random note 1: http://weather.ou.edu/~apw/projects/stress/ (which is in
the Debian archives as package 'stress') was very useful for making my
system return non-zero results with this script.

Random note 2: I haven't programmed in perl in a couple of years, and
I've forgotten *everything*.  Writing that script was far harder than
it should have been, and I completely failed to come up with a utterly
obfuscated one-liner, which was my real goal.

Random note 3: I've absolutely no idea how accurate the smaps
information is.  Google might know that.

- olly
-------------- next part --------------
A non-text attachment was scrubbed...
Name: swap.pl
Type: application/x-perl
Size: 364 bytes
Desc: not available
URL: <http://mailman.lug.org.uk/pipermail/durham/attachments/20120322/8d261491/attachment.bin>


More information about the Durham mailing list