add filter by id

This commit is contained in:
garnier-quentin 2020-05-26 09:44:48 +02:00
parent adfe6a05f0
commit fdc9581613
1 changed files with 12 additions and 2 deletions

View File

@ -80,7 +80,8 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
$options{options}->add_options(arguments => {
'filter-id:s' => { name => 'filter_id' },
'filter-name:s' => { name => 'filter_name' },
'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '' },
@ -120,6 +121,11 @@ sub manage_selection {
$self->{output}->output_add(long_msg => "skipping monitor '" . $_->{MONITOR_NAME} . "': no matching filter.", debug => 1);
next;
}
if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
$_->{MONITOR_ID} !~ /$self->{option_results}->{filter_id}/) {
$self->{output}->output_add(long_msg => "skipping monitor '" . $_->{MONITOR_NAME} . "': no matching filter.", debug => 1);
next;
}
my $start_date = POSIX::strftime('%d/%m/%Y %H:%M:%S', gmtime($time - ($_->{PERIODICITY} * 60 * 2)));
my $kpi_detail = $options{custom}->request_api(
@ -162,9 +168,13 @@ Check KPI.
Only display some counters (regexp can be used).
Example: --filter-counters='status'
=item B<--filter-id>
Filter by monitor id (can be a regexp).
=item B<--filter-name>
Filter monitor name (can be a regexp).
Filter by monitor name (can be a regexp).
=item B<--unknown-status>