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/
--
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.