mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 07:34:35 +02:00
enh(supermicro/bmc): sensors mode - change how to get snmp values (#3345)
This commit is contained in:
parent
ff91f0b772
commit
0deeea61c9
@ -55,10 +55,6 @@ sub snmp_execute {
|
|||||||
$self->{option_results}->{add_name_instance} = 1;
|
$self->{option_results}->{add_name_instance} = 1;
|
||||||
|
|
||||||
$self->{snmp} = $options{snmp};
|
$self->{snmp} = $options{snmp};
|
||||||
$self->{results} = $self->{snmp}->get_multiple_table(
|
|
||||||
oids => $self->{request},
|
|
||||||
return_type => 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
@ -104,7 +100,6 @@ use warnings;
|
|||||||
use centreon::plugins::misc;
|
use centreon::plugins::misc;
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
sensorReading => { oid => '.1.3.6.1.4.1.21317.1.3.1.2' },
|
|
||||||
lncThreshold => { oid => '.1.3.6.1.4.1.21317.1.3.1.5' },
|
lncThreshold => { oid => '.1.3.6.1.4.1.21317.1.3.1.5' },
|
||||||
lcThreshold => { oid => '.1.3.6.1.4.1.21317.1.3.1.6' },
|
lcThreshold => { oid => '.1.3.6.1.4.1.21317.1.3.1.6' },
|
||||||
uncThreshold => { oid => '.1.3.6.1.4.1.21317.1.3.1.8' },
|
uncThreshold => { oid => '.1.3.6.1.4.1.21317.1.3.1.8' },
|
||||||
@ -112,11 +107,7 @@ my $mapping = {
|
|||||||
sensorIDString => { oid => '.1.3.6.1.4.1.21317.1.3.1.13' }
|
sensorIDString => { oid => '.1.3.6.1.4.1.21317.1.3.1.13' }
|
||||||
};
|
};
|
||||||
|
|
||||||
sub load {
|
sub load {}
|
||||||
my ($self) = @_;
|
|
||||||
|
|
||||||
push @{$self->{request}}, values(%$mapping);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub check {
|
sub check {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
@ -125,11 +116,26 @@ sub check {
|
|||||||
$self->{components}->{sensor} = { name => 'sensors', total => 0, skip => 0 };
|
$self->{components}->{sensor} = { name => 'sensors', total => 0, skip => 0 };
|
||||||
return if ($self->check_filter(section => 'sensor'));
|
return if ($self->check_filter(section => 'sensor'));
|
||||||
|
|
||||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}})) {
|
my $sensorReading = '.1.3.6.1.4.1.21317.1.3.1.2';
|
||||||
next if ($oid !~ /^$mapping->{sensorIDString}->{oid}\.(.*)$/);
|
my $snmp_result = $self->{snmp}->get_table(oid => $sensorReading);
|
||||||
my $instance = $1;
|
return if (scalar(keys %$snmp_result) <= 0);
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance);
|
|
||||||
|
|
||||||
|
my $instances = [];
|
||||||
|
foreach (keys %$snmp_result) {
|
||||||
|
push @$instances, $1 if (/^$sensorReading\.(.*)$/);
|
||||||
|
}
|
||||||
|
$self->{snmp}->load(
|
||||||
|
oids => [map($_->{oid}, values(%$mapping))],
|
||||||
|
instances => $instances
|
||||||
|
);
|
||||||
|
my $results = $self->{snmp}->get_leef();
|
||||||
|
|
||||||
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
|
||||||
|
next if ($oid !~ /^$sensorReading\.(.*)$/);
|
||||||
|
my $instance = $1;
|
||||||
|
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
|
||||||
|
|
||||||
|
$result->{sensorReading} = $snmp_result->{$oid};
|
||||||
$result->{sensorIDString} = centreon::plugins::misc::trim($result->{sensorIDString});
|
$result->{sensorIDString} = centreon::plugins::misc::trim($result->{sensorIDString});
|
||||||
next if ($result->{sensorIDString} eq '');
|
next if ($result->{sensorIDString} eq '');
|
||||||
next if ($result->{sensorReading} =~ /^0\.0+$/ && $result->{lncThreshold} =~ /^0\.0+$/);
|
next if ($result->{sensorReading} =~ /^0\.0+$/ && $result->{lncThreshold} =~ /^0\.0+$/);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user