mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-31 01:24:35 +02:00
Fix #1571
This commit is contained in:
parent
99fb399b0d
commit
2378acc458
@ -50,7 +50,8 @@ sub new {
|
|||||||
'description' => { name => 'description' },
|
'description' => { name => 'description' },
|
||||||
'filter-resource:s' => { name => 'filter_resource' },
|
'filter-resource:s' => { name => 'filter_resource' },
|
||||||
'filter-id:s' => { name => 'filter_id' },
|
'filter-id:s' => { name => 'filter_id' },
|
||||||
'exclude-id:s' => { name => 'exclude_id' },
|
'exclude-id:s' => { name => 'exclude_id' },
|
||||||
|
'format-date' => { name => 'format_date' },
|
||||||
});
|
});
|
||||||
$self->{result} = {};
|
$self->{result} = {};
|
||||||
return $self;
|
return $self;
|
||||||
@ -61,7 +62,7 @@ sub check_options {
|
|||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if (defined($self->{option_results}->{exclude_id}) && defined($self->{option_results}->{error_id})) {
|
if (defined($self->{option_results}->{exclude_id}) && defined($self->{option_results}->{error_id})) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Please use --error-id OR --exclude-id, these options are mutually exclusives");
|
$self->{output}->add_option_msg(short_msg => "Please use --error-id OR --exclude-id, these options are mutually exclusives");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,12 +112,14 @@ sub manage_selection {
|
|||||||
|
|
||||||
$extra_options .= $self->{option_results}->{command_options};
|
$extra_options .= $self->{option_results}->{command_options};
|
||||||
|
|
||||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
my $stdout = centreon::plugins::misc::execute(
|
||||||
options => $self->{option_results},
|
output => $self->{output},
|
||||||
sudo => $self->{option_results}->{sudo},
|
options => $self->{option_results},
|
||||||
command => $self->{option_results}->{command},
|
sudo => $self->{option_results}->{sudo},
|
||||||
command_path => $self->{option_results}->{command_path},
|
command => $self->{option_results}->{command},
|
||||||
command_options => $extra_options);
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $extra_options
|
||||||
|
);
|
||||||
my @lines = split /\n/, $stdout;
|
my @lines = split /\n/, $stdout;
|
||||||
# Header not needed
|
# Header not needed
|
||||||
shift @lines;
|
shift @lines;
|
||||||
@ -152,13 +155,20 @@ sub run {
|
|||||||
$resource_name !~ /$self->{option_results}->{filter_resource}/);
|
$resource_name !~ /$self->{option_results}->{filter_resource}/);
|
||||||
next if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
|
next if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
|
||||||
$identifier !~ /$self->{option_results}->{filter_id}/);
|
$identifier !~ /$self->{option_results}->{filter_id}/);
|
||||||
|
|
||||||
|
my $output_date = $split_error[0];
|
||||||
|
if (defined($self->{options}->{format_date})) {
|
||||||
|
my ($month, $day, $hour, $minute, $year) = unpack("(A2)*", $output_date);
|
||||||
|
$output_date = sprintf("20%s/%s/%s %s:%s", $year, $month, $day, $hour, $minute);
|
||||||
|
}
|
||||||
|
|
||||||
$total_error++;
|
$total_error++;
|
||||||
if (defined($description)) {
|
if (defined($description)) {
|
||||||
$self->{output}->output_add(long_msg => sprintf("Error '%s' Date: %s ResourceName: %s Description: %s", $identifier,
|
$self->{output}->output_add(long_msg => sprintf("Error '%s' Date: %s ResourceName: %s Description: %s", $identifier,
|
||||||
$timestamp, $resource_name, $description));
|
$output_date, $resource_name, $description));
|
||||||
} else {
|
} else {
|
||||||
$self->{output}->output_add(long_msg => sprintf("Error '%s' Date: %s ResourceName: %s", $identifier,
|
$self->{output}->output_add(long_msg => sprintf("Error '%s' Date: %s ResourceName: %s", $identifier,
|
||||||
$timestamp, $resource_name));
|
$output_date, $resource_name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,6 +260,10 @@ Filter error code (can use a regexp).
|
|||||||
|
|
||||||
Filter on specific error code (can be a comma separated list).
|
Filter on specific error code (can be a comma separated list).
|
||||||
|
|
||||||
|
=item B<--format-date>
|
||||||
|
|
||||||
|
Print the date to format 20YY/mm/dd HH:MM instead of mmddHHMMYY.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
Loading…
x
Reference in New Issue
Block a user