Hello again,

Yes, of course you can change the directory.

Check out the mentioned module, we put all the nagios stuff in /etc/nagios.d 
directory, keeping clean a /etc/nagios3 directory. For what I've seen, it seems 
to do exactly what you're trying to do.

For the basic:
nagios accept different directories for its configuration, you have to add them 
in your nagios.cfg file using the cfg_dir directive. This can be done using 
either a simple file, a template or with augeas (not sure for the latest point).

Cheers,

C.

On Tue, 26 Apr 2011 11:48:32 +0200
Juan-Francisco Diez <[email protected]> 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.
> 
> 
> 2011/4/26 Cedric Jeanneret <[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]> 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' inherits basenode {}
> > > node 'web.example.int' inherits webserver {
> > >       apache::virtual_host { "test1.example.int":
> > >               ip      => "172.16.73.201"
> > >       }
> > >       apache::virtual_host { "test2.example.int":
> > >                 ip      => "172.16.73.201"
> > >         }
> > > }
> > > node 'db.example.int' inherits dbserver {}
> > > node 'mail.example.int' inherits mailserver {}
> > > node '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
> > >   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"
> > >       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/
> > >
> >
> >
> > --
> > Cédric Jeanneret                 |  System Administrator
> > 021 619 10 32                    |  Camptocamp SA
> > [email protected]  |  PSE-A / EPFL
> >
> 


-- 
Cédric Jeanneret                 |  System Administrator
021 619 10 32                    |  Camptocamp SA
[email protected]  |  PSE-A / EPFL

Attachment: signature.asc
Description: PGP signature

Reply via email to