summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-07-27 00:27:32 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2010-07-27 00:27:32 +0200
commit66916910efc3f8ba2d6edbe3d31243c3ccea92bb (patch)
tree2012c6ae30bc62582d6c3be98b49b51e026ff7d4
parent8f6918c09f9e9f190d4bd86ad84844797304f61f (diff)
icli: Add -s/--short option to only show non-OK services
-rwxr-xr-xbin/icli17
1 files changed, 15 insertions, 2 deletions
diff --git a/bin/icli b/bin/icli
index 427d12e..12c7c16 100755
--- a/bin/icli
+++ b/bin/icli
@@ -7,10 +7,11 @@ use 5.010;
use Getopt::Long;
use Term::ANSIColor;
-my ($data, $cache);
+my ($data, $cache, $extra);
my $status_file = '/var/lib/icinga/status.dat';
my $context;
my $colours = 1;
+my $short = 0;
my ($for_host);
@@ -43,6 +44,9 @@ sub read_status_line {
}
when('servicestatus') {
push(@{$data->{services}->{$cache->{host_name}}}, $cache);
+ if ($cache->{current_state} != 0) {
+ $extra->{$cache->{host_name}}->{service_problem} = 1;
+ }
}
when('contactstatus') {
push(@{$data->{contacts}}, $cache);
@@ -88,12 +92,16 @@ sub display_service {
sub display_host {
my ($host, $all) = @_;
- if ($all) {
+ if ($all and (not $short or $extra->{$host}->{service_problem})) {
say "\n$host";
}
foreach my $service (@{$data->{services}->{$host}}) {
+ if ($short and not $service->{current_state}) {
+ next;
+ }
+
if ($all) {
print "\t";
}
@@ -106,6 +114,7 @@ GetOptions(
'C|no-colours' => sub { $colours = 0 },
'f|status-file=s' => \$status_file,
'h|host=s' => \$for_host,
+ 's|short' => \$short,
);
read_status();
@@ -156,6 +165,10 @@ F</var/lib/icinga/status.dat>
Only show I<host>'s services
+=item B<-s>/B<--short>
+
+Only show services which are not OK
+
=back
=head1 EXIT STATUS