Last active
December 16, 2015 15:39
-
-
Save mizzy/5457912 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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