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