nagios: Moved nrpe services to nagios::target::nrpe::service define.
This commit is contained in:
parent
19df011191
commit
74062b3461
1 changed files with 114 additions and 71 deletions
|
@ -108,31 +108,14 @@ 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-swap",
|
||||
"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"
|
||||
package { "nrpe":
|
||||
ensure => installed,
|
||||
}
|
||||
exec { "add-nrpe-include-dir":
|
||||
command => "echo 'include_dir=${nrpedir}/' >> /etc/nrpe.cfg",
|
||||
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||
|
@ -145,6 +128,15 @@ class nagios::target::nrpe inherits nagios::target {
|
|||
}
|
||||
}
|
||||
|
||||
package { "nrpe":
|
||||
ensure => installed,
|
||||
name => $::operatingsystem ? {
|
||||
"debian" => "nagios-nrpe-server",
|
||||
"ubuntu" => "nagios-nrpe-server",
|
||||
default => "nrpe",
|
||||
}
|
||||
}
|
||||
|
||||
file { "/etc/nrpe.d":
|
||||
ensure => directory,
|
||||
mode => "0644",
|
||||
|
@ -178,65 +170,116 @@ class nagios::target::nrpe inherits nagios::target {
|
|||
notify => Service["nrpe"],
|
||||
}
|
||||
|
||||
file { "${nrpedir}/check_disk.cfg":
|
||||
ensure => present,
|
||||
mode => "0644",
|
||||
owner => "root",
|
||||
group => $::operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "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 => $::operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "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 => $::operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "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
Reference in a new issue