summaryrefslogtreecommitdiff
path: root/bin/icli
diff options
context:
space:
mode:
Diffstat (limited to 'bin/icli')
-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