当我尝试将 Puppet 与 Nagios 集成时遇到了一点问题。
这是我的配置(我知道,这很简单,但这是我的第一次尝试)
/etc/puppet/modules/nagios/manifests/init.pp
class nagios::server {
package { ["nagios"]:
ensure => installed,
}
service { nagios:
ensure => running,
enable => true,
}
file { 'resource-d':
path => '/etc/nagios/objects',
ensure => directory,
owner => 'nagios',
}
# Collect the nagios_host resources
Nagios_host <<||>> {
require => File[resource-d],
notify => [Service[nagios]],
}
}
/etc/puppet/modules/nagios/manifests/export.pp
class nagios::export {
@@nagios_host { $::fqdn:
address => $::ipaddress,
check_command => 'check-host-alive!3000.0,80%!5000.0,100%!10',
hostgroups => 'all-servers',
target => "/etc/nagios/objects/host_${::fqdn}.cfg"
}
}
/etc/puppet/manifests/site.pp
node 'server-1'
{
include nagios::server
include nagios::export
}
所有这些功能都正常工作,但 Nagios 配置的 cfg 是在远程节点“server-1”而不是 Nagios 服务器上创建的(Nagios 和 Puppet 在同一台服务器上运行),我无法从 server-1 获取此配置并将其显示在 Nagios 服务器上。您知道发生了什么吗?
问候
答案1
需要在被监控的服务器上导出资源,并在运行 Nagios 的服务器上收集资源。您说“server-1”是被监控的服务器,并且您在同一台服务器上运行 Nagios 和 Puppet,所以我假设第二个监控服务器名为“puppet”。因此,您的 Puppetsite.pp
应该如下所示:
node 'puppet' {
include nagios::server
}
node 'server-1' {
include nagios::export
}