aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2023-10-04 19:09:39 +0900
committerKazuki Yamaguchi <k@rhe.jp>2023-10-18 19:56:10 +0900
commite163cee019a4f1b69cdb0291c1150fcd2c79b3de (patch)
tree4837d82e96d69315d5aaa9a134aff41ff0cfe992
parent8d83bf55bd9ec3de063ed4a9eda290defbcf8dd6 (diff)
downloadsmokeping-e163cee019a4f1b69cdb0291c1150fcd2c79b3de.tar.gz
Correctly filter target list for slavesHEADmaster
The list of slaves enabled for a target is a space-separated string. A slave name can be a substring of another slave name, so matching it using /\b${slave}\b/ is not accurate. This is an issue when we have two slaves named "abc" and "abc-def" and a target defined only for "abc". Currently, both slaves receive a config including the target.
-rw-r--r--lib/Smokeping/Master.pm2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/Smokeping/Master.pm b/lib/Smokeping/Master.pm
index 869d923..49cd721 100644
--- a/lib/Smokeping/Master.pm
+++ b/lib/Smokeping/Master.pm
@@ -43,7 +43,7 @@ sub get_targets {
# master
next if $key eq 'host' and $trg->{$key} eq 'DYNAMIC';
next if $key eq 'host' and $trg->{$key} =~ m|^/|; # skip multi targets
- next if $key eq 'host' and not ( defined $trg->{slaves} and $trg->{slaves} =~ /\b${slave}\b/);
+ next if $key eq 'host' and not ( defined $trg->{slaves} and grep { $_ eq $slave } split /\s+/, $trg->{slaves});
if (ref $trg->{$key} eq 'HASH'){
$return{$key} = get_targets ($trg->{$key},$slave);
$ok = 1 if defined $return{$key};