summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-07-10 02:14:07 +0200
committerDaniel Friesel <derf@finalrewind.org>2014-07-10 02:14:07 +0200
commit30594afdec7ef76ae917617407a83f263bccffc5 (patch)
treea48ae3a18d02faa5df2da106322c0efccda133e1 /bin
parentf2a6b13ce49649bddc456f7ae5fc7f56811ce250 (diff)
support -U $foo with -lh
Diffstat (limited to 'bin')
-rwxr-xr-xbin/icli24
1 files changed, 21 insertions, 3 deletions
diff --git a/bin/icli b/bin/icli
index 44dd584..f6c33fa 100755
--- a/bin/icli
+++ b/bin/icli
@@ -312,6 +312,10 @@ sub filter_host {
return 0;
}
+ if ( $as_contact and not has_contact_host( $h, $as_contact ) ) {
+ return 0;
+ }
+
return 1;
}
@@ -328,14 +332,22 @@ sub filter_service {
return 0;
}
- if ( $as_contact and not has_contact( $s, $as_contact ) ) {
+ if ( $as_contact and not has_contact_service( $s, $as_contact ) ) {
return 0;
}
return 1;
}
-sub has_contact {
+sub has_contact_host {
+ my ( $h, $contact ) = @_;
+
+ my $conf_h = $config->{hosts}{ $h->{host_name} };
+
+ return any { $_ eq $contact } @{ $conf_h->{contacts} };
+}
+
+sub has_contact_service {
my ( $s, $contact ) = @_;
my $conf_s
@@ -457,13 +469,19 @@ sub enhance_status {
}
}
}
+ for my $h ( values %{ $config->{hosts} } ) {
+ if ( $h->{contacts} ) {
+ $h->{contacts} =~ s{^ *}{}o;
+ $h->{contacts} = [ split( m{, *}, $h->{contacts} ) ];
+ }
+ }
HOST: for my $h ( keys %{ $config->{services} } ) {
for my $s ( @{ $config->{services}->{$h} } ) {
if ( $s->{contacts} ) {
$s->{contacts} =~ s{^ *}{}o;
$s->{contacts} = [ split( m{, *}, $s->{contacts} ) ];
}
- if ($s->{contact_groups}) {
+ if ( $s->{contact_groups} ) {
for my $group ( split( m{, *}, $s->{contact_groups} ) ) {
push(
@{ $s->{contacts} },