puppet/nagios/manifests/target.pp

160 lines
3.7 KiB
Puppet

# Configure nagios target.
#
class nagios::target {
@@nagios::host { $fqdn:
group => $::domain,
osname => $::operatingsystem,
osicon => $::osfamily ? {
"" => "NONE",
default => inline_template("<%= osfamily.downcase %>")
},
}
Nagios::Service {
host => $::fqdn,
group => $::domain,
}
}
# Configure ssh service target.
#
class nagios::target::ssh inherits nagios::target {
@@nagios::service { "${fqdn}_ssh":
command => "check_ssh",
description => "SSH",
}
}
# Configure http service target.
#
class nagios::target::http inherits nagios::target {
@@nagios::service { "${fqdn}_http":
command => "check_http",
description => "HTTP",
}
}
# Configure https service target.
#
class nagios::target::https inherits nagios::target {
@@nagios::service { "${fqdn}_https":
command => "check_http!--ssl",
description => "HTTPS",
}
}
# Configure smtp service target.
#
class nagios::target::smtp inherits nagios::target {
@@nagios::service { "${fqdn}_smtp":
command => "check_smtp",
description => "SMTP",
}
}
# Configure nagios nrpe target.
#
class nagios::target::nrpe inherits nagios::target {
if !$nagios_allow {
$nagios_allow = "127.0.0.1"
}
include nagios::common
case $operatingsystem {
"centos","redhat","fedora": {
$service = "nrpe"
$nrpedir = "/etc/nrpe.d"
package { [ "nrpe",
"nagios-plugins-disk",
"nagios-plugins-load",
"nagios-plugins-procs",
"nagios-plugins-users", ]:
ensure => installed,
before => [ File["/etc/nrpe.d"],
Augeas["nrpe-allow"],
Service["nrpe"], ],
}
}
"ubuntu","debian": {
$service = "nagios-nrpe-server"
$nrpedir = "/etc/nagios/nrpe.d"
package { [ "nagios-nrpe-server",
"nagios-plugins-basic", ]:
ensure => installed,
before => [ File["/etc/nrpe.d"],
Augeas["nrpe-allow"],
Service["nrpe"], ],
}
}
}
file { "/etc/nrpe.d":
ensure => directory,
mode => "0644",
owner => "root",
group => "root",
purge => true,
force => true,
recurse => true,
source => "puppet:///modules/custom/empty",
}
service { "nrpe":
name => $service,
ensure => running,
enable => true,
}
augeas { "nrpe-allow":
context => "/files/etc/nagios/nrpe.cfg",
changes => "set allowed_hosts '${nagios_allow}'",
notify => Service["nrpe"],
}
file { "${nrpedir}/check_disk.cfg":
ensure => present,
mode => "0644",
owner => "root",
group => "root",
content => "command[check_disk] = ${nagios::common::libdir}/check_disk -c 10% -w 20% -p /\n",
require => File["/etc/nrpe.d"],
notify => Service["nrpe"],
}
@@nagios::service { "${fqdn}_disk":
command => "check_nrpe!check_disk",
description => "Disk",
}
@@nagios::service { "${fqdn}_load":
command => "check_nrpe!check_load",
description => "Load",
}
@@nagios::service { "${fqdn}_users":
command => "check_nrpe!check_users",
description => "Users",
}
@@nagios::service { "${fqdn}_procs":
command => "check_nrpe!check_total_procs",
description => "Processes",
}
}