From b6692fe8cec4582853a3f0bbb1c70abbfd2a9170 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 27 Aug 2012 15:41:33 +0200 Subject: add -m / --match option --- bin/icli | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'bin') diff --git a/bin/icli b/bin/icli index 5289890..cd961fc 100755 --- a/bin/icli +++ b/bin/icli @@ -26,6 +26,7 @@ my $list_type = 's'; my $verbosity = 1; my $recheck = 0; my $force_recheck = 0; +my $match_output = undef; my $acknowledge = undef; my $as_contact = undef; my $term_width = Term::Size::chars(); @@ -198,6 +199,10 @@ sub filter_generic { my ($x) = @_; my $filters_unfulfilled = @filters; + if ($match_output and not $x->{plugin_output} =~ $match_output) { + return 0; + } + foreach my $f (@filters) { if ( ( $f eq 'A' and $x->{'problem_has_been_acknowledged'} ) @@ -809,6 +814,7 @@ GetOptions( 'g|hostgroup=s' => sub { push( @for_groups, split( /,/, $_[1] ) ) }, 'h|host=s' => sub { push( @for_hosts, split( /,/, $_[1] ) ) }, 'l|list=s' => sub { $list_type = substr( $_[1], 0, 1 ) }, + 'm|match=s' => sub { $match_output = qr{$_[1]}i }, 'r|recheck' => sub { $recheck = 1; $list_type = q{} }, 's|service=s' => sub { push( @for_services, split( /,/, $_[1] ) ) }, 'u|force-recheck' => sub { $force_recheck = 1; $list_type = q{} }, @@ -984,6 +990,11 @@ List either services (the default) or hosts. Note that only the first character of the argument is checked, so C<< icli -lh >>, C<< icli -ls >> etc. are also fine. +=item B<-m>|B<--match> I + +Limit selection to hosts/services whose plugin output matches +I (perl regular expression, case insensitive. see L). + =item B<-r>|B<--recheck> Schedule an immediate recheck of all selected services -- cgit v1.2.3