From 5c330c8d09f0cae4690c6871f29ea680a1fe673f Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 18 Nov 2010 23:08:04 +0100 Subject: Use filters for host listing as well --- bin/icli | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'bin') 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)); -- cgit v1.2.3