Skip to content

Instantly share code, notes, and snippets.

@mizzy
Last active December 16, 2015 15:39
Show Gist options
  • Select an option

  • Save mizzy/5457912 to your computer and use it in GitHub Desktop.

Select an option

Save mizzy/5457912 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use Linux::Smaps;
@ARGV or die "usage: %0 pid";
my $pid = shift;
my $pstree = `pstree $pid -p`;
my $total_rss = 0;
my $total_shared = 0;
while ( $pstree =~ /[^\{][a-zA-Z0-9_\-]+[^\}]\((\d+)\)/xmsg ) {
my $map = Linux::Smaps->new($1);
$total_rss += $map->rss;
$total_shared += $map->shared_dirty + $map->shared_clean;
}
print "$total_rss $total_shared\n";
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment