Hello,

On 11-04-26 05:48 AM, Juan-Francisco Diez wrote:
> OK, thenks for your help. I solved the trouble using the $hostname fact
> in front of services definitions.
> 
> But I have another question about this:
> 
> Is it possible to define the directory where the file are created in the
> nagios server?
> 
> Now the files are stored in the /etc/nagios.

Yes, that's possible. Check out this page for more info on the nagios_*
resources:

http://docs.puppetlabs.com/references/stable/type.html

hint: the nagios_* all have a metaparameter named "target" which is
described on this page as doing "target" .... that's what you want: set
that parameter to the path of the file that should contain each resource.

> 2011/4/26 Cedric Jeanneret <[email protected]
> <mailto:[email protected]>>
> 
>     Hello,
> 
>     Maybe have a look at our nagios module:
>     https://github.com/camptocamp/puppet-nagios
> 
>     Your problem is that resources with same name are exported from
>     multiple hosts, and that make puppet crash with duplicated
>     definition (as it's exported resources, the error message is
>     different ;) ).
>     You should name your nagios resources with the fqdn embedded so that
>     it will be really unique across the DB.
> 
>     Cheers,
> 
>     C.
> 
>     On Tue, 26 Apr 2011 01:29:03 -0700 (PDT)
>     Fransua33 <[email protected] <mailto:[email protected]>> wrote:
> 
>     > Hi everyone,
>     >
>     > I'm trying to automate the nagios configuration of new host through
>     > Puppet. For this I define a nagios module with the generic
>     > configuration of my Nagios host definition.  The module look like
>     > this:
>     >
>     > class nagios {
>     >       $packagelist=["nagios"]
>     >
>     >       package { $packagelist:
>     >               ensure => "installed"
>     >       }
>     >
>     >       $servicelist=["nagios", "httpd"]
>     >
>     >       service { $servicelist:
>     >               ensure          => "running",
>     >               hasstatus       => "true",
>     >               hasrestart      => "true"
>     >       }
>     >
>     >       # collect resources and populate /etc/nagios/nagios_*.cfg
>     >       Nagios_host <<| |>>
>     >       Nagios_service <<| |>>
>     >       Nagios_hostextinfo <<| |>>
>     >
>     >       class target {
>     >               @@nagios_host { $fqdn:
>     >                       ensure          => "present",
>     >                       use             =>
>     "ingacceso_$operatingsystem-server",
>     >                       alias           => $hostname,
>     >                       address         => $ipaddress,
>     >                       contacts        =>
>     "farconada,henry,fsariego,jfdiez"
>     >               }
>     >
>     >               @@nagios_hostextinfo { $fqdn:
>     >                       ensure  => "present",
>     >                       icon_image_alt  => $operatingsystem,
>     >                       icon_image      => "$operatingsystem.png"
>     >               }
>     >
>     >               @@nagios_service { "Host - Carga CPU":
>     >                       use             => "ingacceso_generic-service",
>     >                       host_name       => "$fqdn",
>     >                       check_command   => "check_nrpe!check_load"
>     >               }
>     >
>     >               @@nagios_service { "Host - CPU":
>     >                         use             => "ingacceso_generic-
>     > service",
>     >                         host_name       => "$fqdn",
>     >                         check_command   => "check_nrpe!check_cpu"
>     >                 }
>     >
>     >               @@nagios_service { "Host - Ping":
>     >                         use             => "ingacceso_generic-
>     > service",
>     >                         host_name       => "$fqdn",
>     >                         check_command   => "check_ping!400.0,20%!
>     > 900.0,60%"
>     >                 }
>     >
>     >               @@nagios_service { "Host - /":
>     >                         use             => "ingacceso_generic-
>     > service",
>     >                         host_name       => "$fqdn",
>     >                         check_command   => "check_nrpe!check_raiz"
>     >                 }
>     >
>     >               @@nagios_service { "Host - /boot":
>     >                         use             => "ingacceso_generic-
>     > service",
>     >                         host_name       => "$fqdn",
>     >                         check_command   => "check_nrpe!check_boot"
>     >                 }
>     >
>     >               @@nagios_service { "Host - Memoria":
>     >                         use             => "ingacceso_generic-
>     > service",
>     >                         host_name       => "$fqdn",
>     >                         check_command   => "check_nrpe!check_memoria"
>     >                 }
>     >
>     >               @@nagios_service { "Host - Swap":
>     >                         use             => "ingacceso_generic-
>     > service",
>     >                         host_name       => "$fqdn",
>     >                         check_command   => "check_nrpe!check_swap"
>     >                 }
>     >
>     >               @@nagios_service { "Host - Numero Procesos":
>     >                         use             => "ingacceso_generic-
>     > service",
>     >                         host_name       => "$fqdn",
>     >                         check_command   => "check_nrpe!
>     > check_total_procs"
>     >                 }
>     >
>     >
>     >               @@nagios_service { "Host - Interfaces de Red":
>     >                         use             => "ingacceso_generic-
>     > service",
>     >                         host_name       => "$fqdn",
>     >                         check_command   => "check_nrpe!
>     > check_interfaces_net"
>     >                 }
>     >       }
>     > }
>     >
>     > After this, I include this module in the template.pp:
>     >
>     > node basenode {
>     >       case $operatingsystem {
>     >               centos: { include centos }
>     >               default: { include centos }
>     >       }
>     >       include baseapps, sshd, administradores, nagiosclient
>     >       include nagios::target
>     > }
>     > node default inherits basenode {}
>     > node webserver inherits basenode {
>     >       include apache
>     > }
>     > node dbserver inherits basenode {
>     >       include mysql
>     > }
>     > node mailserver inherits basenode {
>     >       include postfix
>     > }
>     > node nagiosserver {
>     >       case $operatingsystem {
>     >                 centos: { include centos }
>     >                 default: { include centos }
>     >         }
>     >         include baseapps, sshd, administradores, nagiosclient
>     >       include nagios
>     > }
>     >
>     > Also I define my nodes in the node.pp file:
>     >
>     > node 'masterpuppet.example.int <http://masterpuppet.example.int>'
>     inherits basenode {}
>     > node 'web.example.int <http://web.example.int>' inherits webserver {
>     >       apache::virtual_host { "test1.example.int
>     <http://test1.example.int>":
>     >               ip      => "172.16.73.201"
>     >       }
>     >       apache::virtual_host { "test2.example.int
>     <http://test2.example.int>":
>     >                 ip      => "172.16.73.201"
>     >         }
>     > }
>     > node 'db.example.int <http://db.example.int>' inherits dbserver {}
>     > node 'mail.example.int <http://mail.example.int>' inherits
>     mailserver {}
>     > node 'nagios.example.int <http://nagios.example.int>' inherits
>     nagiosserver {}
>     >
>     > I verified that my store configs work well in my MySQL Database but in
>     > the reports of my Nagios host I can see this error:
>     >
>     > --- !ruby/object:Puppet::Transaction::Report
>     >   configuration_version:
>     >   host: nagios.example.int <http://nagios.example.int>
>     >   kind: apply
>     >   logs:
>     >     - !ruby/object:Puppet::Util::Log
>     >       level: !ruby/sym err
>     >       message: "Could not retrieve catalog from remote server: Error
>     > 400 on SERVER: Exported resource Nagios_service[Host - /] cannot
>     > override local resource on node nagios.example.int
>     <http://nagios.example.int>"
>     >       source: Puppet
>     >       tags:
>     >         - err
>     >       time: 2011-04-26 09:39:55.848399 +02:00
>     >     - !ruby/object:Puppet::Util::Log
>     >       level: !ruby/sym notice
>     >       message: Using cached catalog
>     >       source: Puppet
>     >       tags:
>     >         - notice
>     >       time: 2011-04-26 09:39:55.928445 +02:00
>     >     - !ruby/object:Puppet::Util::Log
>     >       level: !ruby/sym err
>     >       message: Could not retrieve catalog; skipping run
>     >       source: Puppet
>     >       tags:
>     >         - err
>     >       time: 2011-04-26 09:39:55.928687 +02:00
>     >   metrics: {}
>     >   puppet_version: 2.6.6
>     >   report_format: 2
>     >   resource_statuses: {}
>     >   status: failed
>     >   time: 2011-04-26 09
>     >
>     > and the files nagios_*.cfg don't appear in my Nagios config.
>     >
>     > Can somebody help me with this troubleshoot?
>     >
>     > Ref:
>     
> http://blog.gurski.org/index.php/2010/01/28/automatic-monitoring-with-puppet-and-nagios/
>     >


-- 
Gabriel Filion

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to