| 1 |
package HP::Proliant::Component::TemperatureSubsystem::CLI; |
| 2 |
our @ISA = qw(HP::Proliant::Component::TemperatureSubsystem); |
| 3 |
|
| 4 |
use strict; |
| 5 |
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; |
| 6 |
|
| 7 |
sub new { |
| 8 |
my $class = shift; |
| 9 |
my %params = @_; |
| 10 |
my $self = { |
| 11 |
runtime => $params{runtime}, |
| 12 |
rawdata => $params{rawdata}, |
| 13 |
temperatures => [], |
| 14 |
blacklisted => 0, |
| 15 |
info => undef, |
| 16 |
extendedinfo => undef, |
| 17 |
}; |
| 18 |
bless $self, $class; |
| 19 |
$self->init(%params); |
| 20 |
return $self; |
| 21 |
} |
| 22 |
|
| 23 |
sub init { |
| 24 |
my $self = shift; |
| 25 |
my %params = @_; |
| 26 |
my $tempcnt = 1; |
| 27 |
foreach (grep(/^temp/, split(/\n/, $params{rawdata}))) { |
| 28 |
s/^temp\s*//g; |
| 29 |
if (/^#(\d+)\s+([\w_\/\-#]+)\s+(-*\d+)C\/(\d+)F\s+(\d+)C\/(\d+)F/) { |
| 30 |
my %params = (); |
| 31 |
$params{runtime} = $self->{runtime}; |
| 32 |
$params{cpqHeTemperatureChassis} = 1; |
| 33 |
$params{cpqHeTemperatureIndex} = $1; |
| 34 |
$params{cpqHeTemperatureLocale} = lc $2; |
| 35 |
$params{cpqHeTemperatureCelsius} = $3; |
| 36 |
$params{cpqHeTemperatureThresholdCelsius} = $5; |
| 37 |
$params{cpqHeTemperatureCondition} = 'unknown'; |
| 38 |
push(@{$self->{temperatures}}, |
| 39 |
HP::Proliant::Component::TemperatureSubsystem::Temperature->new( |
| 40 |
%params)); |
| 41 |
} elsif (/^#(\d+)\s+([\w_\/\-#]+)\s+\-\s+(\d+)C\/(\d+)F/) { |
| 42 |
# #3 CPU#2 - 0C/0F |
| 43 |
$self->trace(2, sprintf "skipping temperature %s", $_); |
| 44 |
} elsif (/^#(\d+)\s+([\w_\/\-#]+)\s+(\d+)C\/(\d+)F\s+\-/) { |
| 45 |
# #3 CPU#2 0C/0F - |
| 46 |
$self->trace(2, sprintf "skipping temperature %s", $_); |
| 47 |
} elsif (/^#(\d+)\s+([\w_\/\-#]+)\s+\-\s+\-/) { |
| 48 |
# #3 CPU#2 - - |
| 49 |
$self->trace(2, sprintf "skipping temperature %s", $_); |
| 50 |
} elsif (/^#(\d+)/) { |
| 51 |
$self->trace(0, sprintf "send this to lausser: %s", $_); |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
1; |