line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# system::linux::cpuinfo Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::System::Linux::Cpuinfo; |
7
|
1
|
|
|
1
|
|
773
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
8
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use base qw(Metabrik::File::Text); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
424
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
attributes_default => { |
19
|
|
|
|
|
|
|
as_array => 1, |
20
|
|
|
|
|
|
|
strip_crlf => 1, |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
commands => { |
23
|
|
|
|
|
|
|
read => [ ], |
24
|
|
|
|
|
|
|
count_processors => [ ], |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub read { |
30
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $cpuinfo = '/proc/cpuinfo'; |
33
|
0
|
0
|
|
|
|
|
if (! -f $cpuinfo) { |
34
|
0
|
|
|
|
|
|
return $self->log->info("read: cpuinfo file [$cpuinfo] not found"); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
my $lines = $self->SUPER::read($cpuinfo) or return; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $current = 0; |
40
|
0
|
|
|
|
|
|
my @infos = (); |
41
|
0
|
|
|
|
|
|
for (@$lines) { |
42
|
0
|
|
|
|
|
|
my ($k, $v) = split(/\s*:\s*/, $_); |
43
|
0
|
0
|
|
|
|
|
if (! defined($v)) { # New line |
44
|
0
|
|
|
|
|
|
$current++; |
45
|
0
|
|
|
|
|
|
next; |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
|
$infos[$current]->{$k} = $v; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return \@infos; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub count_processors { |
54
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
55
|
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
my $infos = $self->read or return; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $count = 0; |
59
|
0
|
|
|
|
|
|
for my $this (@$infos) { |
60
|
0
|
0
|
|
|
|
|
if (exists($this->{processor})) { |
61
|
0
|
|
|
|
|
|
$count++; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
return $count; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |