diff --git a/plugins/plugins-available/agents/README.md b/plugins/plugins-available/agents/README.md
index 9f1d7c649..f54186f92 100644
--- a/plugins/plugins-available/agents/README.md
+++ b/plugins/plugins-available/agents/README.md
@@ -112,39 +112,34 @@ For example:
name = httpd
- # set default args (if multiple args match, the last one overrides previous ones)
+ # set extra service attributes (if multiple blocks match, each is applied in order and overwrites previous values)
# block can be used multiple times
-
- value = warn='load > 95' crit='load > 100'
- match = cpu # regex match on service name
+
+ service = ^cpu$ # regex match on service description
# restrict to specific hosts (regular expression)
#host = ANY
- #section ~ test # apply this argument only to sections containing "test"
-
+ #section ~ test # apply this attributes only to sections containing "test"
+
+ # can be used to append extra arguments to the command line
+ #args = warn='load > 95' crit='load > 100'
+
+ # naemon service attributes will be added to the generated host configuration
+ first_notification_delay = 30
+ notification_options = w,c
+ # other naemon service attributes...
+
# set extra host attributes (if multiple blocks match, each is applied in order)
# block can be used multiple times
- match = hostname # regex match on host name
+ host = ^hostname$ # regex match on host name
#section ~ test # apply this attributes only to sections containing "test"
# naemon host attributes will be added to the generated host configuration
#first_notification_delay = 30
- # other attributes...
+ #check_command = check-host-alive!$HOSTADDRESS$
+ # other naemon host attributes...
- # set extra service attributes (if multiple blocks match, each is applied in order)
- # block can be used multiple times
-
- match = service description # regex match on service description
- # restrict to specific hosts (regular expression)
- #host = ANY
- #section ~ test # apply this attributes only to sections containing "test"
-
- # naemon service attributes will be added to the generated host configuration
- first_notification_delay = 30
- # other attributes...
-
-
diff --git a/plugins/plugins-available/agents/lib/Thruk/Agents/SNClient.pm b/plugins/plugins-available/agents/lib/Thruk/Agents/SNClient.pm
index 10b90a58f..4af1d5e53 100644
--- a/plugins/plugins-available/agents/lib/Thruk/Agents/SNClient.pm
+++ b/plugins/plugins-available/agents/lib/Thruk/Agents/SNClient.pm
@@ -180,28 +180,34 @@ sub get_config_objects {
# these are obsolete services, just keep them as is
next;
}
+ my $extra = _get_extra_opts_svc($c, $svc->{'conf'}->{'service_description'}, $hostname, $section);
$settings->{'disabled'} = Thruk::Base::array_remove($settings->{'disabled'}, $id);
$svc->{'conf'} = $chk->{'svc_conf'};
$svc->{'conf'}->{'use'} = \@templates;
delete $chk->{'svc_conf'}->{'_AGENT_ARGS'};
- if($args) {
+ if($args) { # user supplied manual overrides
$chk->{'svc_conf'}->{'_AGENT_ARGS'} = $args;
$chk->{'svc_conf'}->{'check_command'} .= " ".$args;
} else {
# check for default args
$args = _get_default_args($c, $svc->{'conf'}->{'service_description'}, $hostname, $section);
+ for my $ex (@{$extra}) {
+ for my $key (sort keys %{$ex}) {
+ $args = $ex->{$key} if $key eq 'args';
+ }
+ }
$chk->{'svc_conf'}->{'check_command'} .= " ".$args if $args;
}
$svc->{'comments'} = ["# autogenerated check: ".$svc->{'conf'}->{'service_description'} ];
# set extra service options
- my $extra = _get_extra_opts_svc($c, $svc->{'conf'}->{'service_description'}, $hostname, $section);
for my $ex (@{$extra}) {
for my $key (sort keys %{$ex}) {
next if $key eq 'host';
next if $key eq 'match';
next if $key eq 'section';
next if $key eq 'host_name';
+ next if $key eq 'args';
$chk->{'svc_conf'}->{$key} = $ex->{$key};
}
}
@@ -596,6 +602,7 @@ sub _get_extra_opts_svc {
my $res = [];
for my $opt (@{$opts}) {
next unless Thruk::Utils::Agents::check_wildcard_match($name, ($opt->{'match'} // 'ANY'));
+ next unless Thruk::Utils::Agents::check_wildcard_match($name, ($opt->{'service'} // 'ANY'));
next unless Thruk::Agents::SNClient::check_host_match($opt->{'host'});
next unless Thruk::Utils::Agents::check_wildcard_match($section, ($opt->{'section'} // 'ANY'));
push @{$res}, $opt;