Bug #1496
nagios_servicedependency needs a unique host_name?
| Status: | Closed | Start: | 08/07/2008 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | nagios | |||
| Target version: | - | |||
| Affected version: | 0.24.8 | Branch: | ||
| Keywords: | exportedresources | |||
| Votes: | 0 |
Description
Hi all,
I might be doing something wrong here, but… I’ve created a definition that adds exported resources for websites that are hosted on that machine. However, these Nagios service checks depend on the overall availability of apache. So I tried to simply add a dependency on the apache check for each of the http website checks. The definition looks like this:
define my_site ($documentroot = "/var/www", $check_priority = "important") {
apache::site { $name:
documentroot => $documentroot,
}
@@nagios_service { "$fqdn $name http check":
ensure => present,
target => "/etc/nagios2/cust/services-by-puppet.cfg",
use => "${check_priority}-service",
host_name => $fqdn,
service_description => "$name at $hostname",
#notify => Service["nagios2"],
check_command => "check_http2!$name!10!20",
}
@@nagios_servicedependency { "$fqdn $name http dependency":
ensure => present,
target => "/tmp/servicedependencies-by-puppet.cfg",
dependent_host_name => $fqdn,
dependent_service_description => "$name at $hostname",
host_name => $fqdn,
service_description => "apache",
execution_failure_criteria => "c",
notification_failure_criteria => "w,c",
}
}
I get the following error:
@err: Could not create sharedhosting1.example.com test1.example.com http dependency: sharedhosting1.example.com test2.example.com http dependency already exists with name sharedhosting1.example.com@
Adding an alias to the nagios_servicedependency doesn’t seem to solve this.
Am I doing something wrong or is this a bug in the type?
History
Updated by James Turnbull about 2 years ago
- Status changed from Unreviewed to Needs design decision
- Assignee set to Luke Kanies
Luke?
Updated by Luke Kanies about 2 years ago
- Assignee changed from Luke Kanies to Puppet Community
It looks like the service dependencies have the host_name field as their namevar, meaning that yes, they must be unique based on their hostname. Seems like a pretty bad idea, but I don’t have a better recommendation for the unique name.
Updated by Tim Stoop about 2 years ago
Can’t the name of the resource not be the namevar? Or am I saying something stupid now? So in my case it would be “$fqdn $name http dependency”.
Updated by Tim Stoop almost 2 years ago
This is a better test than the original one. Using this to see if I can learn ruby and fix this at the same time.
class nagios-test {
define my_site ($documentroot = "/var/www", $check_priority = "important") {
nagios_service { "$fqdn $name http check":
ensure => present,
target => "/tmp/services-by-puppet.cfg",
use => "service",
host_name => $fqdn,
service_description => "$name at $hostname",
check_command => "check_http2!$name!10!20",
}
nagios_servicedependency { "$fqdn $name http dependency":
ensure => present,
target => "/tmp/servicedependencies-by-puppet.cfg",
dependent_host_name => $fqdn,
dependent_service_description => "$name at $hostname",
host_name => $fqdn,
service_description => "apache",
execution_failure_criteria => "c",
notification_failure_criteria => "w,c",
}
}
my_site {
"important":;
"notimportant":;
}
}
Updated by Martha Greenberg almost 2 years ago
- File namevars.diff added
Until this get fixed properly, the following patch sets more reasonable defaults for the nagios namevars. Since the service names have to be unique anyway, this allows one dependency per service, instead of one per host. Similarly with service escalation, service extinfo and host dependencies.
Updated by Luke Kanies over 1 year ago
- Status changed from Needs design decision to Ready for Checkin
- Assignee changed from Puppet Community to James Turnbull
My understanding is that this is largely fixed in commit:“b2daea83ab8a5cd71b6f14eef7e97e7dab754d66”.
Updated by Tim Stoop over 1 year ago
- Affected version changed from 0.24.5 to 0.24.6
luke wrote:
My understanding is that this is largely fixed in commit:“b2daea83ab8a5cd71b6f14eef7e97e7dab754d66”.
Where can I find this commit? 0.24.7 seems not to contain it yet.
Updated by James Turnbull over 1 year ago
Is this not in commit:“a0a6d2cfa88cac5418097fb9f71df4cbcae4b192”?
Updated by James Turnbull over 1 year ago
- Status changed from Ready for Checkin to Closed
- Target version set to 0.24.7
Please re-open if still broken.
Updated by Tim Stoop over 1 year ago
jamtur01 wrote:
Please re-open if still broken.
Just downloaded the 0.24.7 tarball and tried the recipe from comment #4:
tim@debian:~/.puppet$ puppet ~/.puppet/manifests/site.pp notice: //Node[default]/nagios-bug-1496/Nagios-bug-1496::My_site[notimportant]/Nagios_servicedependency[debian.ehv.kumina.localnet notimportant http dependency]/ensure: created notice: //Node[default]/nagios-bug-1496/Nagios-bug-1496::My_site[important]/Nagios_service[debian.ehv.kumina.localnet important http check]/ensure: created notice: //Node[default]/nagios-bug-1496/Nagios-bug-1496::My_site[notimportant]/Nagios_service[debian.ehv.kumina.localnet notimportant http check]/ensure: created notice: //Node[default]/nagios-bug-1496/Nagios-bug-1496::My_site[important]/Nagios_servicedependency[debian.ehv.kumina.localnet important http dependency]/ensure: created
So fixed for me. Thanks for the hard work, people!
Updated by Alex Urbanowicz 10 months ago
- Status changed from Closed to Re-opened
- Affected version changed from 0.24.6 to 0.24.8
- Keywords set to exportedresources
I have a following nagios service manifest:
define service( $contactgroup, $command ) {
@@nagios_service { "$title_$hostname":
use => "generic-service",
host_name => $hostname,
service_description => "$title",
is_volatile => 0,
contact_groups => $contactgroup,
check_period => "24x7",
max_check_attempts => 2,
normal_check_interval => 5,
retry_check_interval => 3,
check_command => $command,
notification_interval => 480,
notification_period => "dayhours",
notification_options => "u,c,r,w",
tag => $environment,
require => [Nagios_contactgroup["artegence-admins"],Nagios_host["$hostname"]],
notify => [Exec["chmod_nagios"], Service["nagios"]],
}
@@nagios_servicedependency { "$title_DEP_$hostname":
host_name => $hostname,
service_description => "$title",
dependent_host_name => $hostname,
notification_failure_criteria => "w,u,c",
execution_failure_criteria => "n,p",
require => [Nagios_service["$title_$hostname"], Nagios_host["$hostname"]],
notify => [Exec["chmod_nagios"], Service["nagios"]],
tag => $environment,
ensure => present,
}
}
When I use it in service class definition like:
nagios::service { YUM: contactgroup => somecontactgroup, command => somenagioscommand }
and in another
nagios::service { PUPPET: contactgroup => somecontactgroup, command => somenagioscommand }
I get Duplicate definition: Nagios_service[hostname] with references to file and line where the define() is defined. When I paste the code directly to respective classes and replace $title by hand with PUPPET and YUM respectively, everything works ok.
Updated by James Turnbull 10 months ago
- Target version deleted (
0.24.7)
Updated by James Turnbull 10 months ago
- Status changed from Re-opened to Investigating
- Assignee changed from James Turnbull to Luke Kanies
Luke?
Updated by Luke Kanies 10 months ago
- Status changed from Investigating to Closed
The problem is probably the way you’re including multiple variables; it needs to be:
Nagios_service["${title}_${hostname}"]
Note the curlies. Otherwise Puppet looks for a variable named ‘$title_’, which doesn’t exist of course.