| 1 | # | ||||||||||||||||||||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | package Rex::Inventory::Proc::Cpuinfo; | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 2 | ▶ | use v5.14.4; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 2 | our $VERSION = '1.16.1'; # VERSION | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 2 | ▶ | use Rex::Commands::File; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 2 | ▶ | use Rex::Commands::Fs; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 2 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||
| 17 | 2 | my $that = shift; | |||||||||||||||||||
| 18 | 2 | ▶ | my $proto = ref($that) || $that; | ||||||||||||||||||
|
Condition33%1/3
ref $that || $that
MC/DC0%0/2
ref $that || $that
ref $that
$that
Truth table33%1/3
A || B
A= ref $thatB= $that
| |||||||||||||||||||||
| 19 | 2 | my $self = {@_}; | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 2 | bless( $self, $proto ); | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 2 | return $self; | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 2 | ▶ | sub get { | ||||||||||||||||||
|
Subroutine
get: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||
| 27 | 2 | my ($self) = @_; | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 2 | my @ret; | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 2 | ▶ | if ( is_readable('/proc/cpuinfo') ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 2 | my @cpuinfo = split /\n/, cat "/proc/cpuinfo"; | |||||||||||||||||||
| 34 | 2 | chomp @cpuinfo; | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 2 | my $proc = 0; | |||||||||||||||||||
| 37 | 2 | for my $line (@cpuinfo) { | |||||||||||||||||||
| 38 | 700 | ▶ | next if $line =~ qr{^$}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 676 | my ( $key, $val ) = split /\s*:\s*/, $line, 2; | |||||||||||||||||||
| 40 | 676 | ▶ | if ( $key eq "processor" ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 41 | 26 | $proc = $val; | |||||||||||||||||||
| 42 | 26 | $ret[$proc] = {}; | |||||||||||||||||||
| 43 | 26 | next; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 650 | $ret[$proc]->{$key} = $val; | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | else { | ||||||||||||||||||||
| 50 | 0 | Rex::Logger::info( 'Cannot read /proc/cpuinfo', 'warn' ); | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 2 | return \@ret; | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 2 | 1; | |||||||||||||||||||