MON-21973-date-problem-on-storage-ibm-storwize-ssh-plugin-eventlog (#4676)
Co-authored-by: Matteo D'Alfonso <mdalfonso@centreon.com> Co-authored-by: Lucie Dubrunfaut <ldubrunfaut@CNTR-P-PF3DNAR1> Co-authored-by: Evan <eadam@centreon.com>
This commit is contained in:
parent
186afcb092
commit
dd3f3a3b36
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"dependencies": [
|
||||
"libssh-session-perl",
|
||||
"plink"
|
||||
"plink"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning:s' => { name => 'warning', },
|
||||
'critical:s' => { name => 'critical', },
|
||||
'filter-event-id:s' => { name => 'filter_event_id' },
|
||||
'filter-message:s' => { name => 'filter_message' },
|
||||
'retention:s' => { name => 'retention' }
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning:s' => { name => 'warning', },
|
||||
'critical:s' => { name => 'critical', },
|
||||
'filter-event-id:s' => { name => 'filter_event_id' },
|
||||
'filter-message:s' => { name => 'filter_message' },
|
||||
'retention:s' => { name => 'retention' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -72,24 +72,35 @@ sub run {
|
|||
my $result = $options{custom}->get_hasharray(content => $content, delim => ':');
|
||||
|
||||
my ($num_eventlog_checked, $num_errors) = (0, 0);
|
||||
foreach (@$result) {
|
||||
foreach my $event (@$result) {
|
||||
$num_eventlog_checked++;
|
||||
if (defined($self->{option_results}->{filter_message}) && $self->{option_results}->{filter_message} ne '' &&
|
||||
$_->{description} !~ /$self->{option_results}->{filter_message}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $_->{description} . "': no matching filter description.", debug => 1);
|
||||
$event->{description} !~ /$self->{option_results}->{filter_message}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $event->{description} . "': no matching filter description.", debug => 1);
|
||||
next;
|
||||
}
|
||||
if (defined($self->{option_results}->{filter_event_id}) && $self->{option_results}->{filter_event_id} ne '' &&
|
||||
$_->{event_id} !~ /$self->{option_results}->{filter_event_id}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $_->{event_id} . "': no matching filter event id.", debug => 1);
|
||||
$event->{event_id} !~ /$self->{option_results}->{filter_event_id}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $event->{event_id} . "': no matching filter event id.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
my @array = ($event->{last_timestamp} =~ m/../g); # format expected is YYMMDDHHMMSS
|
||||
my $date = DateTime->new(
|
||||
"year" => "20" . $array[0], # DateTime expect 4 digit year, as this is log the chance of decade old data is slim.
|
||||
"month" => $array[1],
|
||||
"day" => $array[2],
|
||||
"hour" => $array[3],
|
||||
"minute" => $array[4],
|
||||
"second" => $array[5],
|
||||
|
||||
);
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
'%s : %s - %s',
|
||||
scalar(localtime($_->{last_timestamp})),
|
||||
$_->{event_id}, $_->{description}
|
||||
'%s : %s - %s',
|
||||
$date->strftime("%a %b %d %T %Y"),
|
||||
$event->{event_id}, $event->{description}
|
||||
)
|
||||
);
|
||||
$num_errors++;
|
||||
|
@ -98,16 +109,16 @@ sub run {
|
|||
$self->{output}->output_add(long_msg => sprintf("Number of message checked: %s", $num_eventlog_checked));
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $num_errors, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
severity => $exit,
|
||||
short_msg => sprintf("%d problem detected (use verbose for more details)", $num_errors)
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'eventlogs.problems.count',
|
||||
value => $num_errors,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
nlabel => 'eventlogs.problems.count',
|
||||
value => $num_errors,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0
|
||||
min => 0
|
||||
);
|
||||
|
||||
$self->{output}->display();
|
||||
|
|
Loading…
Reference in New Issue