summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2012-08-27 15:41:33 +0200
committerDaniel Friesel <derf@finalrewind.org>2012-08-27 15:41:33 +0200
commitb6692fe8cec4582853a3f0bbb1c70abbfd2a9170 (patch)
tree85d18adba3158c8b0980dffe4d81f1d6a4351c8d
parent93ebb76764a6185217310313e2b34729d9e5030f (diff)
add -m / --match option
-rw-r--r--Changelog1
-rwxr-xr-xbin/icli11
2 files changed, 12 insertions, 0 deletions
diff --git a/Changelog b/Changelog
index 3f32fbd..c13276b 100644
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,7 @@
git hEAD
* Add missing documentation for -a / --acknowledge
+ * Add -m / --match option to select on plugin output
icli 0.42 - Fri Jun 01 2012
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<regex>
+
+Limit selection to hosts/services whose plugin output matches
+I<regex> (perl regular expression, case insensitive. see L<perlre>).
+
=item B<-r>|B<--recheck>
Schedule an immediate recheck of all selected services