Skip to content

Commit

Permalink
conf: fix validating service parents (fixes #1376)
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Jul 19, 2024
1 parent 52f3dc1 commit aac1a07
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions plugins/plugins-available/conf/lib/Monitoring/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2226,6 +2226,24 @@ sub _check_references {
return if $tst =~ m/$newval/;
## use critic
}
} elsif($attr eq 'parents' && $link eq 'service') {
if($val =~ m/,/mx) {
my @list = split(/\s*,\s*/mx, $val);
my $failed;
while(scalar @list > 0) {
my $hst = shift @list;
my $svc = shift @list;
if(!defined $hst || !$objects_by_name->{'host'}->{$hst}) {
$failed = 1;
last;
}
if(!defined $svc || !$objects_by_name->{'service'}->{$svc}) {
$failed = 1;
last;
}
}
return if !$failed;
}
}

if($options{'hash'}) {
Expand Down

0 comments on commit aac1a07

Please sign in to comment.