From efbe4a66d63d2a55c9e9721e471780b2cfba23ad Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 20 Nov 2010 09:59:51 +0100 Subject: Add -vv mode for -lh as well --- bin/icli | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/icli b/bin/icli index 9c6e9b8..a2f061e 100755 --- a/bin/icli +++ b/bin/icli @@ -483,17 +483,72 @@ sub display_host_services { sub display_host_single { my ($host) = @_; + my $format = "%-16s : %s\n"; my $h = $data->{hosts}->{$host}; my $v = $verbosity; - printf("%-32.32s", $h->{'host_name'}); - printf(" %s", host_state($h->{'has_been_checked'}, $h->{'current_state'})); + if ($v < 3) { - if ($v >= 2) { - printf(" %d/%d", $h->{'current_attempt'}, $h->{'max_attempts'}); + 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'}); + } + else { + printf( + $format, + 'Host', + $h->{'host_name'}, + ); + printf( + "%-16s : %s (for %s)%s\n", + 'Status', + host_state($h->{'has_been_checked'}, $h->{'current_state'}), + pretty_duration($h->{'last_state_change'}), + ($h->{'problem_has_been_acknowledged'} ? ' (Acknowledged)' : q{}), + ); + printf( + $format, + 'Plugin Output', + $h->{'plugin_output'}, + ); + printf( + $format, + 'Performance Data', + $h->{'performance_data'}, + ); + printf( + "%-16s : %d/%d\n", + 'Current Attempt', + $h->{'current_attempt'}, + $h->{'max_attempts'}, + ); + printf( + $format, + 'Last Check Time', + pretty_date($h->{'last_check'}), + ); + printf( + $format, + 'Next Check', + pretty_date($h->{'next_check'}), + ); + printf( + "%-16s : %s (%.1f%% state change)\n", + 'Flapping', + ($h->{'is_flapping'} ? + colored('YES', 'white on_red') : + colored('NO', 'black on_green') + ), + $h->{'percent_state_change'}, + ); + print "\n"; } - printf(" %s\n", $h->{'plugin_output'}); } sub display_host { -- cgit v1.2.3