fix(brocade/snmp): hardware mode - missing status (#2845)
This commit is contained in:
parent
c9b47b1d48
commit
ec0aa833fe
|
@ -29,9 +29,9 @@ sub set_system {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan)$';
|
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan)$';
|
||||||
|
|
||||||
$self->{cb_hook2} = 'snmp_execute';
|
$self->{cb_hook2} = 'snmp_execute';
|
||||||
|
|
||||||
$self->{thresholds} = {
|
$self->{thresholds} = {
|
||||||
sensor => [
|
sensor => [
|
||||||
['unknown', 'UNKNOWN'],
|
['unknown', 'UNKNOWN'],
|
||||||
|
@ -49,7 +49,7 @@ sub set_system {
|
||||||
['absent', 'OK']
|
['absent', 'OK']
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
$self->{components_path} = 'network::brocade::snmp::mode::components';
|
$self->{components_path} = 'network::brocade::snmp::mode::components';
|
||||||
$self->{components_module} = ['switch', 'sensor'];
|
$self->{components_module} = ['switch', 'sensor'];
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ my $mapping = {
|
||||||
swSensorType => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.2', map => \%map_type },
|
swSensorType => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.2', map => \%map_type },
|
||||||
swSensorStatus => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.3', map => \%map_status },
|
swSensorStatus => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.3', map => \%map_status },
|
||||||
swSensorValue => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.4' },
|
swSensorValue => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.4' },
|
||||||
swSensorInfo => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.5' },
|
swSensorInfo => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.5' }
|
||||||
};
|
};
|
||||||
my $oid_swSensorEntry = '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1';
|
my $oid_swSensorEntry = '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1';
|
||||||
|
|
||||||
|
@ -154,28 +154,40 @@ sub check {
|
||||||
next if ($oid !~ /^$mapping->{swSensorStatus}->{oid}\.(.*)$/);
|
next if ($oid !~ /^$mapping->{swSensorStatus}->{oid}\.(.*)$/);
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_swSensorEntry}, instance => $instance);
|
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_swSensorEntry}, instance => $instance);
|
||||||
|
|
||||||
next if ($self->check_filter(section => 'sensor', instance => $instance));
|
next if ($self->check_filter(section => 'sensor', instance => $instance));
|
||||||
next if ($result->{swSensorStatus} =~ /absent/i &&
|
next if ($result->{swSensorStatus} =~ /absent/i &&
|
||||||
$self->absent_problem(section => 'sensor', instance => $instance));
|
$self->absent_problem(section => 'sensor', instance => $instance));
|
||||||
|
|
||||||
$result->{swSensorInfo} = centreon::plugins::misc::trim($result->{swSensorInfo});
|
$result->{swSensorInfo} = centreon::plugins::misc::trim($result->{swSensorInfo});
|
||||||
$self->{components}->{sensor}->{total}++;
|
$self->{components}->{sensor}->{total}++;
|
||||||
$self->{output}->output_add(long_msg => sprintf("%s sensor '%s' status is '%s' [instance = %s]",
|
$self->{output}->output_add(
|
||||||
$result->{swSensorType}, $result->{swSensorInfo}, $result->{swSensorStatus}, $instance));
|
long_msg => sprintf(
|
||||||
|
"%s sensor '%s' status is '%s' [instance = %s]",
|
||||||
|
$result->{swSensorType}, $result->{swSensorInfo}, $result->{swSensorStatus}, $instance
|
||||||
|
)
|
||||||
|
);
|
||||||
my $exit = $self->get_severity(section => 'sensor', value => $result->{swSensorStatus});
|
my $exit = $self->get_severity(section => 'sensor', value => $result->{swSensorStatus});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(
|
||||||
short_msg => sprintf("%s sensor '%s' status is '%s'", $result->{swSensorType}, $result->{swSensorInfo}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf("%s sensor '%s' status is '%s'", $result->{swSensorType}, $result->{swSensorInfo}, $result->{swSensorStatus})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result->{swSensorValue} > 0 && $result->{swSensorType} ne 'power-supply') {
|
if ($result->{swSensorValue} > 0 && $result->{swSensorType} ne 'power-supply') {
|
||||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => $result->{swSensorType}, instance => $instance, value => $result->{swSensorValue});
|
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => $result->{swSensorType}, instance => $instance, value => $result->{swSensorValue});
|
||||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(severity => $exit2,
|
$self->{output}->output_add(
|
||||||
short_msg => sprintf("%s sensor '%s' is %s %s", $result->{swSensorType}, $result->{swSensorInfo}, $result->{swSensorValue},
|
severity => $exit2,
|
||||||
$map_unit{$result->{swSensorType}}));
|
short_msg => sprintf(
|
||||||
|
"%s sensor '%s' is %s %s",
|
||||||
|
$result->{swSensorType}, $result->{swSensorInfo}, $result->{swSensorValue},
|
||||||
|
$map_unit{$result->{swSensorType}}
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->perfdata_add(
|
$self->{output}->perfdata_add(
|
||||||
label => 'sensor', unit => $map_unit{$result->{swSensorType}},
|
label => 'sensor', unit => $map_unit{$result->{swSensorType}},
|
||||||
nlabel => 'hardware.sensor.' . $result->{swSensorType} . '.' . $map_unit{$result->{swSensorType}},
|
nlabel => 'hardware.sensor.' . $result->{swSensorType} . '.' . $map_unit{$result->{swSensorType}},
|
||||||
|
@ -199,19 +211,19 @@ my %map_oper_status = (1 => 'online', 2 => 'offline', 3 => 'testing', 4 => 'faul
|
||||||
|
|
||||||
my $mapping_global = {
|
my $mapping_global = {
|
||||||
swFirmwareVersion => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.6' },
|
swFirmwareVersion => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.6' },
|
||||||
swOperStatus => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.7', map => \%map_oper_status },
|
swOperStatus => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.7', map => \%map_oper_status }
|
||||||
};
|
};
|
||||||
my $oid_swSystem = '.1.3.6.1.4.1.1588.2.1.1.1.1';
|
my $oid_swSystem = '.1.3.6.1.4.1.1588.2.1.1.1.1';
|
||||||
|
|
||||||
sub load {
|
sub load {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
push @{$self->{request}}, { oid => $oid_swSystem, start => $mapping_global->{swFirmwareVersion}->{oid}, end => $mapping_global->{swOperStatus}->{oid} };
|
push @{$self->{request}}, { oid => $oid_swSystem, start => $mapping_global->{swFirmwareVersion}->{oid}, end => $mapping_global->{swOperStatus}->{oid} };
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check {
|
sub check {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "Checking switch");
|
$self->{output}->output_add(long_msg => "Checking switch");
|
||||||
$self->{components}->{switch} = {name => 'switch', total => 0, skip => 0};
|
$self->{components}->{switch} = {name => 'switch', total => 0, skip => 0};
|
||||||
return if ($self->check_filter(section => 'switch'));
|
return if ($self->check_filter(section => 'switch'));
|
||||||
|
@ -221,14 +233,21 @@ sub check {
|
||||||
|
|
||||||
$self->{components}->{switch}->{total}++;
|
$self->{components}->{switch}->{total}++;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("switch operational status is '%s' [firmware: %s].",
|
$self->{output}->output_add(
|
||||||
$result->{swOperStatus}, $result->{swFirmwareVersion}
|
long_msg => sprintf(
|
||||||
));
|
"switch operational status is '%s' [firmware: %s].",
|
||||||
|
$result->{swOperStatus}, $result->{swFirmwareVersion}
|
||||||
|
)
|
||||||
|
);
|
||||||
my $exit = $self->get_severity(section => 'switch', value => $result->{swOperStatus});
|
my $exit = $self->get_severity(section => 'switch', value => $result->{swOperStatus});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(
|
||||||
short_msg => sprintf("switch operational status is '%s'",
|
severity => $exit,
|
||||||
$result->{swOperStatus}));
|
short_msg => sprintf(
|
||||||
|
"switch operational status is '%s'",
|
||||||
|
$result->{swOperStatus}
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue