summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2010-11-07 15:34:45 +0100
committerDaniel Friesel <derf@finalrewind.org>2010-11-07 15:34:45 +0100
commitaf8ce156b29fbcdfa2c5e80395661d227897f962 (patch)
tree97c4af460e2ea6621204e3ed15474f95e9da1d3a
parentb71ec7282385b72e7e5d7aaf99890a0890e38eda (diff)
Make -s slightly more effective
-rwxr-xr-xbin/icli22
1 files changed, 20 insertions, 2 deletions
diff --git a/bin/icli b/bin/icli
index d50b897..1151a80 100755
--- a/bin/icli
+++ b/bin/icli
@@ -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') {