1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
package HP::Proliant::Component::CpuSubsystem::CLI;
our @ISA = qw(HP::Proliant::Component::CpuSubsystem);
use strict;
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
sub new {
my $class = shift;
my %params = @_;
my $self = {
runtime => $params{runtime},
rawdata => $params{rawdata},
cpus => [],
blacklisted => 0,
info => undef,
extendedinfo => undef,
};
bless $self, $class;
$self->init(%params);
return $self;
}
sub init {
my $self = shift;
my %params = @_;
my %tmpcpu = (
runtime => $params{runtime},
);
my $inblock = 0;
foreach (grep(/^server/, split(/\n/, $self->{rawdata}))) {
if (/Processor:\s+(\d+)/) {
$tmpcpu{cpqSeCpuUnitIndex} = $1;
$inblock = 1;
} elsif (/Name\s*:\s+(.+?)\s*$/) {
$tmpcpu{cpqSeCpuName} = $1;
} elsif (/Status\s*:\s+(.+?)\s*$/) {
$tmpcpu{cpqSeCpuStatus} = lc $1;
} elsif (/Socket\s*:\s+(.+?)\s*$/) {
$tmpcpu{cpqSeCpuSlot} = $1;
} elsif (/^server\s*$/) {
if ($inblock) {
$inblock = 0;
push(@{$self->{cpus}},
HP::Proliant::Component::CpuSubsystem::Cpu->new(%tmpcpu));
%tmpcpu = (
runtime => $params{runtime},
);
}
}
}
if ($inblock) {
push(@{$self->{cpus}},
HP::Proliant::Component::CpuSubsystem::Cpu->new(%tmpcpu));
}
}
1;
|