From 0f3b5b657b95451f0c9328db053710c1edb782c6 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 5 Sep 2010 16:21:10 +0200 Subject: proper -v handling --- bin/icli | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) (limited to 'bin') diff --git a/bin/icli b/bin/icli index 81b7364..d644240 100755 --- a/bin/icli +++ b/bin/icli @@ -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 { -- cgit v1.2.3