diff options
-rwxr-xr-x | bin/icli | 42 | ||||
-rw-r--r-- | t/50-icli.t | 4 |
2 files changed, 20 insertions, 26 deletions
@@ -179,25 +179,16 @@ sub display_queue { sub display_service { my ($s) = @_; - given ($verbosity) { - when (1) { - printf( - "%-20.20s %s %s\n", - $s->{service_description}, - service_state($s->{has_been_checked}, $s->{current_state}), - $s->{plugin_output}, - ); - } - when (2) { - printf("%-20.20s %s %d/%d %s\n", - $s->{service_description}, - service_state($s->{has_been_checked}, $s->{current_state}), - $s->{current_attempt}, - $s->{max_attempts}, - $s->{plugin_output}, - ); - } + my $v = $verbosity; + + printf("%-20.20s", $s->{service_description}); + printf(" %s" , service_state($s->{'has_been_checked'}, $s->{'current_state'})); + + if ($v >= 2) { + printf(" %d/%d", $s->{'current_attempt'}, $s->{'max_attempts'}); } + + printf(" %s\n", $s->{'plugin_output'}); } sub display_host_services { @@ -224,17 +215,20 @@ sub display_host_services { sub display_host_single { my ($host) = @_; my $h = $data->{hosts}->{$host}; + my $v = $verbosity; if ($short and not $h->{current_state}) { return; } - printf( - "%-32.32s %s %s\n", - $h->{host_name}, - host_state($h->{has_been_checked}, $h->{current_state}), - $h->{plugin_output}, - ); + printf("%-32.32s", $h->{'host_name'}); + printf(" %s", host_state($h->{'has_been_checked'}, $h->{'current_state'})); + + if ($v >= 2) { + printf(" %d/%d", $h->{'current_attempt'}, $h->{'max_attempts'}); + } + + printf(" %s\n", $h->{'plugin_output'}); } sub display_host { diff --git a/t/50-icli.t b/t/50-icli.t index 29702ab..1c9e344 100644 --- a/t/50-icli.t +++ b/t/50-icli.t @@ -118,10 +118,10 @@ $icli = "bin/icli -f t/in/status.dat.weird.2 -c t/in/objects.cache"; $cmd = Test::Command->new(cmd => "$icli -lh -h alpha"); $cmd->exit_isnt_num(0); -$cmd->stdout_is_eq($EMPTY); +$cmd->stdout_is_eq('alpha '); $cmd->stderr_is_eq("Unknown host state: 23\n"); $cmd = Test::Command->new(cmd => "$icli -ls -h aneurysm"); $cmd->exit_isnt_num(0); -$cmd->stdout_is_eq($EMPTY); +$cmd->stdout_is_eq('Disk: / '); $cmd->stderr_is_eq("Unknown service state: 23\n"); |