mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-29 16:45:04 +02:00
(plugin) network::h3c::snmp - mode hardware skip high temperature (#4074)
This commit is contained in:
parent
ed1db76094
commit
d257b4b556
@ -40,7 +40,7 @@ my %map_default_status = (
|
|||||||
61 => 'rpsError',
|
61 => 'rpsError',
|
||||||
71 => 'moduleFaulty',
|
71 => 'moduleFaulty',
|
||||||
81 => 'sensorError',
|
81 => 'sensorError',
|
||||||
91 => 'hardwareFaulty',
|
91 => 'hardwareFaulty'
|
||||||
);
|
);
|
||||||
|
|
||||||
sub check {
|
sub check {
|
||||||
@ -51,7 +51,7 @@ sub check {
|
|||||||
return if ($self->check_filter(section => $options{component}));
|
return if ($self->check_filter(section => $options{component}));
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_default_status },
|
EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_default_status }
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach my $instance (sort $self->get_instance_class(class => { $options{component_class} => 1 })) {
|
foreach my $instance (sort $self->get_instance_class(class => { $options{component_class} => 1 })) {
|
||||||
@ -63,19 +63,25 @@ sub check {
|
|||||||
$self->absent_problem(section => $options{component}, instance => $instance);
|
$self->absent_problem(section => $options{component}, instance => $instance);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $name = '';
|
my $name = '';
|
||||||
$name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1);
|
$name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1);
|
||||||
$name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne '');
|
$name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne '');
|
||||||
$self->{components}->{$options{component}}->{total}++;
|
$self->{components}->{$options{component}}->{total}++;
|
||||||
$self->{output}->output_add(long_msg => sprintf("%s '%s' status is '%s' [instance = %s]",
|
$self->{output}->output_add(
|
||||||
ucfirst($options{component}), $name, $result->{EntityExtErrorStatus}, $instance));
|
long_msg => sprintf(
|
||||||
|
"%s '%s' status is '%s' [instance = %s]",
|
||||||
|
ucfirst($options{component}), $name, $result->{EntityExtErrorStatus}, $instance
|
||||||
|
)
|
||||||
|
);
|
||||||
my $exit = $self->get_severity(section => $options{component}, value => $result->{EntityExtErrorStatus});
|
my $exit = $self->get_severity(section => $options{component}, value => $result->{EntityExtErrorStatus});
|
||||||
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 '%s' status is '%s'", $options{component}, $name, $result->{EntityExtErrorStatus}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf("%s '%s' status is '%s'", $options{component}, $name, $result->{EntityExtErrorStatus})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -28,7 +28,7 @@ my %map_fan_status = (
|
|||||||
2 => 'normal',
|
2 => 'normal',
|
||||||
4 => 'entityAbsent',
|
4 => 'entityAbsent',
|
||||||
41 => 'fanError',
|
41 => 'fanError',
|
||||||
91 => 'hardwareFaulty',
|
91 => 'hardwareFaulty'
|
||||||
);
|
);
|
||||||
|
|
||||||
sub check {
|
sub check {
|
||||||
@ -39,7 +39,7 @@ sub check {
|
|||||||
return if ($self->check_filter(section => 'fan'));
|
return if ($self->check_filter(section => 'fan'));
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_fan_status },
|
EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_fan_status }
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach my $instance (sort $self->get_instance_class(class => { 7 => 1 })) {
|
foreach my $instance (sort $self->get_instance_class(class => { 7 => 1 })) {
|
||||||
@ -51,19 +51,25 @@ sub check {
|
|||||||
$self->absent_problem(section => 'fan', instance => $instance);
|
$self->absent_problem(section => 'fan', instance => $instance);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $name = '';
|
my $name = '';
|
||||||
$name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1);
|
$name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1);
|
||||||
$name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne '');
|
$name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne '');
|
||||||
$self->{components}->{fan}->{total}++;
|
$self->{components}->{fan}->{total}++;
|
||||||
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance = %s]",
|
$self->{output}->output_add(
|
||||||
$name, $result->{EntityExtErrorStatus}, $instance));
|
long_msg => sprintf(
|
||||||
|
"Fan '%s' status is '%s' [instance: %s]",
|
||||||
|
$name, $result->{EntityExtErrorStatus}, $instance
|
||||||
|
)
|
||||||
|
);
|
||||||
my $exit = $self->get_severity(section => 'fan', value => $result->{EntityExtErrorStatus});
|
my $exit = $self->get_severity(section => 'fan', value => $result->{EntityExtErrorStatus});
|
||||||
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'", $name, $result->{EntityExtErrorStatus}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf("Fan '%s' status is '%s'", $name, $result->{EntityExtErrorStatus})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -28,14 +28,14 @@ my %map_psu_status = (
|
|||||||
2 => 'normal',
|
2 => 'normal',
|
||||||
4 => 'entityAbsent',
|
4 => 'entityAbsent',
|
||||||
51 => 'psuError',
|
51 => 'psuError',
|
||||||
91 => 'hardwareFaulty',
|
91 => 'hardwareFaulty'
|
||||||
);
|
);
|
||||||
|
|
||||||
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 => 'power supplies', total => 0, skip => 0};
|
$self->{components}->{psu} = { name => 'power supplies', total => 0, skip => 0 };
|
||||||
return if ($self->check_filter(section => 'psu'));
|
return if ($self->check_filter(section => 'psu'));
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
@ -51,19 +51,25 @@ sub check {
|
|||||||
$self->absent_problem(section => 'psu', instance => $instance);
|
$self->absent_problem(section => 'psu', instance => $instance);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $name = '';
|
my $name = '';
|
||||||
$name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1);
|
$name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1);
|
||||||
$name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne '');
|
$name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne '');
|
||||||
$self->{components}->{psu}->{total}++;
|
$self->{components}->{psu}->{total}++;
|
||||||
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is '%s' [instance = %s]",
|
$self->{output}->output_add(
|
||||||
$name, $result->{EntityExtErrorStatus}, $instance));
|
long_msg => sprintf(
|
||||||
|
"Power supply '%s' status is '%s' [instance: %s]",
|
||||||
|
$name, $result->{EntityExtErrorStatus}, $instance
|
||||||
|
)
|
||||||
|
);
|
||||||
my $exit = $self->get_severity(section => 'psu', value => $result->{EntityExtErrorStatus});
|
my $exit = $self->get_severity(section => 'psu', value => $result->{EntityExtErrorStatus});
|
||||||
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("Power supply '%s' status is '%s'", $name, $result->{EntityExtErrorStatus}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf("Power supply '%s' status is '%s'", $name, $result->{EntityExtErrorStatus})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -28,7 +28,7 @@ my %map_sensor_status = (
|
|||||||
2 => 'normal',
|
2 => 'normal',
|
||||||
4 => 'entityAbsent',
|
4 => 'entityAbsent',
|
||||||
81 => 'sensorError',
|
81 => 'sensorError',
|
||||||
91 => 'hardwareFaulty',
|
91 => 'hardwareFaulty'
|
||||||
);
|
);
|
||||||
|
|
||||||
sub check {
|
sub check {
|
||||||
@ -49,54 +49,70 @@ sub check {
|
|||||||
my @instances = $self->get_instance_class(class => { 8 => 1 });
|
my @instances = $self->get_instance_class(class => { 8 => 1 });
|
||||||
return if (scalar(@instances) == 0);
|
return if (scalar(@instances) == 0);
|
||||||
|
|
||||||
$self->{snmp}->load(oids => [$mapping2->{EntityExtTemperature}->{oid}, $mapping2->{EntityExtTemperatureThreshold}->{oid}],
|
$self->{snmp}->load(
|
||||||
instances => [@instances]);
|
oids => [$mapping2->{EntityExtTemperature}->{oid}, $mapping2->{EntityExtTemperatureThreshold}->{oid}],
|
||||||
|
instances => [@instances]
|
||||||
|
);
|
||||||
my $results = $self->{snmp}->get_leef();
|
my $results = $self->{snmp}->get_leef();
|
||||||
|
|
||||||
my ($exit, $warn, $crit, $checked);
|
my ($exit, $warn, $crit, $checked);
|
||||||
foreach my $instance (sort @instances) {
|
foreach my $instance (sort @instances) {
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance);
|
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance);
|
||||||
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $results, instance => $instance);
|
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $results, instance => $instance);
|
||||||
|
|
||||||
next if (!defined($result->{EntityExtErrorStatus}));
|
next if (!defined($result->{EntityExtErrorStatus}));
|
||||||
next if ($self->check_filter(section => 'sensor', instance => $instance));
|
next if ($self->check_filter(section => 'sensor', instance => $instance));
|
||||||
if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) {
|
if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) {
|
||||||
$self->absent_problem(section => 'sensor', instance => $instance);
|
$self->absent_problem(section => 'sensor', instance => $instance);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $name = '';
|
my $name = '';
|
||||||
$name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1);
|
$name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1);
|
||||||
$name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne '');
|
$name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne '');
|
||||||
$self->{components}->{sensor}->{total}++;
|
$self->{components}->{sensor}->{total}++;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("Sensor '%s' status is '%s' [instance = %s]",
|
$self->{output}->output_add(
|
||||||
$name, $result->{EntityExtErrorStatus}, $instance));
|
long_msg => sprintf(
|
||||||
|
"Sensor '%s' status is '%s' [instance: %s]",
|
||||||
|
$name, $result->{EntityExtErrorStatus}, $instance
|
||||||
|
)
|
||||||
|
);
|
||||||
$exit = $self->get_severity(section => 'sensor', value => $result->{EntityExtErrorStatus});
|
$exit = $self->get_severity(section => 'sensor', value => $result->{EntityExtErrorStatus});
|
||||||
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("Sensor '%s' status is '%s'", $name, $result->{EntityExtErrorStatus}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf("Sensor '%s' status is '%s'", $name, $result->{EntityExtErrorStatus})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
next if (defined($result2->{EntityExtTemperature}) && $result2->{EntityExtTemperature} <= 0);
|
next if (defined($result2->{EntityExtTemperature}) && ($result2->{EntityExtTemperature} <= 0 || $result2->{EntityExtTemperature} == 65535));
|
||||||
|
|
||||||
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result2->{EntityExtTemperature});
|
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result2->{EntityExtTemperature});
|
||||||
if ($checked == 0 && defined($result2->{EntityExtTemperatureThreshold}) &&
|
if ($checked == 0 && defined($result2->{EntityExtTemperatureThreshold}) &&
|
||||||
$result2->{EntityExtTemperatureThreshold} > 0 && $result2->{EntityExtTemperatureThreshold} < 65535) {
|
$result2->{EntityExtTemperatureThreshold} > 0 && $result2->{EntityExtTemperatureThreshold} < 65535) {
|
||||||
my $crit_th = '~:' . $result2->{EntityExtTemperatureThreshold};
|
my $crit_th = '~:' . $result2->{EntityExtTemperatureThreshold};
|
||||||
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => undef);
|
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => undef);
|
||||||
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th);
|
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th);
|
||||||
|
|
||||||
$exit = $self->{perfdata}->threshold_check(value => $result2->{EntityExtTemperature}, threshold => [ { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' },
|
$exit = $self->{perfdata}->threshold_check(
|
||||||
{ label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } ]);
|
value => $result2->{EntityExtTemperature},
|
||||||
|
threshold => [
|
||||||
|
{ label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' },
|
||||||
|
{ label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' }
|
||||||
|
]
|
||||||
|
);
|
||||||
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
|
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
|
||||||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance);
|
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 sensor '%s' is %s degree centigrade", $name, $result2->{EntityExtTemperature}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf("Temperature sensor '%s' is %s degree centigrade", $name, $result2->{EntityExtTemperature})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->perfdata_add(
|
$self->{output}->perfdata_add(
|
||||||
label => 'temp', unit => 'C',
|
label => 'temp', unit => 'C',
|
||||||
nlabel => 'hardware.sensor.temperature.celsius',
|
nlabel => 'hardware.sensor.temperature.celsius',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user