summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2013-01-02 19:54:17 +0100
committermh <mh@immerda.ch>2013-01-02 19:54:17 +0100
commit8b4e71729288d25e44d8433be27dc1a5d9fe63d9 (patch)
tree5460675cf9f10df08f298c777d1e37d8fbcfbb6f /manifests
parent4d2d0a813a718ad412fbd05da8588b8e90d0b9a3 (diff)
parent4d6b051acd53217860e1401946e45550e20c91a0 (diff)
Merge remote-tracking branch 'shared/master'
Conflicts: README manifests/service.pp
Diffstat (limited to 'manifests')
-rw-r--r--manifests/command/nrpe.pp14
-rw-r--r--manifests/command/nrpe_timeout.pp11
-rw-r--r--manifests/nrpe.pp22
-rw-r--r--manifests/nrpe/base.pp50
-rw-r--r--manifests/nrpe/command.pp33
-rw-r--r--manifests/nrpe/freebsd.pp16
-rw-r--r--manifests/nrpe/linux.pp9
-rw-r--r--manifests/nrpe/xinetd.pp11
-rw-r--r--manifests/nsca/server.pp1
-rw-r--r--manifests/service.pp20
10 files changed, 184 insertions, 3 deletions
diff --git a/manifests/command/nrpe.pp b/manifests/command/nrpe.pp
new file mode 100644
index 0000000..7539a26
--- /dev/null
+++ b/manifests/command/nrpe.pp
@@ -0,0 +1,14 @@
+class nagios::command::nrpe {
+
+ # this command runs a program $ARG1$ with arguments $ARG2$
+ nagios_command {
+ 'check_nrpe':
+ command_line => '/usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$'
+ }
+
+ # this command runs a program $ARG1$ with no arguments
+ nagios_command {
+ 'check_nrpe_1arg':
+ command_line => '/usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$'
+ }
+}
diff --git a/manifests/command/nrpe_timeout.pp b/manifests/command/nrpe_timeout.pp
new file mode 100644
index 0000000..3415566
--- /dev/null
+++ b/manifests/command/nrpe_timeout.pp
@@ -0,0 +1,11 @@
+class nagios::command::nrpe_timeout {
+ nagios_command {
+ 'check_nrpe_timeout':
+ command_line => '/usr/lib/nagios/plugins/check_nrpe -t $ARG1$ -H $HOSTADDRESS$ -c $ARG2$ -a $ARG3$'
+ }
+
+ nagios_command {
+ 'check_nrpe_1arg_timeout':
+ command_line => '/usr/lib/nagios/plugins/check_nrpe -t $ARG1$ -H $HOSTADDRESS$ -c $ARG2$'
+ }
+}
diff --git a/manifests/nrpe.pp b/manifests/nrpe.pp
new file mode 100644
index 0000000..5c05ed4
--- /dev/null
+++ b/manifests/nrpe.pp
@@ -0,0 +1,22 @@
+class nagios::nrpe {
+
+ case $operatingsystem {
+ 'FreeBSD': {
+ if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/usr/local/etc' }
+ if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/spool/nagios/nrpe2.pid' }
+ if $nagios_plugin_dir == '' { $nagios_plugin_dir = '/usr/local/libexec/nagios' }
+
+ include nagios::nrpe::freebsd
+ }
+ default: {
+ if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/run/nrpe.pid' }
+ if $nagios_plugin_dir == '' { $nagios_plugin_dir = '/usr/lib/nagios/plugins' }
+
+ case $kernel {
+ linux: { include nagios::nrpe::linux }
+ default: { include nagios::nrpe::base }
+ }
+ }
+ }
+
+}
diff --git a/manifests/nrpe/base.pp b/manifests/nrpe/base.pp
new file mode 100644
index 0000000..17abb04
--- /dev/null
+++ b/manifests/nrpe/base.pp
@@ -0,0 +1,50 @@
+class nagios::nrpe::base {
+
+ if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/etc/nagios' }
+ if $processorcount == '' { $processorcount = 1 }
+
+ package { "nagios-nrpe-server": ensure => present;
+ "nagios-plugins-basic": ensure => present;
+ "libwww-perl": ensure => present; # for check_apache
+ }
+
+ # Special-case lenny. the package doesn't exist
+ if $lsbdistcodename != 'lenny' {
+ package { "libnagios-plugin-perl": ensure => present; }
+ }
+
+ file { [ $nagios_nrpe_cfgdir, "$nagios_nrpe_cfgdir/nrpe.d" ]:
+ ensure => directory }
+
+ if $nagios_nrpe_dont_blame == '' { $nagios_nrpe_dont_blame = 1 }
+ file { "$nagios_nrpe_cfgdir/nrpe.cfg":
+ content => template('nagios/nrpe/nrpe.cfg'),
+ owner => root, group => 0, mode => 644;
+ }
+
+ # default commands
+ nagios::nrpe::command { "basic_nrpe":
+ source => [ "puppet:///modules/site-nagios/configs/nrpe/nrpe_commands.${fqdn}.cfg",
+ "puppet:///modules/site-nagios/configs/nrpe/nrpe_commands.cfg",
+ "puppet:///modules/nagios/nrpe/nrpe_commands.cfg" ],
+ }
+ # the check for load should be customized for each server based on number
+ # of CPUs and the type of activity.
+ $warning_1_threshold = 7 * $processorcount
+ $warning_5_threshold = 6 * $processorcount
+ $warning_15_threshold = 5 * $processorcount
+ $critical_1_threshold = 10 * $processorcount
+ $critical_5_threshold = 9 * $processorcount
+ $critical_15_threshold = 8 * $processorcount
+ nagios::nrpe::command { "check_load":
+ command_line => "${nagios_plugin_dir}/check_load -w ${warning_1_threshold},${warning_5_threshold},${warning_15_threshold} -c ${critical_1_threshold},${critical_5_threshold},${critical_15_threshold}",
+ }
+
+ service { "nagios-nrpe-server":
+ ensure => running,
+ enable => true,
+ pattern => "nrpe",
+ subscribe => File["$nagios_nrpe_cfgdir/nrpe.cfg"],
+ require => Package["nagios-nrpe-server"],
+ }
+}
diff --git a/manifests/nrpe/command.pp b/manifests/nrpe/command.pp
new file mode 100644
index 0000000..e6ebdae
--- /dev/null
+++ b/manifests/nrpe/command.pp
@@ -0,0 +1,33 @@
+define nagios::nrpe::command (
+ $ensure = present,
+ $command_line = '',
+ $source = '' )
+{
+ if ($command_line == '' and $source == '') {
+ fail ( "Either one of 'command_line' or 'source' must be given to nagios::nrpe::command." )
+ }
+
+ if $nagios_nrpe_cfg_dir == '' {
+ $nagios_nrpe_cfgdir = $nagios::nrpe::base::nagios_nrpe_cfgdir
+ }
+
+ file { "$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg":
+ ensure => $ensure,
+ mode => 644, owner => root, group => 0,
+ notify => Service['nagios-nrpe-server'],
+ require => File [ "$nagios_nrpe_cfgdir/nrpe.d" ]
+ }
+
+ case $source {
+ '': {
+ File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] {
+ content => template( "nagios/nrpe/nrpe_command.erb" ),
+ }
+ }
+ default: {
+ File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] {
+ source => $source,
+ }
+ }
+ }
+}
diff --git a/manifests/nrpe/freebsd.pp b/manifests/nrpe/freebsd.pp
new file mode 100644
index 0000000..063b79b
--- /dev/null
+++ b/manifests/nrpe/freebsd.pp
@@ -0,0 +1,16 @@
+class nagios::nrpe::freebsd inherits nagios::nrpe::base {
+
+ Package["nagios-nrpe-server"] { name => "nrpe" }
+ Package["nagios-plugins-basic"] { name => "nagios-plugins" }
+ Package["libnagios-plugin-perl"] { name => "p5-Nagios-Plugin" }
+ Package["libwww-perl"] { name => "p5-libwww" }
+
+ # TODO check_cpustats.sh is probably not working as of now. the package 'sysstat' is not available under FreeBSD
+
+ Service["nagios-nrpe-server"] {
+ pattern => "^/usr/local/sbin/nrpe2",
+ path => "/usr/local/etc/rc.d",
+ name => "nrpe2",
+ hasstatus => "false",
+ }
+}
diff --git a/manifests/nrpe/linux.pp b/manifests/nrpe/linux.pp
new file mode 100644
index 0000000..14e007f
--- /dev/null
+++ b/manifests/nrpe/linux.pp
@@ -0,0 +1,9 @@
+class nagios::nrpe::linux inherits nagios::nrpe::base {
+
+ package {
+ "nagios-plugins-standard": ensure => present;
+ "ksh": ensure => present; # for check_cpustats.sh
+ "sysstat": ensure => present; # for check_cpustats.sh
+ }
+
+}
diff --git a/manifests/nrpe/xinetd.pp b/manifests/nrpe/xinetd.pp
new file mode 100644
index 0000000..e13ed76
--- /dev/null
+++ b/manifests/nrpe/xinetd.pp
@@ -0,0 +1,11 @@
+# This is created only to cope with cases where we're not the only ones
+# administering a machine and NRPE is running in xinetd.
+class nagios::nrpe::xinetd inherits base {
+
+ Service ["nagios-nrpe-server"] {
+ ensure => stopped,
+ }
+
+ # TODO manage the xinetd config file that glues with NRPE
+
+}
diff --git a/manifests/nsca/server.pp b/manifests/nsca/server.pp
index 8ba0116..bd5389d 100644
--- a/manifests/nsca/server.pp
+++ b/manifests/nsca/server.pp
@@ -6,6 +6,7 @@ class nagios::nsca::server {
ensure => running,
hasstatus => false,
hasrestart => true,
+ require => Package['nsca'],
}
file { '/etc/nsca.cfg':
diff --git a/manifests/service.pp b/manifests/service.pp
index 9eb993e..134d1f7 100644
--- a/manifests/service.pp
+++ b/manifests/service.pp
@@ -11,8 +11,11 @@ define nagios::service (
$notification_options = '',
$contact_groups = '',
$use = 'generic-service',
- $service_description = 'absent' )
-{
+ $service_description = 'absent',
+ $use_nrpe = '',
+ $nrpe_args = '',
+ $nrpe_timeout = 10
+) {
# TODO: this resource should normally accept all nagios_host parameters
@@ -25,7 +28,18 @@ define nagios::service (
if $ensure != 'absent' {
if $check_comand == 'absent' {
- fail("Must pass a check_command to ${name} if it should be present")
+ fail("Must pass a check_command to ${name} if it should be present")
+ }
+ if ($use_nrpe == 'true') {
+ include nagios::command::nrpe_timeout
+
+ if ($nrpe_args != '') {
+ $real_check_command = "check_nrpe_timeout!$nrpe_timeout!$check_command!\"$nrpe_args\""
+ } else {
+ $real_check_command = "check_nrpe_1arg_timeout!$nrpe_timeout!$check_command"
+ }
+ } else {
+ $real_check_command = "$check_command"
}
Nagios_service["${real_name}"] {