summaryrefslogtreecommitdiff
path: root/bin/icli
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2010-11-18 23:08:04 +0100
committerDaniel Friesel <derf@finalrewind.org>2010-11-18 23:08:04 +0100
commit5c330c8d09f0cae4690c6871f29ea680a1fe673f (patch)
treecf17b42fee10b173b46cff209dad493c02fa27a0 /bin/icli
parent416a6fedf5feebc6c8d27f22ef828419fd365609 (diff)
Use filters for host listing as well
Diffstat (limited to 'bin/icli')
-rwxr-xr-xbin/icli18
1 files changed, 14 insertions, 4 deletions
diff --git a/bin/icli b/bin/icli
index 630c986..b4b8107 100755
--- a/bin/icli
+++ b/bin/icli
@@ -72,6 +72,16 @@ sub pretty_date {
return time2str('%Y-%m-%d %H:%M:%S', $unix);
}
+sub filter_host {
+ my ($h) = @_;
+
+ if ($short and not $h->{'current_state'}) {
+ return 0;
+ }
+
+ return 1;
+}
+
sub filter_service {
my ($s) = @_;
@@ -320,10 +330,6 @@ sub display_host_single {
my $h = $data->{hosts}->{$host};
my $v = $verbosity;
- if ($short and not $h->{current_state}) {
- return;
- }
-
printf("%-32.32s", $h->{'host_name'});
printf(" %s", host_state($h->{'has_been_checked'}, $h->{'current_state'}));
@@ -423,6 +429,10 @@ if (@list_services) {
@list_hosts = grep { have_service_multi($_, @list_services) } @list_hosts;
}
+if ($list_type eq 'h') {
+ @list_hosts = grep { filter_host($data->{'hosts'}->{$_}) } @list_hosts;
+}
+
if ($list_type ~~ [qw[s h]]) {
foreach my $host (@list_hosts) {
display_host($host, (@list_hosts > 1));