summaryrefslogtreecommitdiff
path: root/bin/icli
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2010-11-18 23:18:03 +0100
committerDaniel Friesel <derf@finalrewind.org>2010-11-18 23:18:03 +0100
commit5b6c9f684132dae79014e985f7502d42c74b60bb (patch)
tree56fb66403fd5ef2297b6c81d4ac437d4dda64b95 /bin/icli
parent5c330c8d09f0cae4690c6871f29ea680a1fe673f (diff)
Prepare for more filters
Diffstat (limited to 'bin/icli')
-rwxr-xr-xbin/icli15
1 files changed, 13 insertions, 2 deletions
diff --git a/bin/icli b/bin/icli
index b4b8107..663eccc 100755
--- a/bin/icli
+++ b/bin/icli
@@ -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");