summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-06-01 21:13:03 +0200
committerDaniel Friesel <derf@finalrewind.org>2014-06-01 21:13:03 +0200
commit8bc973db6d3a21d23bb1f9fac0573c5e438768fd (patch)
treec5a1b8841345c16a4532fd920351354039077901
parentdbbe3c116cf1f7ab9944d4d85118bb21fb12b91a (diff)
-ld: improve output format. TODO: -vv and -vvv
-rw-r--r--Changelog2
-rwxr-xr-xbin/icli35
2 files changed, 31 insertions, 6 deletions
diff --git a/Changelog b/Changelog
index 4e0c515..90f12e0 100644
--- a/Changelog
+++ b/Changelog
@@ -6,7 +6,7 @@ git HEAD
-aa/ -a acknowledge, -r/--recheck with -ar / -a recheck and
-u/--force-recheck wiht -aR / -a force_recheck
* add -ad / -a downtime option to schedule host/service downtimes
- * Also show service downtimes when using --list downtimes
+ * Also show service downtimes when using -ld, improve its output
icli 0.47 - Thu May 29 2014
diff --git a/bin/icli b/bin/icli
index b601f8e..9bfa94a 100755
--- a/bin/icli
+++ b/bin/icli
@@ -95,6 +95,12 @@ sub pretty_duration {
my $now = time();
my $dif = $now - $since;
+ return pretty_duration_abs($dif);
+}
+
+sub pretty_duration_abs {
+ my ($dif) = @_;
+
return sprintf( '%dd %dh %dm %ds',
int( $dif / ( 24 * 3600 ) ),
int( ( $dif / 3600 ) % 24 ),
@@ -619,15 +625,19 @@ sub display_downtime {
pretty_date( $d->{'entry_time'} ),
$d->{'author'}, );
}
- if ( $v >= 2 ) {
- printf( ' %-30.30s', $d->{'comment'} );
- }
- printf( ' %s %s',
+ printf(
+ ' %-20.20s %-20.20s',
pretty_date( $d->{'start_time'} ),
pretty_date( $d->{'end_time'} ),
);
if ( $v >= 2 ) {
- print( $d->{'fixed'} ? ' Fixed' : ' Flexi' );
+ printf( '%-17.17s',
+ $d->{'fixed'}
+ ? ' Fixed'
+ : ' ' . pretty_duration_abs( $d->{duration} ) );
+ }
+ if ( $v >= 2 ) {
+ print( $d->{comment} );
}
print "\n";
@@ -1111,10 +1121,25 @@ elsif ( $list_type eq 'q' ) {
}
elsif ( $list_type eq 'd' ) {
say "Host downtimes:";
+ if ( $verbosity == 1 ) {
+ printf( "%-25.25s %-20.20s %-20.20s\n", 'Host', 'start', 'stop' );
+ }
+ elsif ( $verbosity == 2 ) {
+ printf( "%-25.25s %-20.20s %-20.20s %-17.17s %s\n",
+ 'Host', 'start', 'stop', 'duration', 'comment' );
+ }
foreach my $downtime ( @{ $data->{hostdowntimes} } ) {
display_downtime($downtime);
}
say "\nService downtimes:";
+ if ( $verbosity == 1 ) {
+ printf( "%-25.25s %-25.25s %-20.20s %-20.20s\n",
+ 'Host', 'Service', 'start', 'stop' );
+ }
+ elsif ( $verbosity == 2 ) {
+ printf( "%-25.25s %-25.25s %-20.20s %-20.20s %-17.17s %s\n",
+ 'Host', 'Service', 'start', 'stop', 'duration', 'comment' );
+ }
foreach my $downtime ( @{ $data->{servicedowntimes} } ) {
display_downtime($downtime);
}