Bug #1496

avatar

nagios_servicedependency needs a unique host_name?

Added by Tim Stoop 11 months ago. Updated 6 months ago.

Status:Closed Start:08/07/2008
Priority:Normal Due date:
Assigned to:avatarJames Turnbull % Done:

0%

Category:nagios
Target version:0.24.7
Complexity:

Unknown

Affected version:

0.24.6

Keywords:

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?

namevars.diff (1.1 KB) Martha Greenberg, 09/11/2008 12:38 pm


Related issues

related to Puppet - Bug #1420 nagios_serviceescalation not allowing host_name more than one type Closed 07/13/2008
duplicated by Puppet - Bug #1561 puppet requires a unique service_description for a nagios_service Duplicate 09/05/2008

History

Updated by James Turnbull 10 months ago

avatar
  • Status changed from Unreviewed to Needs design decision
  • Assigned to set to Luke Kanies

Luke?

Updated by Luke Kanies 10 months ago

avatar
  • Assigned to 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 10 months ago

avatar

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 10 months ago

avatar

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 9 months ago

avatar

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 6 months ago

avatar
  • Status changed from Needs design decision to Ready for Checkin
  • Assigned to changed from Puppet Community to James Turnbull

My understanding is that this is largely fixed in commit:"b2daea83ab8a5cd71b6f14eef7e97e7dab754d66".

Updated by Tim Stoop 6 months ago

avatar
  • 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 6 months ago

avatar
  • 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 6 months ago

avatar

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!

Also available in: Atom PDF