Linux OSのプロセスのcopy-on-writeのメモリ量を調べたりとか。
#!/usr/bin/perl use strict; use warnings; use Linux::Smaps; my @pids = `pgrep modperl`; printf "PID\tRSS\tSHARED\n"; my $total = { rss => 0, shared => 0, }; my $cnt = 0; for my $pid (@pids) { chomp $pid ; my $map = Linux::Smaps->new($pid); unless ($map) { warn $!; next; } $cnt++; $total->{rss} += $map->rss; $total->{shared} += $map->shared_dirty + $map->shared_clean; printf "%d\t%d\t%d (%d%%)\n", $pid, $map->rss, $map->shared_dirty + $map->shared_clean, int( ( ( $map->shared_dirty + $map->shared_clean ) / $map->rss ) * 100 ); } printf "TOTAL\t%d\t%d (%d%%)\n", $total->{rss}, $total->{shared}, $total->{shared} / $total->{rss} * 100 ; my $avg = { rss => 0, sahred => 0 }; printf "ARG\t%d\t%d (%d processes)\n", $total->{rss} / $cnt, $total->{shared} / $cnt , $cnt; __END__
タグ
このページへのコメント
1raA0h Really appreciate you sharing this blog article.Much thanks again. Really Cool.