From 5264f6ecbf7638cb7a498ba9f18e481b9cdf4c80 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 18 Nov 2010 23:29:08 +0100 Subject: Filters! So far only those based on Flags and not totally clean. But working. --- bin/icli | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'bin') diff --git a/bin/icli b/bin/icli index 663eccc..0a40f94 100755 --- a/bin/icli +++ b/bin/icli @@ -24,6 +24,7 @@ my $list_type = 's'; my $verbosity = 1; my $recheck = 0; my (@for_hosts, @for_groups, @for_services, @list_hosts, @list_services); +my @filters; sub have_host { my ($host) = @_; @@ -74,11 +75,30 @@ sub pretty_date { sub filter_generic { my ($x) = @_; + my $filters_unfulfilled = @filters; if ($short and not $x->{'current_state'}) { return 0; } + foreach my $f (@filters) { + if ( + ($f eq 'A' and $x->{'problem_has_been_acknowledged'}) or + ($f eq '!A' and not $x->{'problem_has_been_acknowledged'}) or + ($f eq 'F' and $x->{'is_flapping'}) or + ($f eq '!F' and not $x->{'is_flapping'}) or + ($f eq 'P' and $x->{'passive_checks_enabled'} + and not $x->{'active_checks_enabled'}) or + ($f eq '!P' and $x->{'active_checks_enabled'}) + ) { + $filters_unfulfilled--; + } + } + + if ($filters_unfulfilled) { + return 0; + } + return 1; } -- cgit v1.2.3