diff options
author | Daniel Friesel <derf@finalrewind.org> | 2010-11-18 23:18:03 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2010-11-18 23:18:03 +0100 |
commit | 5b6c9f684132dae79014e985f7502d42c74b60bb (patch) | |
tree | 56fb66403fd5ef2297b6c81d4ac437d4dda64b95 | |
parent | 5c330c8d09f0cae4690c6871f29ea680a1fe673f (diff) |
Prepare for more filters
-rwxr-xr-x | bin/icli | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -72,10 +72,20 @@ sub pretty_date { return time2str('%Y-%m-%d %H:%M:%S', $unix); } +sub filter_generic { + my ($x) = @_; + + if ($short and not $x->{'current_state'}) { + return 0; + } + + return 1; +} + sub filter_host { my ($h) = @_; - if ($short and not $h->{'current_state'}) { + if (not filter_generic($h)) { return 0; } @@ -85,7 +95,7 @@ sub filter_host { sub filter_service { my ($s) = @_; - if ($short and not $s->{'current_state'}) { + if (not filter_generic($s)) { return 0; } @@ -394,6 +404,7 @@ GetOptions( 'v|verbose+' => \$verbosity, 'V|version' => sub { say "icli version $VERSION"; exit 0 }, 'x|critical-only' => \$short, + 'z|filter=s' => sub { push(@filters, split(/,/, $_[1])) }, ) or die("Please see perldoc -F $0 for help\n"); |