line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::Memalyzer::Plugin::ProcStatus; |
2
|
1
|
|
|
1
|
|
739
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
BEGIN { |
6
|
1
|
50
|
|
1
|
|
36
|
die( __PACKAGE__ . ' cannot be used without a proc filesystem') |
7
|
|
|
|
|
|
|
unless -e '/proc'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use base 'Devel::Memalyzer::Base'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
576
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub collect { |
13
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
14
|
1
|
|
|
|
|
3
|
my ( $pid ) = @_; |
15
|
1
|
|
|
|
|
5
|
return $self->capture_status( $pid ); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub status { |
19
|
1
|
|
|
1
|
|
5
|
my $self = shift; |
20
|
1
|
|
|
|
|
2
|
my ( $pid ) = @_; |
21
|
1
|
|
|
|
|
7
|
return "/proc/$pid/status"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub capture_status { |
25
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
26
|
1
|
|
|
|
|
2
|
my ( $pid ) = @_; |
27
|
1
|
50
|
|
|
|
8
|
open( my $status, '<', $self->status( $pid )) || die( "Error opening status: $!" ); |
28
|
1
|
|
|
|
|
62
|
my %data; |
29
|
1
|
|
|
|
|
31
|
while( my $line = <$status> ){ |
30
|
31
|
100
|
|
|
|
95
|
next unless $line =~ m/^Vm/; |
31
|
7
|
|
|
|
|
12
|
chomp( $line ); |
32
|
7
|
|
|
|
|
26
|
my ( $key, $value ) = split( /:\s+/, $line ); |
33
|
7
|
|
|
|
|
21
|
$value =~ s/\s.*$//; |
34
|
7
|
|
|
|
|
30
|
$data{ $key } = $value; |
35
|
|
|
|
|
|
|
} |
36
|
1
|
|
|
|
|
40
|
return %data; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |