line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Linux::Smaps::Tiny::PP; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
41
|
$Linux::Smaps::Tiny::PP::AUTHORITY = 'cpan:AVAR'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$Linux::Smaps::Tiny::PP::VERSION = '0.09'; |
7
|
|
|
|
|
|
|
} |
8
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
9
|
1
|
|
|
1
|
|
5
|
use warnings FATAL => "all"; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
239
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub __get_smaps_summary { |
12
|
3
|
|
100
|
3
|
|
11090
|
my $proc_id= shift || "self"; |
13
|
3
|
|
|
|
|
9
|
my $smaps_file= "/proc/$proc_id/smaps"; |
14
|
|
|
|
|
|
|
open my $fh, "<", $smaps_file |
15
|
3
|
100
|
|
|
|
153
|
or do { |
16
|
1
|
|
|
|
|
9
|
my $errnum= 0+$!; # numify |
17
|
1
|
|
|
|
|
5
|
my $errmsg= "$!"; # stringify |
18
|
1
|
|
|
|
|
3
|
my $msg= "In get_smaps_summary, failed to read '$smaps_file': [$errnum] $errmsg"; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
11
|
die $msg; |
21
|
|
|
|
|
|
|
}; |
22
|
2
|
|
|
|
|
3
|
my %sum; |
23
|
2
|
|
|
|
|
1435
|
while (<$fh>) { |
24
|
2464
|
100
|
|
|
|
6296
|
next unless substr($_,-3) eq "kB\n"; |
25
|
2156
|
|
|
|
|
4519
|
my ($field, $value)= split /:/,$_; |
26
|
1
|
|
|
1
|
|
7
|
no warnings 'numeric'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
104
|
|
27
|
2156
|
50
|
|
|
|
11551
|
$sum{$field}+=$value if $value; |
28
|
|
|
|
|
|
|
} |
29
|
2
|
|
|
|
|
28
|
close $fh; |
30
|
2
|
|
|
|
|
20
|
return \%sum; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |