line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Linux::Taskstats::Read; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
36704
|
use 5.008001; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
45
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
48
|
|
6
|
1
|
|
|
1
|
|
5
|
use Fcntl qw(O_RDONLY); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1220
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '6.01'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
## these are object members (and need to be cleaned up in DESTROY()) |
11
|
|
|
|
|
|
|
my %Fh = (); |
12
|
|
|
|
|
|
|
my %Ver = (); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my %Size = ( 3 => 268, |
15
|
|
|
|
|
|
|
4 => 276, |
16
|
|
|
|
|
|
|
6 => 316, ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my %Tmpl = (); |
19
|
|
|
|
|
|
|
$Tmpl{3} = 'S xx L C C xxxxxx QQQQQQQQ a32 C C xx xxxx LLLLL xxxx QQQQQQQQQQQQQQQQ'; |
20
|
|
|
|
|
|
|
$Tmpl{4} = $Tmpl{3}; |
21
|
|
|
|
|
|
|
$Tmpl{6} = $Tmpl{3} . 'QQQQQ'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my %Fields = (); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$Fields{3} = [ qw(version ac_exitcode |
26
|
|
|
|
|
|
|
ac_flag ac_nice |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
cpu_count cpu_delay_total |
29
|
|
|
|
|
|
|
blkio_count blkio_delay_total |
30
|
|
|
|
|
|
|
swapin_count swapin_delay_total |
31
|
|
|
|
|
|
|
cpu_run_real_total cpu_run_virtual_total |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
ac_comm |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
ac_sched |
36
|
|
|
|
|
|
|
ac_pad |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
ac_uid ac_gid |
39
|
|
|
|
|
|
|
ac_pid ac_ppid |
40
|
|
|
|
|
|
|
ac_btime |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
ac_etime ac_utime ac_stime |
43
|
|
|
|
|
|
|
ac_minflt ac_majflt |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
coremem virtmem hiwater_rss hiwater_vm |
46
|
|
|
|
|
|
|
read_char write_char read_syscalls write_syscalls |
47
|
|
|
|
|
|
|
read_bytes write_bytes cancelled_write_bytes) ]; |
48
|
|
|
|
|
|
|
$Fields{4} = $Fields{3}; |
49
|
|
|
|
|
|
|
@{$Fields{6}} = (@{$Fields{3}}, qw(nvcsw nivcsw |
50
|
|
|
|
|
|
|
ac_utimescaled ac_stimescaled |
51
|
|
|
|
|
|
|
cpu_scaled_run_real_total)); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub new { |
54
|
3
|
|
|
3
|
1
|
45
|
my $class = shift; |
55
|
3
|
|
|
|
|
9
|
my %args = @_; |
56
|
3
|
|
|
|
|
8
|
my $self = bless \(my $fake), $class; ## an inside-out module |
57
|
|
|
|
|
|
|
|
58
|
3
|
50
|
33
|
|
|
22
|
$Ver{$self} = ($args{'-ver'} || $args{'-version'}) |
59
|
|
|
|
|
|
|
or die "'-version' parameter required\n"; |
60
|
|
|
|
|
|
|
|
61
|
3
|
50
|
|
|
|
7
|
$self->open($args{'-file'}) if $args{'-file'}; |
62
|
|
|
|
|
|
|
|
63
|
3
|
|
|
|
|
10
|
return $self; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub open { |
67
|
3
|
|
|
3
|
1
|
8
|
my $self = shift; |
68
|
3
|
|
|
|
|
5
|
my $file = shift; |
69
|
|
|
|
|
|
|
|
70
|
3
|
50
|
33
|
|
|
132
|
unless( -f $file && -r _ ) { |
71
|
0
|
|
|
|
|
0
|
die "File '$file' is not a file or is not readable.\n"; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
3
|
50
|
|
|
|
117
|
sysopen($Fh{$self}, $file, O_RDONLY) |
75
|
|
|
|
|
|
|
or die "Could not open file '$file': $!\n"; |
76
|
|
|
|
|
|
|
|
77
|
3
|
|
|
|
|
8
|
return 1; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub read { |
81
|
17
|
|
|
17
|
1
|
101
|
my $self = shift; |
82
|
|
|
|
|
|
|
|
83
|
17
|
100
|
|
|
|
197
|
sysread($Fh{$self}, my $rec, $Size{$Ver{$self}}, 0) |
84
|
|
|
|
|
|
|
or return; |
85
|
|
|
|
|
|
|
|
86
|
16
|
|
|
|
|
26
|
my %rec = (); |
87
|
16
|
|
|
|
|
124
|
@rec{@{$Fields{$Ver{$self}}}} = unpack($Tmpl{$Ver{$self}}, $rec); |
|
16
|
|
|
|
|
311
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
## some cleaning |
90
|
16
|
|
|
|
|
136
|
$rec{ac_comm} =~ s/\0//g; |
91
|
|
|
|
|
|
|
|
92
|
16
|
|
|
|
|
44
|
return \%rec; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub read_raw { |
96
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
1
|
50
|
|
|
|
18
|
sysread($Fh{$self}, my $rec, $Size{$Ver{$self}}, 0) |
99
|
|
|
|
|
|
|
or return; |
100
|
|
|
|
|
|
|
|
101
|
1
|
|
|
|
|
3
|
return $rec; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub close { |
105
|
3
|
50
|
|
3
|
1
|
45
|
CORE::close($Fh{$_[0]}) if $Fh{$_[0]}; |
106
|
3
|
|
|
|
|
14
|
delete $Fh{$_[0]}; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub version { |
110
|
1
|
|
|
1
|
1
|
12
|
return $Ver{$_[0]}; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub size { |
114
|
1
|
|
|
1
|
1
|
8
|
return $Size{$Ver{$_[0]}}; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub fields { |
118
|
1
|
|
|
1
|
1
|
3
|
return @{ $Fields{$Ver{$_[0]}} }; |
|
1
|
|
|
|
|
18
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub template { |
122
|
1
|
|
|
1
|
1
|
770
|
return $Tmpl{$Ver{$_[0]}}; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub DESTROY { |
126
|
3
|
|
|
3
|
|
990
|
my $self = $_[0]; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
## delete any members here |
129
|
3
|
|
|
|
|
8
|
delete $Fh{$self}; |
130
|
3
|
|
|
|
|
7
|
delete $Ver{$self}; |
131
|
|
|
|
|
|
|
|
132
|
3
|
|
|
|
|
14
|
my $super = $self->can("SUPER::DESTROY"); |
133
|
3
|
50
|
|
|
|
120
|
goto &$super if $super; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
1; |
137
|
|
|
|
|
|
|
__END__ |