diff options
author | Daniel Friesel <derf@finalrewind.org> | 2014-06-02 17:07:17 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2014-06-02 17:07:17 +0200 |
commit | 8559009dc832e65aab539b891308c6c9a33c6deb (patch) | |
tree | aae21cf5d0aad8f59f1622bf683e993c357304b4 /bin | |
parent | 8bc973db6d3a21d23bb1f9fac0573c5e438768fd (diff) |
-ld: Print "no {host/service} downtimes" instead of an empty list
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/icli | 48 |
1 files changed, 29 insertions, 19 deletions
@@ -1120,28 +1120,38 @@ elsif ( $list_type eq 'q' ) { display_queue(); } elsif ( $list_type eq 'd' ) { - say "Host downtimes:"; - if ( $verbosity == 1 ) { - printf( "%-25.25s %-20.20s %-20.20s\n", 'Host', 'start', 'stop' ); - } - elsif ( $verbosity == 2 ) { - printf( "%-25.25s %-20.20s %-20.20s %-17.17s %s\n", - 'Host', 'start', 'stop', 'duration', 'comment' ); - } - foreach my $downtime ( @{ $data->{hostdowntimes} } ) { - display_downtime($downtime); + if ( @{ $data->{hostdowntimes} } ) { + say "Host downtimes:"; + if ( $verbosity == 1 ) { + printf( "%-25.25s %-20.20s %-20.20s\n", 'Host', 'start', 'stop' ); + } + elsif ( $verbosity == 2 ) { + printf( "%-25.25s %-20.20s %-20.20s %-17.17s %s\n", + 'Host', 'start', 'stop', 'duration', 'comment' ); + } + foreach my $downtime ( @{ $data->{hostdowntimes} } ) { + display_downtime($downtime); + } } - say "\nService downtimes:"; - if ( $verbosity == 1 ) { - printf( "%-25.25s %-25.25s %-20.20s %-20.20s\n", - 'Host', 'Service', 'start', 'stop' ); + else { + say "No host downtimes"; } - elsif ( $verbosity == 2 ) { - printf( "%-25.25s %-25.25s %-20.20s %-20.20s %-17.17s %s\n", - 'Host', 'Service', 'start', 'stop', 'duration', 'comment' ); + if ( @{ $data->{servicedowntimes} } ) { + say "\nService downtimes:"; + if ( $verbosity == 1 ) { + printf( "%-25.25s %-25.25s %-20.20s %-20.20s\n", + 'Host', 'Service', 'start', 'stop' ); + } + elsif ( $verbosity == 2 ) { + printf( "%-25.25s %-25.25s %-20.20s %-20.20s %-17.17s %s\n", + 'Host', 'Service', 'start', 'stop', 'duration', 'comment' ); + } + foreach my $downtime ( @{ $data->{servicedowntimes} } ) { + display_downtime($downtime); + } } - foreach my $downtime ( @{ $data->{servicedowntimes} } ) { - display_downtime($downtime); + else { + say "\nNo service downtimes"; } } elsif ($action) { |