From df744427be22787720e84850a209c6b0e0241e0f Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 12 Jun 2014 11:22:06 +0200 Subject: show service comments when using -vvv --- Changelog | 1 + bin/icli | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Changelog b/Changelog index 90f12e0..ae2b38f 100644 --- a/Changelog +++ b/Changelog @@ -7,6 +7,7 @@ git HEAD -u/--force-recheck wiht -aR / -a force_recheck * add -ad / -a downtime option to schedule host/service downtimes * Also show service downtimes when using -ld, improve its output + * Show service comments when using -vvv icli 0.47 - Thu May 29 2014 diff --git a/bin/icli b/bin/icli index dc30273..06ba2e8 100755 --- a/bin/icli +++ b/bin/icli @@ -384,12 +384,10 @@ sub read_objects_line { = $cache; } when ('hostcomment') { - - # TODO + push( @{ ${$ref}->{hostcomments} }, $cache ); } when ('servicecomment') { - - # TODO + push( @{ ${$ref}->{servicecomments} }, $cache ); } when ('host') { ${$ref}->{hosts}->{ $cache->{host_name} } = $cache; @@ -441,6 +439,16 @@ sub read_objects { } sub enhance_status { + for my $c ( @{ $data->{servicecomments} } ) { + say "!"; + my $service + = firstval { $_->{service_description} eq $c->{service_description} } + @{ $data->{services}->{ $c->{host_name} } }; + push( @{ $service->{comments} }, $c ); + } + for my $c ( @{ $data->{hostcomments} } ) { + push( @{ $data->{hosts}->{ $c->{host_name} }->{comments} }, $c ); + } HOST: for my $h ( keys %{ $data->{services} } ) { for my $s ( @{ $data->{services}->{$h} } ) { if ( $s->{current_state} != 0 ) { @@ -802,6 +810,10 @@ sub display_x_verbose { 'Flap Detection', pretty_yesno( $x->{'flap_detection_enabled'} ), ); + + for my $c ( @{ $x->{comments} // [] } ) { + printf( $format, 'Comment', break_str( $c->{comment_data}, 19 ) ); + } } } -- cgit v1.2.3