From 61fc6dec5d7312dbfaf19e8ccffda705a128cad4 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 4 Sep 2010 19:10:16 +0200 Subject: Add -v switch --- bin/icli | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/icli b/bin/icli index ee07793..81b7364 100755 --- a/bin/icli +++ b/bin/icli @@ -17,6 +17,7 @@ my $context; my $colours = 1; my $short = 0; my $list_type = 's'; +my $verbosity = 1; my (@for_hosts, @for_groups); sub have_host { @@ -177,12 +178,26 @@ sub display_queue { sub display_service { my ($s) = @_; - printf( - "%-20.20s %s %s\n", - $s->{service_description}, - service_state($s->{has_been_checked}, $s->{current_state}), - $s->{plugin_output}, - ); + + 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}, + ); + } + } } sub display_host_services { @@ -241,6 +256,7 @@ GetOptions( 'h|host=s' => sub { push(@for_hosts, split(/,/, $_[1])) }, 'l|list=s' => sub { $list_type = substr($_[1], 0, 1) }, 's|short' => \$short, + 'v|verbose+' => \$verbosity, 'V|version' => sub { say "icli version $VERSION"; exit 0 }, ); -- cgit v1.2.3