summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-09-04 19:10:16 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2010-09-04 19:10:16 +0200
commit61fc6dec5d7312dbfaf19e8ccffda705a128cad4 (patch)
treed7fbc6eeb3d98a796d52a064f7a94073d328622a
parent2731255c0cabc52896eece32f8d054d199aef1c6 (diff)
Add -v switch
-rwxr-xr-xbin/icli28
1 files changed, 22 insertions, 6 deletions
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 },
);