FAQ
Hello,
i 'm try automatizando my nagios monitoring i've running puppet with
puppetDB and postgres and this running ok. The problem that present in
this moment is the nagios structure in the server with generate puppet for
example:
When I connect my node agent (puppet agent --test) and my nagios server
after run (puppet agent --test) generate the archives:

/etc/nagios/nagios_host.cfg ---> (host definition)

[..............]
# HEADER: This file was autogenerated at Fri Aug 30 17:06:55 -0400 2013
# HEADER: by puppet. While it can still be managed manually, it
# HEADER: is definitely not recommended.
define host {
address 10.0.0.133
use linux-server
host_name node5.example.com
alias node5
}
[..............]

resource.d/host_node1.example.com.cfg (service monitoring)

[..............]
# HEADER: This file was autogenerated at Fri Aug 30 17:06:54 -0400 2013
# HEADER: by puppet. While it can still be managed manually, it
# HEADER: is definitely not recommended.

define service {
## --PUPPET_NAME-- (called '_naginator_name' in the manifest)
  check_users_node1
use generic-service
service_description node1_check_users
host_name node1.example.com
check_command check_nrpe!check_users
}
[..............]

But when the service nagios is restarted say error message

[..............]
Error: Could not find any host matching 'node1.example.com' (config file
'/etc/nagios/resource.d/host_node1.example.com.cfg', starting on line 4)
Error: Could not expand hostgroups and/or hosts specified in service
(config file '/etc/nagios/resource.d/host_node5.example.com.cfg', starting
on line 4)
[..............]

And the "solution" is placed (manually) the host definition
"/etc/nagios/nagios_host.cfg" within "resource.d/host_node1.example.com.cfg"
. For example:

[..............]
[root@nagios nagios]# cat resource.d/host_node5.example.com.cfg
# HEADER: This file was autogenerated at Fri Aug 30 17:06:54 -0400 2013
# HEADER: by puppet. While it can still be managed manually, it
# HEADER: is definitely not recommended.

define host {
         address 10.0.0.133
         use linux-server
         host_name node5.example.com
         alias node5
}

define service {
## --PUPPET_NAME-- (called '_naginator_name' in the manifest)
  check_users_node5
use generic-service
service_description node5_check_users
host_name node5.example.com
check_command check_nrpe!check_users
}
[..............]

My export class is (node information) is:

[..............]
class nagios::export {

   @@nagios_host { $::fqdn:
     ensure => present,
     alias => $::hostname,
     address => $::ipaddress,
     use => "linux-server",
     notify => Service["nagios"],
   }

   @@nagios_service { "check_users_${hostname}":
# check_command => "check_ping!100.0,20%!500.0,60%",
         check_command => "check_nrpe!check_users",
         use => "generic-service",
         host_name => "$fqdn",
         service_description => "${hostname}_check_users",
         target => "/etc/nagios/resource.d/host_${::fqdn}.cfg",
  }
}
[..............]

¿How to make the definition is within the same resource? ¿is possible? or
¿What is the way to correct the problem?


Thanks.!!


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Gabriel Filion at Sep 1, 2013 at 7:48 am
    Hi there,
    On 30/08/13 05:34 PM, mike wrote:
    [..............]
    Error: Could not find any host matching 'node1.example.com' (config file
    '/etc/nagios/resource.d/host_node1.example.com.cfg', starting on line 4)
    Error: Could not expand hostgroups and/or hosts specified in service
    (config file '/etc/nagios/resource.d/host_node5.example.com.cfg',
    starting on line 4)
    [..............]
    those errors indicate that the host definitions are either absent or not
    in a place where nagios is looking for (e.g. not loaded via include or
    include_dir).

    also:
    class nagios::export {

    @@nagios_host { $::fqdn:
    ensure => present,
    alias => $::hostname,
    address => $::ipaddress,
    use => "linux-server",
    notify => Service["nagios"],
    }
    in the above snippet, you're not specifying any target for hosts, so
    unless you do it while collecting resources[1], the host definitions
    will be written in /etc/nagios/nagios_host.cfg

    see: https://docs.puppetlabs.com/references/stable/type.html#nagioshost

    you could add in the above:

    [...]
       target => "/etc/nagios/resource.d/host_${::fqdn}.cfg",
    }

    [1]: the target can be specified during collection on the nagios server
    if you want to send all resources of the same type in one file. for example:

    Nagios_host <<||>>
    Nagios_host <||> {
       target => '/etc/nagios3/conf.d/nagios_hosts.cfg',
    }

    --
    Gabriel Filion

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedAug 30, '13 at 9:34p
activeSep 1, '13 at 7:48a
posts2
users2
websitepuppetlabs.com

2 users in discussion

Mike: 1 post Gabriel Filion: 1 post

People

Translate

site design / logo © 2022 Grokbase