Merge branch 'master' into puppet3
This commit is contained in:
commit
c8c5f097b4
12 changed files with 605 additions and 95 deletions
|
@ -33,6 +33,10 @@ class nagios::common {
|
|||
$cgibin = "/usr/lib/cgi-bin/nagios3"
|
||||
$htdocs = "/usr/share/nagios3/htdocs"
|
||||
}
|
||||
"openbsd": {
|
||||
# no params set as we don't support server on openbsd yet
|
||||
$libdir = "/usr/local/libexec/nagios"
|
||||
}
|
||||
default: {
|
||||
fail("Nagios not supported on ${::operatingsystem}")
|
||||
}
|
||||
|
@ -67,6 +71,9 @@ class nagios::server::manual inherits nagios::common {
|
|||
target => "/etc/nagios3/stylesheets",
|
||||
}
|
||||
}
|
||||
default: {
|
||||
fail("nagios::server not supported in ${::operatingsystem}")
|
||||
}
|
||||
}
|
||||
|
||||
exec { "usermod-nagios-httpsd":
|
||||
|
@ -418,9 +425,11 @@ define nagios::contact::pushover($token, $group=["all"],
|
|||
# Operating system name for hostextinfo.
|
||||
# $osicon:
|
||||
# Operating system icon name for hostextinfo.
|
||||
# $parent:
|
||||
# Parent hostname.
|
||||
#
|
||||
define nagios::host($group="NONE", $osname="NONE", $osicon="NONE",
|
||||
$confdir=$nagios::common::confdir) {
|
||||
$confdir=$nagios::common::confdir, $parent=undef) {
|
||||
|
||||
file { "${confdir}/host_${name}.cfg":
|
||||
ensure => present,
|
||||
|
@ -431,9 +440,14 @@ define nagios::host($group="NONE", $osname="NONE", $osicon="NONE",
|
|||
require => File["/etc/nagios/conf.d"],
|
||||
}
|
||||
nagios_host { $name:
|
||||
ensure => present,
|
||||
use => "default",
|
||||
target => "${confdir}/host_${name}.cfg"
|
||||
ensure => present,
|
||||
use => "default",
|
||||
target => "${confdir}/host_${name}.cfg",
|
||||
parents => is_array($parent) ? {
|
||||
true => inline_template('<%= parent.join(",") -%>'),
|
||||
false => $parent,
|
||||
},
|
||||
notify => Service["nagios"],
|
||||
}
|
||||
|
||||
if $osicon != "NONE" {
|
||||
|
@ -458,7 +472,8 @@ define nagios::host($group="NONE", $osname="NONE", $osicon="NONE",
|
|||
icon_image_alt => $osname,
|
||||
icon_image => "${iconpath}${osicon}.png",
|
||||
statusmap_image => "${iconpath}${osicon}.gd2",
|
||||
target => "${confdir}/hostextinfo_${name}.cfg"
|
||||
target => "${confdir}/hostextinfo_${name}.cfg",
|
||||
notify => Service["nagios"],
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
# Configure nagios target.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# $parent:
|
||||
# Parent hostname.
|
||||
#
|
||||
# === Global variables
|
||||
#
|
||||
# $nagios_target_group:
|
||||
# Host and service group name. Defaults to $domain.
|
||||
#
|
||||
class nagios::target {
|
||||
class nagios::target($parent=undef) {
|
||||
|
||||
if $nagios_target_group {
|
||||
$group = $nagios_target_group
|
||||
|
@ -24,6 +29,7 @@ class nagios::target {
|
|||
"" => "NONE",
|
||||
default => inline_template("<%= osfamily.downcase %>")
|
||||
},
|
||||
parent => $parent,
|
||||
}
|
||||
|
||||
Nagios::Service {
|
||||
|
@ -70,6 +76,18 @@ class nagios::target::https inherits nagios::target {
|
|||
}
|
||||
|
||||
|
||||
# Configure imaps service target.
|
||||
#
|
||||
class nagios::target::imaps inherits nagios::target {
|
||||
|
||||
@@nagios::service { "${::homename}_imaps":
|
||||
command => "check_imap!--ssl -p 993",
|
||||
description => "IMAPS",
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Configure smtp service target.
|
||||
#
|
||||
class nagios::target::smtp inherits nagios::target {
|
||||
|
@ -82,6 +100,42 @@ class nagios::target::smtp inherits nagios::target {
|
|||
}
|
||||
|
||||
|
||||
# Configure tcp connect service target.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# $name:
|
||||
# Short name
|
||||
# $port:
|
||||
# Port where to connect
|
||||
# $description:
|
||||
# Description of service. Defaults to $name
|
||||
#
|
||||
# === Sample usage
|
||||
#
|
||||
# nagios::target::tcp { "git":
|
||||
# port => "9418",
|
||||
# description => "GIT",
|
||||
# }
|
||||
#
|
||||
define nagios::target::tcp($port, $description=undef) {
|
||||
|
||||
include nagios::target
|
||||
|
||||
if ! $description {
|
||||
$description = $name
|
||||
}
|
||||
|
||||
@@nagios::service { "${::homename}_${name}":
|
||||
command => "check_tcp!${port}",
|
||||
description => $description,
|
||||
group => $nagios::target::group,
|
||||
host => $::homename,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Configure nagios nrpe target.
|
||||
#
|
||||
class nagios::target::nrpe inherits nagios::target {
|
||||
|
@ -96,31 +150,43 @@ class nagios::target::nrpe inherits nagios::target {
|
|||
"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"], 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"], Service["nrpe"] ],
|
||||
}
|
||||
"openbsd": {
|
||||
$service = "nrpe"
|
||||
$nrpedir = "/etc/nrpe.d"
|
||||
exec { "add-nrpe-include-dir":
|
||||
command => "echo 'include_dir=${nrpedir}/' >> /etc/nrpe.cfg",
|
||||
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||
user => "root",
|
||||
unless => "egrep '^include_dir=${nrpedir}/' /etc/nrpe.cfg",
|
||||
require => Package["nrpe"],
|
||||
notify => Service[$service],
|
||||
before => File[$nrpedir],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
package { "nrpe":
|
||||
ensure => installed,
|
||||
name => $::operatingsystem ? {
|
||||
"debian" => "nagios-nrpe-server",
|
||||
"ubuntu" => "nagios-nrpe-server",
|
||||
default => "nrpe",
|
||||
}
|
||||
}
|
||||
|
||||
file { "/etc/nrpe.d":
|
||||
ensure => directory,
|
||||
mode => "0644",
|
||||
owner => "root",
|
||||
group => "root",
|
||||
group => $::operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "root",
|
||||
},
|
||||
purge => true,
|
||||
force => true,
|
||||
recurse => true,
|
||||
|
@ -137,62 +203,125 @@ class nagios::target::nrpe inherits nagios::target {
|
|||
ensure => present,
|
||||
mode => "0644",
|
||||
owner => "root",
|
||||
group => "root",
|
||||
group => $::operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "root",
|
||||
},
|
||||
content => "allowed_hosts=${nagios_allow}\n",
|
||||
require => File["/etc/nrpe.d"],
|
||||
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 -w 20% -c 10% -p /\n",
|
||||
require => File["/etc/nrpe.d"],
|
||||
notify => Service["nrpe"],
|
||||
}
|
||||
@@nagios::service { "${::homename}_disk":
|
||||
command => "check_nrpe!check_disk",
|
||||
nagios::target::nrpe::service { "check_disk -w 20% -c 10% -p /":
|
||||
description => "Disk",
|
||||
package => $::operatingsystem ? {
|
||||
"openbsd" => undef,
|
||||
"debian" => "nagios-plugins-basic",
|
||||
"ubuntu" => "nagios-plugins-basic",
|
||||
default => "nagios-plugins-disk",
|
||||
}
|
||||
}
|
||||
|
||||
file { "${nrpedir}/check_load.cfg":
|
||||
ensure => present,
|
||||
mode => "0644",
|
||||
owner => "root",
|
||||
group => "root",
|
||||
content => "command[check_load]=${nagios::common::libdir}/check_load -r -w 3,2,1 -c 6,4,2\n",
|
||||
require => File["/etc/nrpe.d"],
|
||||
notify => Service["nrpe"],
|
||||
}
|
||||
@@nagios::service { "${::homename}_load":
|
||||
command => "check_nrpe!check_load",
|
||||
nagios::target::nrpe::service { "check_load -r -w 3,2,1 -c 6,4,2":
|
||||
description => "Load",
|
||||
package => $::operatingsystem ? {
|
||||
"openbsd" => undef,
|
||||
"debian" => "nagios-plugins-basic",
|
||||
"ubuntu" => "nagios-plugins-basic",
|
||||
default => "nagios-plugins-load",
|
||||
}
|
||||
}
|
||||
|
||||
file { "${nrpedir}/check_swap.cfg":
|
||||
ensure => present,
|
||||
mode => "0644",
|
||||
owner => "root",
|
||||
group => "root",
|
||||
content => "command[check_swap]=${nagios::common::libdir}/check_swap -w 75% -c 50%\n",
|
||||
require => File["/etc/nrpe.d"],
|
||||
notify => Service["nrpe"],
|
||||
}
|
||||
@@nagios::service { "${::homename}_swap":
|
||||
command => "check_nrpe!check_swap",
|
||||
nagios::target::nrpe::service { "check_swap -w 75% -c 50%":
|
||||
description => "Swap",
|
||||
package => $::operatingsystem ? {
|
||||
"openbsd" => undef,
|
||||
"debian" => "nagios-plugins-basic",
|
||||
"ubuntu" => "nagios-plugins-basic",
|
||||
default => "nagios-plugins-swap",
|
||||
}
|
||||
}
|
||||
|
||||
# @@nagios::service { "${::homename}_users":
|
||||
# command => "check_nrpe!check_users",
|
||||
# description => "Users",
|
||||
# }
|
||||
#
|
||||
# @@nagios::service { "${::homename}_procs":
|
||||
# command => "check_nrpe!check_total_procs",
|
||||
# description => "Processes",
|
||||
# }
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Add new nagios nrpe service check
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# $name:
|
||||
# Check command.
|
||||
# $description:
|
||||
# Service description. Defaults to command name without
|
||||
# check_ prefix.
|
||||
# $package:
|
||||
# Package providing check command.
|
||||
# $source:
|
||||
# Source file for check command.
|
||||
#
|
||||
# === Example usage
|
||||
#
|
||||
# nagios::target::nrpe::service { "check_disk -w 20% -c 10% -p /":
|
||||
# description => "Disk",
|
||||
# package => $::operatingsystem ? {
|
||||
# "openbsd" => undef,
|
||||
# "debian" => "nagios-plugins-basic",
|
||||
# "ubuntu" => "nagios-plugins-basic",
|
||||
# default => "nagios-plugins-disk",
|
||||
# }
|
||||
# }
|
||||
#
|
||||
define nagios::target::nrpe::service($source=undef,
|
||||
$description=undef,
|
||||
$package=undef) {
|
||||
|
||||
include nagios::target::nrpe
|
||||
|
||||
$binary = regsubst($name, '^([^ ]+) .*', '\1')
|
||||
$service = regsubst($binary, '^check_(.+)', '\1')
|
||||
|
||||
if !$description {
|
||||
$description = $service
|
||||
}
|
||||
|
||||
if $source {
|
||||
file { "${nagios::common::libdir}/${binary}":
|
||||
ensure => present,
|
||||
source => $source,
|
||||
mode => "0755",
|
||||
owner => "root",
|
||||
group => $::operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "root",
|
||||
},
|
||||
require => Package["nrpe"],
|
||||
notify => Service["nrpe"],
|
||||
}
|
||||
}
|
||||
|
||||
if $package and !defined(Package[$package]) {
|
||||
package { $package:
|
||||
ensure => present,
|
||||
require => Package["nrpe"],
|
||||
before => Service["nrpe"],
|
||||
}
|
||||
}
|
||||
|
||||
file { "${nagios::target::nrpe::nrpedir}/${binary}.cfg":
|
||||
ensure => present,
|
||||
mode => "0644",
|
||||
owner => "root",
|
||||
group => $::operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "root",
|
||||
},
|
||||
content => "command[${binary}]=${nagios::common::libdir}/${name}\n",
|
||||
require => File["/etc/nrpe.d"],
|
||||
notify => Service["nrpe"],
|
||||
}
|
||||
|
||||
@@nagios::service { "${::homename}_${service}":
|
||||
command => "check_nrpe!${binary}",
|
||||
description => $description,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue