diff options
author | Daniel Friesel <derf@finalrewind.org> | 2010-11-18 23:02:57 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2010-11-18 23:02:57 +0100 |
commit | 416a6fedf5feebc6c8d27f22ef828419fd365609 (patch) | |
tree | b11c467955f5e0ea64c8764857038e647c3d199f /bin | |
parent | 6ab4d8130cc51be36c0d26760009eeb8e7881e2c (diff) |
Replace $short handling with generic filter (so far only for services)
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/icli | 30 |
1 files changed, 20 insertions, 10 deletions
@@ -72,6 +72,21 @@ sub pretty_date { return time2str('%Y-%m-%d %H:%M:%S', $unix); } +sub filter_service { + my ($s) = @_; + + if ($short and not $s->{'current_state'}) { + return 0; + } + + if (@list_services and not ($s->{'service_description'} ~~ + [@list_services])) { + return 0; + } + + return 1; +} + sub read_objects_line { my ($line, $ref) = @_; @@ -282,20 +297,15 @@ sub display_service { sub display_host_services { my ($host, $all) = @_; + my @services; + + @services = grep { filter_service($_) } @{$data->{'services'}->{$host}}; - if ($all and (not $short or $extra->{$host}->{service_problem})) { + if ($all and @services) { say "\n$host"; } - foreach my $service (@{$data->{services}->{$host}}) { - - if ( - ($short and not $service->{current_state}) - or (@list_services and not - ($service->{service_description} ~~ [@list_services]) - )) { - next; - } + foreach my $service (@services) { if ($all) { print "\t"; |