Added nagios class for manual server configuration
This commit is contained in:
parent
2a80b58e04
commit
998dc8e8eb
1 changed files with 31 additions and 16 deletions
|
@ -1,8 +1,8 @@
|
|||
# Install Nagios server.
|
||||
# Common nagios variables.
|
||||
#
|
||||
class nagios::server {
|
||||
class nagios::common {
|
||||
|
||||
case $operatingsystem {
|
||||
case $::operatingsystem {
|
||||
"centos","redhat","fedora": {
|
||||
$etcdir = "/etc/nagios"
|
||||
$confdir = "${etcdir}/conf.d"
|
||||
|
@ -10,11 +10,11 @@ class nagios::server {
|
|||
$package = "nagios"
|
||||
$service = "nagios"
|
||||
$scriptalias = "/nagios/cgi-bin/"
|
||||
$libdir = $architecture ? {
|
||||
$libdir = $::architecture ? {
|
||||
"x86_64" => "/usr/lib64/nagios/plugins",
|
||||
default => "/usr/lib/nagios/plugins",
|
||||
}
|
||||
$cgibin = $architecture ? {
|
||||
$cgibin = $::architecture ? {
|
||||
"x86_64" => "/usr/lib64/nagios/cgi-bin",
|
||||
default => "/usr/lib/nagios/cgi-bin",
|
||||
}
|
||||
|
@ -32,16 +32,23 @@ class nagios::server {
|
|||
$htdocs = "/usr/share/nagios3/htdocs"
|
||||
}
|
||||
default: {
|
||||
fail("nagios::server not supported on ${::operatingsystem}")
|
||||
fail("Nagios not supported on ${::operatingsystem}")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Install Nagios server.
|
||||
#
|
||||
class nagios::server::manual inherits nagios::common {
|
||||
|
||||
package { "nagios":
|
||||
name => $package,
|
||||
ensure => installed,
|
||||
}
|
||||
|
||||
case $operatingsystem {
|
||||
case $::operatingsystem {
|
||||
"centos","redhat","fedora": {
|
||||
package { [ "nagios-plugins-all",
|
||||
"nagios-plugins-nrpe", ]:
|
||||
|
@ -76,7 +83,7 @@ class nagios::server {
|
|||
owner => "root",
|
||||
group => "root",
|
||||
source => [ "puppet:///files/nagios/htaccess",
|
||||
"puppet:///modules/nagios/htaccess.${osfamily}", ],
|
||||
"puppet:///modules/nagios/htaccess.${::osfamily}", ],
|
||||
require => Package["nagios"],
|
||||
}
|
||||
|
||||
|
@ -86,7 +93,7 @@ class nagios::server {
|
|||
mode => "0644",
|
||||
owner => "root",
|
||||
group => "root",
|
||||
source => "puppet:///modules/nagios/nagios.cfg.${osfamily}",
|
||||
source => "puppet:///modules/nagios/nagios.cfg.${::osfamily}",
|
||||
require => Package["nagios"],
|
||||
notify => Service["nagios"],
|
||||
}
|
||||
|
@ -250,6 +257,13 @@ class nagios::server {
|
|||
notify => Service["nagios"],
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Install Nagios server and collect node configurations.
|
||||
#
|
||||
class nagios::server inherits nagios::server::manual {
|
||||
|
||||
Nagios::Host <<||>> {
|
||||
confdir => $confdir,
|
||||
notify => Service["nagios"],
|
||||
|
@ -261,6 +275,7 @@ class nagios::server {
|
|||
|
||||
}
|
||||
|
||||
|
||||
# Define nagios email contact.
|
||||
#
|
||||
# === Parameters
|
||||
|
@ -268,7 +283,7 @@ class nagios::server {
|
|||
# $name:
|
||||
# Email address.
|
||||
#
|
||||
define nagios::contact::email($confdir=$nagios::server::confdir) {
|
||||
define nagios::contact::email($confdir=$nagios::common::confdir) {
|
||||
|
||||
file { "${confdir}/contact_${name}.cfg":
|
||||
ensure => present,
|
||||
|
@ -300,7 +315,7 @@ define nagios::contact::email($confdir=$nagios::server::confdir) {
|
|||
# $name:
|
||||
# Prowl API key.
|
||||
#
|
||||
define nagios::contact::prowl($confdir=$nagios::server::confdir) {
|
||||
define nagios::contact::prowl($confdir=$nagios::common::confdir) {
|
||||
|
||||
file { "${confdir}/contact_${name}.cfg":
|
||||
ensure => present,
|
||||
|
@ -554,7 +569,7 @@ class nagios::plugin::esxi {
|
|||
},
|
||||
}
|
||||
|
||||
file { "${nagios::server::libdir}/check_esxi_hardware.py":
|
||||
file { "${nagios::common::libdir}/check_esxi_hardware.py":
|
||||
ensure => present,
|
||||
mode => "0755",
|
||||
owner => "root",
|
||||
|
@ -581,7 +596,7 @@ class nagios::plugin::esxi {
|
|||
#
|
||||
define nagios::host::esxi($user, $pass, $vendor="auto") {
|
||||
|
||||
file { "${nagios::server::private}/esxi_${name}.cfg":
|
||||
file { "${nagios::common::private}/esxi_${name}.cfg":
|
||||
ensure => present,
|
||||
mode => "0640",
|
||||
owner => "root",
|
||||
|
@ -591,15 +606,15 @@ define nagios::host::esxi($user, $pass, $vendor="auto") {
|
|||
}
|
||||
|
||||
nagios::host { $name:
|
||||
confdir => $nagios::server::confdir,
|
||||
confdir => $nagios::common::confdir,
|
||||
notify => Service["nagios"],
|
||||
}
|
||||
|
||||
nagios::service { "${name}_esxi":
|
||||
host => $name,
|
||||
command => "check_esxi_hardware!${nagios::server::private}/esxi_${name}.cfg!${vendor}",
|
||||
command => "check_esxi_hardware!${nagios::common::private}/esxi_${name}.cfg!${vendor}",
|
||||
description => "ESXi",
|
||||
confdir => $nagios::server::confdir,
|
||||
confdir => $nagios::common::confdir,
|
||||
notify => Service["nagios"],
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue