diff options
author | Daniel Friesel <derf@finalrewind.org> | 2010-11-07 15:34:45 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2010-11-07 15:34:45 +0100 |
commit | af8ce156b29fbcdfa2c5e80395661d227897f962 (patch) | |
tree | 97c4af460e2ea6621204e3ed15474f95e9da1d3a /bin/icli | |
parent | b71ec7282385b72e7e5d7aaf99890a0890e38eda (diff) |
Make -s slightly more effective
Diffstat (limited to 'bin/icli')
-rwxr-xr-x | bin/icli | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -45,6 +45,17 @@ sub have_service { return 0; } +sub have_service_multi { + my ($host, @services) = @_; + + foreach my $s (@services) { + if (have_service($host, $s)) { + return 1; + } + } + return 0; +} + sub with_colour { my ($text, $colour) = @_; if ($colours) { @@ -254,7 +265,11 @@ sub display_host_services { foreach my $service (@{$data->{services}->{$host}}) { - if ($short and not $service->{current_state}) { + if ( + ($short and not $service->{current_state}) + or (@for_services and not + ($service->{service_description} ~~ [@for_services]) + )) { next; } @@ -370,7 +385,10 @@ if (@for_hosts and $list_type ~~ [qw/s h/]) { } elsif ($list_type eq 's') { foreach my $host (sort keys %{$data->{services}}) { - display_host($host, 1); + if (not (@for_services and not have_service_multi($host, + @for_services))) { + display_host($host, 1); + } } } elsif ($list_type eq 'h') { |