Fix #5185
This commit is contained in:
parent
ff77edb043
commit
3d0af89f78
|
@ -54,11 +54,11 @@ sub check {
|
|||
return if (scalar(keys %$result) <= 0);
|
||||
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||
next if ($key !~ /^$oid_fanDescr\.(\d+)$/;
|
||||
next if ($key !~ /^$oid_fanDescr\.(\d+)$/);
|
||||
my $instance = $1;
|
||||
|
||||
my $fan_descr = centreon::plugins::misc($result->{$oid_fanDescr . '.' . $instance});
|
||||
my $fan_speed = centreon::plugins::misc($result->{$oid_fanSpeed . '.' . $instance});
|
||||
my $fan_descr = centreon::plugins::misc::trim($result->{$oid_fanDescr . '.' . $instance});
|
||||
my $fan_speed = centreon::plugins::misc::trim($result->{$oid_fanSpeed . '.' . $instance});
|
||||
|
||||
$self->{components}->{fans}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Fan '%s' speed is %s.",
|
||||
|
|
|
@ -61,9 +61,6 @@ sub check {
|
|||
short_msg => sprintf("System health status is '%s'.",
|
||||
${$states{$result->{$oid_systemHealthStat}}}[0]));
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
|
@ -58,10 +58,10 @@ sub check {
|
|||
return if (scalar(keys %$result) <= 0);
|
||||
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||
next if ($key !~ /^$oid_tempDescr\.(\d+)$/;
|
||||
next if ($key !~ /^$oid_tempDescr\.(\d+)$/);
|
||||
my $instance = $1;
|
||||
|
||||
my $temp_descr = centreon::plugins::misc($result->{$oid_tempDescr . '.' . $instance});
|
||||
my $temp_descr = centreon::plugins::misc::trim($result->{$oid_tempDescr . '.' . $instance});
|
||||
my $temp_value = $result->{$oid_tempReading . '.' . $instance};
|
||||
my $temp_crit_high = $result->{$oid_tempCritLimitHigh . '.' . $instance};
|
||||
my $temp_warn_high = $result->{$oid_tempNonCritLimitHigh . '.' . $instance};
|
||||
|
|
|
@ -46,7 +46,7 @@ sub check {
|
|||
$self->{output}->output_add(long_msg => "Checking voltages");
|
||||
return if ($self->check_exclude('voltages'));
|
||||
|
||||
my $oid_voltEntry = '.1.3.6.1.4.1.2.3.51.3.1.1.2.1';
|
||||
my $oid_voltEntry = '.1.3.6.1.4.1.2.3.51.3.1.2.2.1';
|
||||
my $oid_voltDescr = '.1.3.6.1.4.1.2.3.51.3.1.2.2.1.2';
|
||||
my $oid_voltReading = '.1.3.6.1.4.1.2.3.51.3.1.2.2.1.3';
|
||||
my $oid_voltCritLimitHigh = '.1.3.6.1.4.1.2.3.51.3.1.2.2.1.6';
|
||||
|
@ -58,10 +58,10 @@ sub check {
|
|||
return if (scalar(keys %$result) <= 0);
|
||||
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||
next if ($key !~ /^$oid_voltDescr\.(\d+)$/;
|
||||
next if ($key !~ /^$oid_voltDescr\.(\d+)$/);
|
||||
my $instance = $1;
|
||||
|
||||
my $volt_descr = centreon::plugins::misc($result->{$oid_voltDescr . '.' . $instance});
|
||||
my $volt_descr = centreon::plugins::misc::trim($result->{$oid_voltDescr . '.' . $instance});
|
||||
my $volt_value = $result->{$oid_voltReading . '.' . $instance};
|
||||
my $volt_crit_high = $result->{$oid_voltCritLimitHigh . '.' . $instance};
|
||||
my $volt_warn_high = $result->{$oid_voltNonCritLimitHigh . '.' . $instance};
|
||||
|
@ -69,14 +69,16 @@ sub check {
|
|||
my $volt_warn_low = $result->{$oid_voltNonCritLimitLow . '.' . $instance};
|
||||
|
||||
my $warn_threshold = '';
|
||||
$warn_threshold = $volt_warn_low . ':' . $volt_warn_high;
|
||||
$warn_threshold = $volt_warn_low . ':' if ($volt_warn_low != 0);
|
||||
$warn_threshold .= $volt_warn_high if ($volt_warn_high != 0);
|
||||
my $crit_threshold = '';
|
||||
$crit_threshold = $volt_crit_low . ':' . $volt_crit_high;
|
||||
$crit_threshold = $volt_crit_low . ':' if ($volt_crit_low != 0);
|
||||
$crit_threshold .= $volt_crit_high if ($volt_crit_high != 0);
|
||||
|
||||
$self->{perfdata}->threshold_validate(label => 'warning_' . $instance, value => $warn_threshold);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical_' . $instance, value => $crit_threshold);
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $temp_value, threshold => [ { label => 'critical_' . $instance, 'exit_litteral' => 'critical' }, { label => 'warning_' . $instance, exit_litteral => 'warning' } ]);
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $volt_value, threshold => [ { label => 'critical_' . $instance, 'exit_litteral' => 'critical' }, { label => 'warning_' . $instance, exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{components}->{temperatures}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Voltage '%s' value is %s.",
|
||||
|
|
|
@ -41,6 +41,14 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use centreon::plugins::misc;
|
||||
use centreon::plugins::statefile;
|
||||
|
||||
my %severity_map = (
|
||||
0 => 'error',
|
||||
1 => 'warning',
|
||||
2 => 'information',
|
||||
3 => 'other',
|
||||
);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
|
@ -53,6 +61,7 @@ sub new {
|
|||
"filter-severity:s" => { name => 'filter_severity', default => 'error' },
|
||||
"filter-message:s" => { name => 'filter_message' },
|
||||
"memory" => { name => 'memory' },
|
||||
"warning" => { name => 'warning' },
|
||||
});
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
return $self;
|
||||
|
@ -63,7 +72,7 @@ sub check_options {
|
|||
$self->SUPER::init(%options);
|
||||
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
$self->{statefile_cache}->check_options(%options);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,14 +84,18 @@ sub run {
|
|||
$self->{hostname} = $self->{snmp}->get_hostname();
|
||||
$self->{snmp_port} = $self->{snmp}->get_port();
|
||||
my $datas = {};
|
||||
my $last_time;
|
||||
my $exit = defined($self->{option_results}->{warning}) ? 'WARNING' : 'CRITICAL';
|
||||
my ($num_eventlog_checked, $num_errors) = (0, 0);
|
||||
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$self->{statefile_cache}->read(statefile => "cache_imm_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode});
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "No new problems on system.");
|
||||
short_msg => "No new problems detected.");
|
||||
$last_time = $self->{statefile_cache}->get(name => 'last_time');
|
||||
} else {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "No problems on system.");
|
||||
short_msg => "No problems detected.");
|
||||
}
|
||||
|
||||
#### Get OIDS
|
||||
|
@ -97,29 +110,47 @@ sub run {
|
|||
my $result = $self->{snmp}->get_table(oid => $oid_eventLogEntry);
|
||||
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||
next if ($key !~ /^$oid_eventLogString\.(\d+)$/;
|
||||
next if ($key !~ /^$oid_eventLogString\.(\d+)$/);
|
||||
my $instance = $1;
|
||||
|
||||
my $message = centreon::plugins::misc($result->{$oid_eventLogString . '.' . $instance});
|
||||
my $message = centreon::plugins::misc::trim($result->{$oid_eventLogString . '.' . $instance});
|
||||
my $severity = $result->{$oid_eventLogSeverity . '.' . $instance};
|
||||
my $date = $result->{$oid_eventLogDate . '.' . $instance};
|
||||
my $time = $result->{$oid_eventLogTime . '.' . $instance};
|
||||
|
||||
my $date_compare = '';
|
||||
$date =~ {(\d+)/(\d+)/(\d+)};
|
||||
$date =~ /(\d+)\/(\d+)\/(\d+)/;
|
||||
$date_compare = $3 . $1 . $2;
|
||||
$time =~ {(\d+)::(\d+)::(\d+)};
|
||||
$date_compare .= $1 . $2 . $3
|
||||
$time =~ /(\d+):(\d+):(\d+)/;
|
||||
$date_compare .= $1 . $2 . $3;
|
||||
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$datas->{last_time} = $date_compare;
|
||||
next if (defined($last_time) && $datas->{last_time} <= $last_time);
|
||||
}
|
||||
|
||||
$num_eventlog_checked++;
|
||||
|
||||
next if (defined($self->{option_results}->{filter_severity}) && $self->{option_results}->{filter_severity} ne '' && $severity_map{$severity} !~ /$self->{option_results}->{filter_severity}/);
|
||||
next if (defined($self->{option_results}->{filter_message}) && $self->{option_results}->{filter_message} ne '' && $message !~ /$self->{option_results}->{filter_message}/);
|
||||
|
||||
$num_errors++;
|
||||
$self->{output}->output_add(long_msg => sprintf("%s : %s",
|
||||
$date . ' ' . $time,
|
||||
$message
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %s components [%s] are ok.",
|
||||
$total_components,
|
||||
$display_by_component
|
||||
)
|
||||
);
|
||||
$self->{output}->output_add(long_msg => sprintf("Number of message checked: %s", $num_eventlog_checked));
|
||||
if ($num_errors != 0) {
|
||||
# Message problem
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("%d problem detected (use verbose for more details)", $num_errors)
|
||||
);
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$self->{statefile_cache}->write(data => $datas);
|
||||
|
@ -139,6 +170,10 @@ Check eventlogs.
|
|||
|
||||
=over 8
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Use warning return instead 'critical'.
|
||||
|
||||
=item B<--memory>
|
||||
|
||||
Only check new eventlogs.
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#
|
||||
####################################################################################
|
||||
|
||||
package network::cisco::asa::plugin;
|
||||
package hardware::server::ibm::mgmt_cards::imm::snmp::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
|
|
@ -79,7 +79,7 @@ sub check_options {
|
|||
}
|
||||
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
$self->{statefile_cache}->check_options(%options);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ sub check_options {
|
|||
}
|
||||
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
$self->{statefile_cache}->check_options(%options);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue