nagios
nagios copied to clipboard
Use the service "servicegroups" directive or the servicegroup "members" directive, but not both
:speaking_head: Foreword
Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.
:ghost: Brief Description
When the conf.d/services.cfg file is populated, each service with a servicegroup assignment is given a "servicegroups" directive. At the same time, when conf.d/servicegroups.cfg is populated, each service group is given a "members" directive. I imagine in most situations this works fine, but if I need to have a service defined with an host_name directive that includes a negated/excluded hostname (hostname prefixed with !), the servicegroups.cfg definition does not respect that exclusion. For example, my existing configuration creates something like this:
# conf.d/services.cfg
# <snip>
define service {
use default-service
service-description my-service
hostgroup_name my-hostgroup
host_name !somehost
servicegroups my-servicegroup
check_command check_command!arg1!arg2
}
# <snip>
# conf.d/servicegroups.cfg
# <snip>
define servicegroup {
servicegroup_name my-servicegroup
members thishost,my-service,thathost,my-service,somehost,my-service
}
# <snip>
The result is that the nagios service will not start because it cannot locate my-service on somehost.
:pancakes: Cookbook version
Version of the cookbook where you are encountering the issue: 11.1.4
:woman_cook: Chef-Infra Version
Version of chef-client in your environment: 17.10.3
:tophat: Platform details
Operating system distribution and release version: Ubuntu 22.04
Steps To Reproduce
Steps to reproduce the behavior:
Create a data bag for a service which includes both a servicegroups directive and a host_name directive. The host_name directive needs to contain a negated/excluded host. Then create a data bag for a servicegroup to be referenced by the previously defined service.
:police_car: Expected behavior
As the documentation for Nagios 4 indicates that object definition for a service with a servicegroups directive is an alternative to the object definition for a servicegroup with a members directive, it would be ideal to do one or the other, not both. I'd prefer to have the servicegroups directive attached to a service than individual services enumerated in the servicegroups definitions so that Nagios can intelligently exclude hosts that are negated by the service definitions host_name directive.
:heavy_plus_sign: Additional context
No additional context