This commit is contained in:
Quentin Garnier 2014-11-13 18:17:19 +01:00
parent 364955cfa5
commit 4d07ea016a
4 changed files with 7 additions and 8 deletions

View File

@ -47,7 +47,7 @@ my %map_status = (
sub check {
my ($self) = @_;
$self->{components}->{fan} = {name => 'fans', total => 0};
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
$self->{output}->output_add(long_msg => "Checking fans");
return if ($self->check_exclude(section => 'fan'));

View File

@ -47,7 +47,7 @@ my %map_status = (
sub check {
my ($self) = @_;
$self->{components}->{psu} = {name => 'psus', total => 0};
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
$self->{output}->output_add(long_msg => "Checking power supplies");
return if ($self->check_exclude(section => 'psu'));

View File

@ -42,7 +42,7 @@ sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking temperatures");
$self->{components}->{temperature} = {name => 'temperatures', total => 0};
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
return if ($self->check_exclude(section => 'temperature'));
my $oid_sysChassisTempEntry = '.1.3.6.1.4.1.3375.2.1.3.2.3.2.1';
@ -59,7 +59,7 @@ sub check {
my $exit_code = $self->{perfdata}->threshold_check(value => $result->{$oid_sysChassisTempTemperature . '.' . $instance},
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{components}->{temperatures}->{total}++;
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(severity => $exit_code,long_msg => sprintf("temp_" . $instance . " is %.2f C", $result->{$oid_sysChassisTempTemperature . '.' . $instance}));
if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit_code,short_msg => sprintf("temp_" . $instance . " is %.2f C", $result->{$oid_sysChassisTempTemperature . '.' . $instance}));

View File

@ -101,15 +101,14 @@ sub run {
$self->{output}->option_exit();
}
my $total_components = 0;
my $display_by_component = '';
my $display_by_component_append = '';
foreach my $comp (sort(keys %{$self->{components}})) {
# Skipping short msg when no components
next if ($self->{components}->{$comp}->{total} == 0);
$total_components += $self->{components}->{$comp}->{total};
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . ' ' . $self->{components}->{$comp}->{name};
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $self->{components}->{$comp}->{skip} . ' ' . $self->{components}->{$comp}->{name};
$display_by_component_append = ', ';
}