mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 07:34:35 +02:00
add dlink hardware
This commit is contained in:
parent
046192a8a6
commit
e599f32b33
@ -23,70 +23,147 @@ package network::dlink::standard::snmp::mode::components::fan;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
my %map_states = (
|
my $map_status_equipment = {
|
||||||
0 => 'other',
|
0 => 'other', 1 => 'working',
|
||||||
1 => 'working',
|
2 => 'fail', 3 => 'speed-0',
|
||||||
2 => 'fail',
|
4 => 'speed-low', 5 => 'speed-middle',
|
||||||
3 => 'speed-0',
|
6 => 'speed-high'
|
||||||
4 => 'speed-low',
|
};
|
||||||
5 => 'speed-middle',
|
my $map_status = {
|
||||||
6 => 'speed-high',
|
1 => 'ok', 2 => 'fault'
|
||||||
);
|
};
|
||||||
|
|
||||||
# In MIB 'env_mib.mib'
|
my $mapping_equipment = {
|
||||||
my $mapping = {
|
swFanStatus => { oid => '.1.3.6.1.4.1.171.12.11.1.7.1.3', map => $map_status_equipment },
|
||||||
swFanStatus => { oid => '.1.3.6.1.4.1.171.12.11.1.7.1.3', map => \%map_states },
|
swFanSpeed => { oid => '.1.3.6.1.4.1.171.12.11.1.7.1.6' }
|
||||||
swFanSpeed => { oid => '.1.3.6.1.4.1.171.12.11.1.7.1.6' },
|
|
||||||
};
|
};
|
||||||
my $oid_swFanEntry = '.1.3.6.1.4.1.171.12.11.1.7.1';
|
my $oid_swFanEntry = '.1.3.6.1.4.1.171.12.11.1.7.1';
|
||||||
|
|
||||||
|
my $mapping_industrial = {
|
||||||
|
description => { oid => '.1.3.6.1.4.1.171.14.5.1.1.2.1.3' }, # dEntityExtEnvFanDescr
|
||||||
|
status => { oid => '.1.3.6.1.4.1.171.14.5.1.1.2.1.4', map => $map_status } # dEntityExtEnvFanStatus
|
||||||
|
};
|
||||||
|
my $oid_dEntityExtEnvFanEntry = '.1.3.6.1.4.1.171.14.5.1.1.2.1';
|
||||||
|
|
||||||
|
my $mapping_common = {
|
||||||
|
description => { oid => '.1.3.6.1.4.1.171.17.5.1.1.2.1.3' }, # esEntityExtEnvFanDescr
|
||||||
|
status => { oid => '.1.3.6.1.4.1.171.17.5.1.1.2.1.4', map => $map_status } # esEntityExtEnvFanStatus
|
||||||
|
};
|
||||||
|
my $oid_esEntityExtEnvFanEntry = '.1.3.6.1.4.1.171.17.5.1.1.2.1';
|
||||||
|
|
||||||
sub load {
|
sub load {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
push @{$self->{request}}, { oid => $oid_swFanEntry };
|
push @{$self->{request}},
|
||||||
|
{ oid => $oid_swFanEntry, start => $mapping_equipment->{swFanStatus}->{oid} },
|
||||||
|
{ oid => $oid_dEntityExtEnvFanEntry, start => $mapping_industrial->{description}->{oid} },
|
||||||
|
{ oid => $oid_esEntityExtEnvFanEntry, start => $mapping_common->{description}->{oid} }
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check {
|
sub check_fan_equipment {
|
||||||
my ($self) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "Checking fans");
|
|
||||||
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
|
|
||||||
return if ($self->check_filter(section => 'fan'));
|
|
||||||
|
|
||||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_swFanEntry}})) {
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_swFanEntry}})) {
|
||||||
next if ($oid !~ /^$mapping->{swFanStatus}->{oid}\.(.*)$/);
|
next if ($oid !~ /^$mapping_equipment->{swFanStatus}->{oid}\.(\d+)\.(\d+)$/);
|
||||||
my $instance = $1;
|
my ($unit_id, $fan_id) = ($1, $2);
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_swFanEntry}, instance => $instance);
|
my $instance = $1 . '.' . $2;
|
||||||
|
my $result = $self->{snmp}->map_instance(mapping => $mapping_equipment, results => $self->{results}->{$oid_swFanEntry}, instance => $instance);
|
||||||
|
|
||||||
|
my $description = 'unit' . $unit_id . ':fan' . $fan_id;
|
||||||
next if ($self->check_filter(section => 'fan', instance => $instance));
|
next if ($self->check_filter(section => 'fan', instance => $instance));
|
||||||
$self->{components}->{fan}->{total}++;
|
$self->{components}->{fan}->{total}++;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("fan '%s' status is %s [speed = %s].",
|
$self->{output}->output_add(
|
||||||
$instance, $result->{swFanStatus}, $result->{swFanSpeed}
|
long_msg => sprintf(
|
||||||
));
|
"fan '%s' status is %s [instance: %s, speed: %s]",
|
||||||
|
$description,
|
||||||
|
$result->{swFanStatus},
|
||||||
|
$instance,
|
||||||
|
$result->{swFanSpeed}
|
||||||
|
)
|
||||||
|
);
|
||||||
my $exit = $self->get_severity(section => 'fan', value => $result->{swFanStatus});
|
my $exit = $self->get_severity(section => 'fan', value => $result->{swFanStatus});
|
||||||
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("fan '%s' status is %s",
|
severity => $exit,
|
||||||
$instance, $result->{swFanStatus}));
|
short_msg => sprintf(
|
||||||
|
"fan '%s' status is %s",
|
||||||
|
$description, $result->{swFanStatus}
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined($result->{swFanSpeed})) {
|
if (defined($result->{swFanSpeed})) {
|
||||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{swFanSpeed});
|
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{swFanSpeed});
|
||||||
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("fan '%s' speed is %s rpm", $instance, $result->{swFanSpeed}));
|
severity => $exit2,
|
||||||
|
short_msg => sprintf(
|
||||||
|
"fan '%s' speed is %s rpm",
|
||||||
|
$description,
|
||||||
|
$result->{swFanSpeed}
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$self->{output}->perfdata_add(
|
$self->{output}->perfdata_add(
|
||||||
label => "fan", unit => 'rpm',
|
unit => 'rpm',
|
||||||
nlabel => 'hardware.fan.speed.rpm',
|
nlabel => 'hardware.fan.speed.rpm',
|
||||||
instances => $instance,
|
instances => ['unit' . $unit_id, 'fan' . $fan_id],
|
||||||
value => $result->{swFanSpeed},
|
value => $result->{swFanSpeed},
|
||||||
warning => $warn,
|
warning => $warn,
|
||||||
critical => $crit, min => 0
|
critical => $crit,
|
||||||
|
min => 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub check_fan {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $options{entry} }})) {
|
||||||
|
next if ($oid !~ /^$options{mapping}->{status}->{oid}\.(\d+)\.(\d+)$/);
|
||||||
|
my ($unit_id, $fan_id) = ($1, $2);
|
||||||
|
my $instance = $1 . '.' . $2;
|
||||||
|
my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{ $options{entry} }, instance => $instance);
|
||||||
|
|
||||||
|
my $description = 'unit' . $unit_id . ':fan' . $fan_id;
|
||||||
|
next if ($self->check_filter(section => 'fan', instance => $instance));
|
||||||
|
$self->{components}->{fan}->{total}++;
|
||||||
|
|
||||||
|
$self->{output}->output_add(
|
||||||
|
long_msg => sprintf(
|
||||||
|
"fan '%s' status is '%s' [instance: %s, description: %s]",
|
||||||
|
$description,
|
||||||
|
$result->{status},
|
||||||
|
$instance,
|
||||||
|
$result->{description}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
my $exit = $self->get_severity(section => 'fan', value => $result->{status});
|
||||||
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => $exit,
|
||||||
|
short_msg => sprintf(
|
||||||
|
"fan '%s' status is '%s'",
|
||||||
|
$description, $result->{status}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
$self->{output}->output_add(long_msg => 'checking fans');
|
||||||
|
$self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 };
|
||||||
|
return if ($self->check_filter(section => 'fan'));
|
||||||
|
|
||||||
|
check_fan_equipment($self);
|
||||||
|
check_fan($self, entry => $oid_dEntityExtEnvFanEntry, mapping => $mapping_industrial);
|
||||||
|
check_fan($self, entry => $oid_esEntityExtEnvFanEntry, mapping => $mapping_common);
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -22,54 +22,87 @@ package network::dlink::standard::snmp::mode::components::psu;
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
|
||||||
my %map_states = (
|
my $map_status_equipment = {
|
||||||
0 => 'other',
|
0 => 'other', 1 => 'lowVoltage', 2 => 'overCurrent',
|
||||||
1 => 'lowVoltage',
|
3 => 'working', 4 => 'fail', 5 => 'connect',
|
||||||
2 => 'overCurrent',
|
6 => 'disconnect'
|
||||||
3 => 'working',
|
|
||||||
4 => 'fail',
|
|
||||||
5 => 'connect',
|
|
||||||
6 => 'disconnect',
|
|
||||||
);
|
|
||||||
|
|
||||||
# In MIB 'equipment.mib'
|
|
||||||
my $mapping = {
|
|
||||||
swPowerStatus => { oid => '.1.3.6.1.4.1.171.12.11.1.6.1.3', map => \%map_states },
|
|
||||||
};
|
};
|
||||||
my $oid_swPowerEntry = '.1.3.6.1.4.1.171.12.11.1.6.1';
|
my $map_status = {
|
||||||
|
1 => 'inOperation', 2 => 'failed', 3 => 'empty'
|
||||||
|
};
|
||||||
|
|
||||||
|
my $mapping_equipment = {
|
||||||
|
status => { oid => '.1.3.6.1.4.1.171.12.11.1.6.1.3', map => $map_status_equipment } # swPowerStatus
|
||||||
|
};
|
||||||
|
my $mapping_industrial = {
|
||||||
|
description => { oid => '.1.3.6.1.4.1.171.14.5.1.1.3.1.3' }, # dEntityExtEnvPowerDescr
|
||||||
|
status => { oid => '.1.3.6.1.4.1.171.14.5.1.1.3.1.6', map => $map_status } # dEntityExtEnvPowerStatus
|
||||||
|
};
|
||||||
|
my $oid_dEntityExtEnvPowerEntry = '.1.3.6.1.4.1.171.14.5.1.1.3.1';
|
||||||
|
|
||||||
|
my $mapping_common = {
|
||||||
|
description => { oid => '.1.3.6.1.4.1.171.17.5.1.1.3.1.3' }, # esEntityExtEnvPowerDescr
|
||||||
|
status => { oid => '.1.3.6.1.4.1.171.17.5.1.1.3.1.6', map => $map_status } # esEntityExtEnvPowerStatus
|
||||||
|
};
|
||||||
|
my $oid_esEntityExtEnvPowerEntry = '.1.3.6.1.4.1.171.17.5.1.1.3.1';
|
||||||
|
|
||||||
sub load {
|
sub load {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
push @{$self->{request}}, { oid => $oid_swPowerEntry };
|
push @{$self->{request}},
|
||||||
|
{ oid => $mapping_equipment->{status}->{oid} },
|
||||||
|
{ oid => $oid_dEntityExtEnvPowerEntry, start => $mapping_industrial->{description}->{oid} },
|
||||||
|
{ oid => $oid_esEntityExtEnvPowerEntry, start => $mapping_common->{description}->{oid} }
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_psu {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $options{entry} }})) {
|
||||||
|
next if ($oid !~ /^$options{mapping}->{status}->{oid}\.(\d+)\.(\d+)$/);
|
||||||
|
my ($unit_id, $psu_id) = ($1, $2);
|
||||||
|
my $instance = $1 . '.' . $2;
|
||||||
|
my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{ $options{entry} }, instance => $instance);
|
||||||
|
|
||||||
|
my $description = 'unit' . $unit_id . ':psu' . $psu_id;
|
||||||
|
next if ($self->check_filter(section => 'psu', instance => $instance));
|
||||||
|
$self->{components}->{psu}->{total}++;
|
||||||
|
|
||||||
|
$self->{output}->output_add(
|
||||||
|
long_msg => sprintf(
|
||||||
|
"power supply '%s' status is '%s' [instance: %s, description: %s]",
|
||||||
|
$description,
|
||||||
|
$result->{status},
|
||||||
|
$instance,
|
||||||
|
defined($result->{description}) ? centreon::plugins::misc::trim($result->{description}) : '-'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
my $exit = $self->get_severity(section => 'psu', value => $result->{status});
|
||||||
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => $exit,
|
||||||
|
short_msg => sprintf(
|
||||||
|
"Power supply '%s' status is '%s'",
|
||||||
|
$description, $result->{status}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check {
|
sub check {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "Checking power supplies");
|
$self->{output}->output_add(long_msg => 'checking power supplies');
|
||||||
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
|
$self->{components}->{psu} = { name => 'psu', total => 0, skip => 0 };
|
||||||
return if ($self->check_filter(section => 'psu'));
|
return if ($self->check_filter(section => 'psu'));
|
||||||
|
|
||||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_swPowerEntry}})) {
|
check_psu($self, entry => $mapping_equipment->{status}->{oid}, mapping => $mapping_equipment);
|
||||||
next if ($oid !~ /^$mapping->{swPowerStatus}->{oid}\.(.*)$/);
|
check_psu($self, entry => $oid_dEntityExtEnvPowerEntry, mapping => $mapping_industrial);
|
||||||
my $instance = $1;
|
check_psu($self, entry => $oid_esEntityExtEnvPowerEntry, mapping => $mapping_common);
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_swPowerEntry}, instance => $instance);
|
|
||||||
|
|
||||||
next if ($self->check_filter(section => 'psu', instance => $instance));
|
|
||||||
$self->{components}->{psu}->{total}++;
|
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s.",
|
|
||||||
$instance, $result->{swPowerStatus}
|
|
||||||
));
|
|
||||||
my $exit = $self->get_severity(section => 'psu', value => $result->{swPowerStatus});
|
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
|
||||||
short_msg => sprintf("Power supply '%s' status is %s",
|
|
||||||
$instance, $result->{swPowerStatus}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
@ -23,43 +23,73 @@ package network::dlink::standard::snmp::mode::components::temperature;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
# In MIB 'env_mib.mib'
|
my $map_status = {
|
||||||
my $mapping = {
|
1 => 'ok', 2 => 'abnormal'
|
||||||
swTemperatureCurrent => { oid => '.1.3.6.1.4.1.171.12.11.1.8.1.2' },
|
|
||||||
};
|
};
|
||||||
my $oid_swTemperatureEntry = '.1.3.6.1.4.1.171.12.11.1.8.1';
|
|
||||||
|
my $mapping_equipment = {
|
||||||
|
swTemperatureCurrent => { oid => '.1.3.6.1.4.1.171.12.11.1.8.1.2' }
|
||||||
|
};
|
||||||
|
my $mapping_industrial = {
|
||||||
|
description => { oid => '.1.3.6.1.4.1.171.14.5.1.1.1.1.3' }, # dEntityExtEnvTempDescr
|
||||||
|
current => { oid => '.1.3.6.1.4.1.171.14.5.1.1.1.1.4' }, # dEntityExtEnvTempCurrent
|
||||||
|
threshold_low => { oid => '.1.3.6.1.4.1.171.14.5.1.1.1.1.5' }, # dEntityExtEnvTempThresholdLow
|
||||||
|
threshold_high => { oid => '.1.3.6.1.4.1.171.14.5.1.1.1.1.6' }, # dEntityExtEnvTempThresholdHigh
|
||||||
|
status => { oid => '.1.3.6.1.4.1.171.14.5.1.1.1.1.7', map => $map_status } # dEntityExtEnvTempStatus
|
||||||
|
};
|
||||||
|
my $oid_dEntityExtEnvTempEntry = '.1.3.6.1.4.1.171.14.5.1.1.1.1';
|
||||||
|
|
||||||
|
my $mapping_common = {
|
||||||
|
description => { oid => '.1.3.6.1.4.1.171.17.5.1.1.1.1.3' }, # esEntityExtEnvTempDescr
|
||||||
|
current => { oid => '.1.3.6.1.4.1.171.17.5.1.1.1.1.4' }, # esEntityExtEnvTempCurrent
|
||||||
|
threshold_low => { oid => '.1.3.6.1.4.1.171.17.5.1.1.1.1.5' }, # esEntityExtEnvTempThresholdLow
|
||||||
|
threshold_high => { oid => '.1.3.6.1.4.1.171.17.5.1.1.1.1.6' }, # esEntityExtEnvTempThresholdHigh
|
||||||
|
status => { oid => '.1.3.6.1.4.1.171.17.5.1.1.1.1.7', map => $map_status } # esEntityExtEnvTempStatus
|
||||||
|
};
|
||||||
|
my $oid_esEntityExtEnvTempEntry = '.1.3.6.1.4.1.171.17.5.1.1.1.1';
|
||||||
|
|
||||||
sub load {
|
sub load {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
push @{$self->{request}}, { oid => $oid_swTemperatureEntry };
|
push @{$self->{request}},
|
||||||
|
{ oid => $mapping_equipment->{swTemperatureCurrent}->{oid} },
|
||||||
|
{ oid => $oid_dEntityExtEnvTempEntry, start => $mapping_industrial->{description}->{oid} },
|
||||||
|
{ oid => $oid_esEntityExtEnvTempEntry, start => $mapping_common->{description}->{oid} }
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check {
|
sub check_temperature_equipment {
|
||||||
my ($self) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "Checking temperatures");
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $mapping_equipment->{swTemperatureCurrent}->{oid} }})) {
|
||||||
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
|
$oid =~ /^$mapping_equipment->{swTemperatureCurrent}->{oid}\.(.*)$/;
|
||||||
return if ($self->check_filter(section => 'temperature'));
|
|
||||||
|
|
||||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_swTemperatureEntry}})) {
|
|
||||||
next if ($oid !~ /^$mapping->{swTemperatureCurrent}->{oid}\.(.*)$/);
|
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_swTemperatureEntry}, instance => $instance);
|
my $result = $self->{snmp}->map_instance(mapping => $mapping_equipment, results => $self->{results}->{ $mapping_equipment->{swTemperatureCurrent}->{oid} }, instance => $instance);
|
||||||
|
|
||||||
next if ($self->check_filter(section => 'temperature', instance => $instance));
|
next if ($self->check_filter(section => 'temperature', instance => $instance));
|
||||||
$self->{components}->{temperature}->{total}++;
|
$self->{components}->{temperature}->{total}++;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("Temperature '%s' is %dC.",
|
$self->{output}->output_add(long_msg =>
|
||||||
$instance, $result->{swTemperatureCurrent}));
|
sprintf(
|
||||||
|
"temperature '%s' is %dC.",
|
||||||
|
$instance,
|
||||||
|
$result->{swTemperatureCurrent}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{swTemperatureCurrent});
|
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{swTemperatureCurrent});
|
||||||
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("Temperature '%s' is %s degree centigrade", $instance, $result->{swTemperatureCurrent}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf(
|
||||||
|
"Temperature '%s' is %s degree centigrade",
|
||||||
|
$instance,
|
||||||
|
$result->{swTemperatureCurrent}
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$self->{output}->perfdata_add(
|
$self->{output}->perfdata_add(
|
||||||
label => "temp", unit => 'C',
|
unit => 'C',
|
||||||
nlabel => 'hardware.temperature.celsius',
|
nlabel => 'hardware.temperature.celsius',
|
||||||
instances => $instance,
|
instances => $instance,
|
||||||
value => $result->{swTemperatureCurrent},
|
value => $result->{swTemperatureCurrent},
|
||||||
@ -69,4 +99,85 @@ sub check {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub check_temperature {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $options{entry} }})) {
|
||||||
|
next if ($oid !~ /^$options{mapping}->{status}->{oid}\.(\d+)\.(\d+)$/);
|
||||||
|
my ($unit_id, $temp_id) = ($1, $2);
|
||||||
|
my $instance = $1 . '.' . $2;
|
||||||
|
my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{ $options{entry} }, instance => $instance);
|
||||||
|
|
||||||
|
my $description = 'unit' . $unit_id . ':temp' . $temp_id;
|
||||||
|
next if ($self->check_filter(section => 'temperature', instance => $instance));
|
||||||
|
$self->{components}->{temperature}->{total}++;
|
||||||
|
|
||||||
|
$self->{output}->output_add(
|
||||||
|
long_msg => sprintf(
|
||||||
|
"temperature '%s' status is '%s' [instance: %s, description: %s, current: %s]",
|
||||||
|
$description,
|
||||||
|
$result->{status},
|
||||||
|
$instance,
|
||||||
|
$result->{description},
|
||||||
|
$result->{current}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
my $exit = $self->get_severity(section => 'temperature', value => $result->{status});
|
||||||
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => $exit,
|
||||||
|
short_msg => sprintf(
|
||||||
|
"temperature '%s' status is %s",
|
||||||
|
$description, $result->{status}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
next if (!defined($result->{current}));
|
||||||
|
|
||||||
|
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{current});
|
||||||
|
if ($checked == 0) {
|
||||||
|
my $warn_th = '';
|
||||||
|
my $crit_th = defined($result->{threshold_high}) && $result->{threshold_high} =~ /\d/ ? $result->{threshold_high} : '';
|
||||||
|
$crit_th = $result->{threshold_low} . ':' . $crit_th if (defined($result->{threshold_low}) && $result->{threshold_low} =~ /\d/);
|
||||||
|
|
||||||
|
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th);
|
||||||
|
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th);
|
||||||
|
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
|
||||||
|
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => $exit2,
|
||||||
|
short_msg => sprintf(
|
||||||
|
"temperature '%s' is %s degree centigrate",
|
||||||
|
$description,
|
||||||
|
$result->{current}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$self->{output}->perfdata_add(
|
||||||
|
unit => 'C',
|
||||||
|
nlabel => 'hardware.temperature.celsius',
|
||||||
|
instances => ['unit' . $unit_id, 'temp' . $temp_id],
|
||||||
|
value => $result->{current},
|
||||||
|
warning => $warn,
|
||||||
|
critical => $crit
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
$self->{output}->output_add(long_msg => 'checking temperatures');
|
||||||
|
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
|
||||||
|
return if ($self->check_filter(section => 'temperature'));
|
||||||
|
|
||||||
|
check_temperature_equipment($self);
|
||||||
|
check_temperature($self, entry => $oid_dEntityExtEnvTempEntry, mapping => $mapping_industrial);
|
||||||
|
check_temperature($self, entry => $oid_esEntityExtEnvTempEntry, mapping => $mapping_common);
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -34,6 +34,10 @@ sub set_system {
|
|||||||
|
|
||||||
$self->{thresholds} = {
|
$self->{thresholds} = {
|
||||||
psu => [
|
psu => [
|
||||||
|
['inOperation', 'OK'],
|
||||||
|
['failed', 'CRITICAL'],
|
||||||
|
['empty', 'OK'],
|
||||||
|
|
||||||
['connect', 'OK'],
|
['connect', 'OK'],
|
||||||
['working', 'OK'],
|
['working', 'OK'],
|
||||||
['other', 'UNKNOWN'],
|
['other', 'UNKNOWN'],
|
||||||
@ -43,6 +47,9 @@ sub set_system {
|
|||||||
['disconnect', 'WARNING']
|
['disconnect', 'WARNING']
|
||||||
],
|
],
|
||||||
fan => [
|
fan => [
|
||||||
|
['ok', 'OK'],
|
||||||
|
['fault', 'CRITICAL'],
|
||||||
|
|
||||||
['working', 'OK'],
|
['working', 'OK'],
|
||||||
['fail', 'CRITICAL'],
|
['fail', 'CRITICAL'],
|
||||||
['other', 'UNKNOWN'],
|
['other', 'UNKNOWN'],
|
||||||
@ -50,6 +57,10 @@ sub set_system {
|
|||||||
['speed-low', 'WARNING'],
|
['speed-low', 'WARNING'],
|
||||||
['speed-middle', 'OK'],
|
['speed-middle', 'OK'],
|
||||||
['speed-high', 'WARNING']
|
['speed-high', 'WARNING']
|
||||||
|
],
|
||||||
|
temperature => [
|
||||||
|
['ok', 'OK'],
|
||||||
|
['abnormal', 'CRITICAL']
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -66,7 +77,7 @@ sub snmp_execute {
|
|||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {});
|
$options{options}->add_options(arguments => {});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user