mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-28 08:04:36 +02:00
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
@ -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}
|
||||
$date->strftime("%a %b %d %T %Y"),
|
||||
$event->{event_id}, $event->{description}
|
||||
)
|
||||
);
|
||||
$num_errors++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user