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