summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2015-10-25 14:43:23 +0100
committermh <mh@immerda.ch>2015-10-25 14:44:25 +0100
commitedd580ab2dc92adcb8291fd17d268cfbb6226c3b (patch)
tree2c713b514212c71d67ae90d6f31041630941a616 /manifests
parentcfff7d115e4cff2a4aa5bcfbd01e7ebe265b7a48 (diff)
parentf215de3de43f141ae71fd124a84003d157da7295 (diff)
Merge remote-tracking branch 'shared/master'
Diffstat (limited to 'manifests')
-rw-r--r--manifests/apache.pp26
-rw-r--r--manifests/base.pp76
-rw-r--r--manifests/centos.pp49
-rw-r--r--manifests/debian/apache.pp22
-rw-r--r--manifests/defaults/commands.pp142
-rw-r--r--manifests/init.pp13
-rw-r--r--manifests/nrpe.pp36
-rw-r--r--manifests/plugin.pp35
-rw-r--r--manifests/target.pp13
9 files changed, 233 insertions, 179 deletions
diff --git a/manifests/apache.pp b/manifests/apache.pp
index a90d0ee..8da9c11 100644
--- a/manifests/apache.pp
+++ b/manifests/apache.pp
@@ -1,29 +1,13 @@
+# setup naguis together with apache
class nagios::apache(
$allow_external_cmd = false,
$manage_shorewall = false,
$manage_munin = false
) {
- class{'nagios':
- httpd => 'apache',
+ class{'::nagios':
+ httpd => 'apache',
allow_external_cmd => $allow_external_cmd,
- manage_munin => $manage_munin,
- manage_shorewall => $manage_shorewall,
- }
-
- case $::operatingsystem {
- 'debian': {
- file { "${nagios::defaults::vars::int_cfgdir}/apache2.conf":
- ensure => present,
- source => [ "puppet:///site_nagios/configs/${::fqdn}/apache2.conf",
- "puppet:///site_nagios/configs/apache2.conf",
- "puppet:///nagios/configs/apache2.conf"],
- }
-
- apache::config::global { "nagios3.conf":
- ensure => link,
- target => "${nagios::defaults::vars::int_cfgdir}/apache2.conf",
- require => File["${nagios::defaults::vars::int_cfgdir}/apache2.conf"],
- }
- }
+ manage_munin => $manage_munin,
+ manage_shorewall => $manage_shorewall,
}
}
diff --git a/manifests/base.pp b/manifests/base.pp
index fa28c41..4922cdb 100644
--- a/manifests/base.pp
+++ b/manifests/base.pp
@@ -1,7 +1,7 @@
# basic stuff for nagios
class nagios::base {
# include the variables
- include nagios::defaults::vars
+ include ::nagios::defaults::vars
package { 'nagios':
ensure => present,
@@ -10,7 +10,6 @@ class nagios::base {
service { 'nagios':
ensure => running,
enable => $nagios::service_at_boot,
- #hasstatus => true, #fixme!
require => Package['nagios'],
}
@@ -24,17 +23,18 @@ class nagios::base {
recurse => true,
purge => true,
force => true,
+ require => Package['nagios'],
notify => Service['nagios'],
owner => root,
group => root,
mode => '0755';
'nagios_main_cfg':
path => "${cfg_dir}/nagios.cfg",
- source => ["puppet:///modules/site_nagios/configs/${::fqdn}/nagios.cfg",
- "puppet:///modules/site_nagios/configs/${::operatingsystem}/nagios.cfg",
- 'puppet:///modules/site_nagios/configs/nagios.cfg',
- "puppet:///modules/nagios/configs/${::operatingsystem}/nagios.cfg",
- 'puppet:///modules/nagios/configs/nagios.cfg' ],
+ source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/nagios.cfg",
+ "puppet:///modules/site_nagios/configs/${::operatingsystem}/nagios.cfg",
+ 'puppet:///modules/site_nagios/configs/nagios.cfg',
+ "puppet:///modules/nagios/configs/${::operatingsystem}/nagios.cfg",
+ 'puppet:///modules/nagios/configs/nagios.cfg' ],
notify => Service['nagios'],
owner => root,
group => root,
@@ -42,34 +42,25 @@ class nagios::base {
'nagios_cgi_cfg':
path => "${cfg_dir}/cgi.cfg",
source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/cgi.cfg",
- "puppet:///modules/site_nagios/configs/${::operatingsystem}/cgi.cfg",
- 'puppet:///modules/site_nagios/configs/cgi.cfg',
- "puppet:///modules/nagios/configs/${::operatingsystem}/cgi.cfg",
- 'puppet:///modules/nagios/configs/cgi.cfg' ],
+ "puppet:///modules/site_nagios/configs/${::operatingsystem}/cgi.cfg",
+ 'puppet:///modules/site_nagios/configs/cgi.cfg',
+ "puppet:///modules/nagios/configs/${::operatingsystem}/cgi.cfg",
+ 'puppet:///modules/nagios/configs/cgi.cfg' ],
notify => Service['apache'],
owner => 'root',
group => 0,
mode => '0644';
'nagios_htpasswd':
path => "${cfg_dir}/htpasswd.users",
- source => ['puppet:///modules/site_nagios/htpasswd.users',
- 'puppet:///modules/nagios/htpasswd.users' ],
+ source => [ 'puppet:///modules/site_nagios/htpasswd.users',
+ 'puppet:///modules/nagios/htpasswd.users' ],
owner => root,
group => apache,
mode => '0640';
- 'nagios_private':
- ensure => directory,
- path => "${cfg_dir}/private",
- purge => true,
- recurse => true,
- notify => Service['nagios'],
- owner => root,
- group => nagios,
- mode => '0750';
- 'nagios_private_resource_cfg':
- path => "${cfg_dir}/private/resource.cfg",
+ 'nagios_resource_cfg':
+ path => "${cfg_dir}/resource.cfg",
source => [ "puppet:///modules/site_nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}",
- "puppet:///modules/nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}" ],
+ "puppet:///modules/nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}" ],
notify => Service['nagios'],
owner => root,
group => nagios,
@@ -78,8 +69,9 @@ class nagios::base {
if $cfg_dir == '/etc/nagios3' {
file{'/etc/nagios':
- ensure => link,
- target => $cfg_dir,
+ ensure => link,
+ target => $cfg_dir,
+ require => Package['nagios'],
}
}
@@ -142,21 +134,21 @@ class nagios::base {
}
file{
- ["${cfg_dir}/nagios_command.cfg",
- "${cfg_dir}/nagios_contact.cfg",
- "${cfg_dir}/nagios_contactgroup.cfg",
- "${cfg_dir}/nagios_host.cfg",
- "${cfg_dir}/nagios_hostdependency.cfg",
- "${cfg_dir}/nagios_hostescalation.cfg",
- "${cfg_dir}/nagios_hostextinfo.cfg",
- "${cfg_dir}/nagios_hostgroup.cfg",
- "${cfg_dir}/nagios_hostgroupescalation.cfg",
- "${cfg_dir}/nagios_service.cfg",
- "${cfg_dir}/nagios_servicedependency.cfg",
- "${cfg_dir}/nagios_serviceescalation.cfg",
- "${cfg_dir}/nagios_serviceextinfo.cfg",
- "${cfg_dir}/nagios_servicegroup.cfg",
- "${cfg_dir}/nagios_timeperiod.cfg" ]:
+ [ "${cfg_dir}/nagios_command.cfg",
+ "${cfg_dir}/nagios_contact.cfg",
+ "${cfg_dir}/nagios_contactgroup.cfg",
+ "${cfg_dir}/nagios_host.cfg",
+ "${cfg_dir}/nagios_hostdependency.cfg",
+ "${cfg_dir}/nagios_hostescalation.cfg",
+ "${cfg_dir}/nagios_hostextinfo.cfg",
+ "${cfg_dir}/nagios_hostgroup.cfg",
+ "${cfg_dir}/nagios_hostgroupescalation.cfg",
+ "${cfg_dir}/nagios_service.cfg",
+ "${cfg_dir}/nagios_servicedependency.cfg",
+ "${cfg_dir}/nagios_serviceescalation.cfg",
+ "${cfg_dir}/nagios_serviceextinfo.cfg",
+ "${cfg_dir}/nagios_servicegroup.cfg",
+ "${cfg_dir}/nagios_timeperiod.cfg" ]:
ensure => file,
replace => false,
notify => Service['nagios'],
diff --git a/manifests/centos.pp b/manifests/centos.pp
index 5a2ba23..f41d46d 100644
--- a/manifests/centos.pp
+++ b/manifests/centos.pp
@@ -1,19 +1,42 @@
+# centos specific changes
class nagios::centos inherits nagios::base {
- package { [ 'nagios-plugins', 'nagios-plugins-smtp','nagios-plugins-http', 'nagios-plugins-ssh', 'nagios-plugins-tcp', 'nagios-plugins-dig', 'nagios-plugins-nrpe', 'nagios-plugins-load', 'nagios-plugins-dns', 'nagios-plugins-ping', 'nagios-plugins-procs', 'nagios-plugins-users', 'nagios-plugins-ldap', 'nagios-plugins-disk', 'nagios-plugins-swap', 'nagios-plugins-nagios', 'nagios-plugins-perl', 'nagios-plugins-ntp', 'nagios-plugins-snmp' ]:
- ensure => 'present',
- notify => Service['nagios'],
- }
+ package { [ 'nagios-plugins', 'nagios-plugins-smtp','nagios-plugins-http',
+ 'nagios-plugins-ssh', 'nagios-plugins-tcp', 'nagios-plugins-dig',
+ 'nagios-plugins-nrpe', 'nagios-plugins-load', 'nagios-plugins-dns',
+ 'nagios-plugins-ping', 'nagios-plugins-procs', 'nagios-plugins-users',
+ 'nagios-plugins-ldap', 'nagios-plugins-disk', 'nagios-plugins-swap',
+ 'nagios-plugins-nagios', 'nagios-plugins-perl', 'nagios-plugins-ntp',
+ 'nagios-plugins-snmp' ]:
+ ensure => 'present',
+ notify => Service['nagios'],
+ }
- Service[nagios]{
- hasstatus => true,
- }
+ Service['nagios']{
+ hasstatus => true,
+ }
- if $nagios::allow_external_cmd {
- file { '/var/spool/nagios/cmd':
- ensure => 'directory',
- require => Package['nagios'],
- mode => 2660, owner => apache, group => nagios,
- }
+ file{
+ 'nagios_private':
+ ensure => directory,
+ path => "${nagios::base::cfg_dir}/private",
+ purge => true,
+ recurse => true,
+ notify => Service['nagios'],
+ owner => root,
+ group => nagios,
+ mode => '0750';
+ }
+ File['nagios_resource_cfg']{
+ path => "${nagios::base::cfg_dir}/private/resource.cfg",
+ }
+ if $nagios::allow_external_cmd {
+ file{'/var/spool/nagios/cmd':
+ ensure => 'directory',
+ require => Package['nagios'],
+ owner => apache,
+ group => nagios,
+ mode => '2660',
}
+ }
}
diff --git a/manifests/debian/apache.pp b/manifests/debian/apache.pp
new file mode 100644
index 0000000..17b60c6
--- /dev/null
+++ b/manifests/debian/apache.pp
@@ -0,0 +1,22 @@
+# Handle files that are specifically needed for nagios with apache on debian
+#
+# Do not include this class directly. It is included by the nagios class and
+# needs variables from it.
+#
+class nagios::debian::apache {
+
+ include ::nagios::defaults::vars
+
+ file { "${nagios::defaults::vars::int_cfgdir}/apache2.conf":
+ source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/apache2.conf",
+ 'puppet:///modules/site_nagios/configs/apache2.conf',
+ 'puppet:///modules/nagios/configs/apache2.conf'],
+ }
+
+ apache::config::global { 'nagios3.conf':
+ ensure => link,
+ target => "${nagios::defaults::vars::int_cfgdir}/apache2.conf",
+ require => File["${nagios::defaults::vars::int_cfgdir}/apache2.conf"],
+ }
+
+}
diff --git a/manifests/defaults/commands.pp b/manifests/defaults/commands.pp
index fc552b4..e80e147 100644
--- a/manifests/defaults/commands.pp
+++ b/manifests/defaults/commands.pp
@@ -7,85 +7,85 @@ class nagios::defaults::commands {
# common service commands
case $::operatingsystem {
- debian,ubuntu: {
+ 'Debian','Ubuntu': {
nagios_command {
- check_dummy:
+ 'check_dummy':
command_line => '$USER1$/check_dummy $ARG1$';
- check_https_cert:
+ 'check_https_cert':
command_line => '$USER1$/check_http --ssl -C 20 -H $HOSTADDRESS$ -I $HOSTADDRESS$';
- check_http_url:
+ 'check_http_url':
command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$';
- check_http_url_regex:
- command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$ -e $ARG3$';
- check_https_url:
+ 'check_http_url_regex':
+ command_line => '$USER1$/check_http -H $ARG1$ -p $ARG2$ -u $ARG3$ -e $ARG4$';
+ 'check_https_url':
command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$';
- check_https_url_regex:
+ 'check_https_url_regex':
command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$ -e $ARG3$';
- check_mysql_db:
+ 'check_mysql_db':
command_line => '$USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$ -d $ARG5$';
- check_ntp_time:
+ 'check_ntp_time':
command_line => '$USER1$/check_ntp_time -H $HOSTADDRESS$ -w 0.5 -c 1';
- check_silc:
+ 'check_silc':
command_line => '$USER1$/check_tcp -p 706 -H $ARG1$';
- check_sobby:
+ 'check_sobby':
command_line => '$USER1$/check_tcp -H $ARG1$ -p $ARG2$';
- check_jabber:
+ 'check_jabber':
command_line => '$USER1$/check_jabber -H $ARG1$';
- check_git:
+ 'check_git':
command_line => '$USER1$/check_tcp -H $ARG1$ -p 9418';
}
}
default: {
nagios_command {
- check_dummy:
+ 'check_dummy':
command_line => '$USER1$/check_dummy $ARG1$';
- check_ping:
+ 'check_ping':
command_line => '$USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$';
- check-host-alive:
+ 'check-host-alive':
command_line => '$USER1$/check_ping -H $HOSTADDRESS$ -w 5000,100% -c 5000,100% -p 1';
- check_tcp:
+ 'check_tcp':
command_line => '$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$';
- check_udp:
+ 'check_udp':
command_line => '$USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$';
- check_load:
+ 'check_load':
command_line => '$USER1$/check_load --warning=$ARG1$,$ARG2$,$ARG3$ --critical=$ARG4$,$ARG5$,$ARG6$';
- check_disk:
+ 'check_disk':
command_line => '$USER1$/check_disk -w $ARG1$ -c $ARG2$ -e -p $ARG3$';
- check_all_disks:
+ 'check_all_disks':
command_line => '$USER1$/check_disk -w $ARG1$ -c $ARG2$ -e';
- check_ssh:
+ 'check_ssh':
command_line => '$USER1$/check_ssh $HOSTADDRESS$';
- check_ssh_port:
+ 'check_ssh_port':
command_line => '$USER1$/check_ssh -p $ARG1$ $HOSTADDRESS$';
- check_ssh_port_host:
+ 'check_ssh_port_host':
command_line => '$USER1$/check_ssh -p $ARG1$ $ARG2$';
- check_http:
+ 'check_http':
command_line => '$USER1$/check_http -H $HOSTADDRESS$ -I $HOSTADDRESS$';
- check_https:
+ 'check_https':
command_line => '$USER1$/check_http --ssl -H $HOSTADDRESS$ -I $HOSTADDRESS$';
- check_https_cert:
+ 'check_https_cert':
command_line => '$USER1$/check_http --ssl -C 20 -H $HOSTADDRESS$ -I $HOSTADDRESS$';
- check_http_url:
+ 'check_http_url':
command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$';
- check_http_url_regex:
+ 'check_http_url_regex':
command_line => '$USER1$/check_http -H $ARG1$ -p $ARG2$ -u $ARG3$ -e $ARG4$';
- check_https_url:
+ 'check_https_url':
command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$';
- check_https_url_regex:
+ 'check_https_url_regex':
command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$ -e $ARG3$';
- check_mysql:
+ 'check_mysql':
command_line => '$USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$';
- check_mysql_db:
+ 'check_mysql_db':
command_line => '$USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$ -d $ARG5$';
- check_ntp_time:
+ 'check_ntp_time':
command_line => '$USER1$/check_ntp_time -H $HOSTADDRESS$ -w 0.5 -c 1';
- check_silc:
+ 'check_silc':
command_line => '$USER1$/check_tcp -p 706 -H $ARG1$';
- check_sobby:
+ 'check_sobby':
command_line => '$USER1$/check_tcp -H $ARG1$ -p $ARG2$';
- check_jabber:
+ 'check_jabber':
command_line => '$USER1$/check_jabber -H $ARG1$';
- check_git:
+ 'check_git':
command_line => '$USER1$/check_tcp -H $ARG1$ -p 9418';
}
}
@@ -94,48 +94,52 @@ class nagios::defaults::commands {
# commands for services defined by other modules
nagios_command {
- # from apache module
- http_port:
- command_line => '$USER1$/check_http -p $ARG1$ -H $HOSTADDRESS$ -I $HOSTADDRESS$';
+ # from apache module
+ 'http_port':
+ command_line => '$USER1$/check_http -p $ARG1$ -H $HOSTADDRESS$ -I $HOSTADDRESS$';
- check_http_port_url_content:
- command_line => '$USER1$/check_http -H $ARG1$ -p $ARG2$ -u $ARG3$ -s $ARG4$';
- check_https_port_url_content:
- command_line => '$USER1$/check_http --ssl -H $ARG1$ -p $ARG2$ -u $ARG3$ -s $ARG4$';
- check_http_url_content:
- command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$ -s $ARG3$';
- check_https_url_content:
- command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$ -s $ARG3$';
+ 'check_http_port_url_content':
+ command_line => '$USER1$/check_http -H $ARG1$ -p $ARG2$ -u $ARG3$ -s $ARG4$';
+ 'check_https_port_url_content':
+ command_line => '$USER1$/check_http --ssl -H $ARG1$ -p $ARG2$ -u $ARG3$ -s $ARG4$';
+ 'check_http_url_content':
+ command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$ -s $ARG3$';
+ 'check_https_url_content':
+ command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$ -s $ARG3$';
- # from bind module
- check_dig2:
- command_line => '$USER1$/check_dig -H $HOSTADDRESS$ -l $ARG1$ --record_type=$ARG2$';
+ # from bind module
+ 'check_dig2':
+ command_line => '$USER1$/check_dig -H $HOSTADDRESS$ -l $ARG1$ --record_type=$ARG2$';
- # from mysql module
- check_mysql_health:
- command_line => '$USER1$/check_mysql_health --hostname $ARG1$ --port $ARG2$ --username $ARG3$ --password $ARG4$ --mode $ARG5$ --database $ARG6$ $ARG7$ $ARG8$';
+ # from mysql module
+ 'check_mysql_health':
+ command_line => '$USER1$/check_mysql_health --hostname $ARG1$ --port $ARG2$ --username $ARG3$ --password $ARG4$ --mode $ARG5$ --database $ARG6$ $ARG7$ $ARG8$';
- # better check_dns
- check_dns2:
- command_line => '$USER1$/check_dns2 -c $ARG1$ A $ARG2$';
+ # better check_dns
+ 'check_dns2':
+ command_line => '$USER1$/check_dns2 -c $ARG1$ A $ARG2$';
- # dnsbl checking
- check_dnsbl:
- command_line => '$USER1$/check_dnsbl -H $ARG1$';
+ # dnsbl checking
+ 'check_dnsbl':
+ command_line => '$USER1$/check_dnsbl -H $ARG1$';
}
# notification commands
$mail_cmd_location = $::operatingsystem ? {
- centos => '/bin/mail',
- default => '/usr/bin/mail'
+ 'CentOS' => '/bin/mail',
+ default => '/usr/bin/mail'
}
- nagios_command {
- 'notify-host-by-email':
+ case $::lsbdistcodename {
+ 'wheezy': { }
+ default: {
+ nagios_command {
+ 'notify-host-by-email':
command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\nHost: \$HOSTNAME\$\\nState: \$HOSTSTATE\$\\nAddress: \$HOSTADDRESS\$\\nInfo: \$HOSTOUTPUT\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\" | ${mail_cmd_location} -s \"** \$NOTIFICATIONTYPE\$ Host Alert: \$HOSTNAME\$ is \$HOSTSTATE\$ **\" \$CONTACTEMAIL\$";
- 'notify-service-by-email':
- command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\n\\nService: \$SERVICEDESC\$\\nHost: \$HOSTALIAS\$\\nAddress: \$HOSTADDRESS\$\\nState: \$SERVICESTATE\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\\nAdditional Info:\\n\\n\$SERVICEOUTPUT\$\" | ${mail_cmd_location} -s \"** \$NOTIFICATIONTYPE\$ Service Alert: \$HOSTALIAS\$/\$SERVICEDESC\$ is \$SERVICESTATE\$ **\" \$CONTACTEMAIL\$";
+ 'notify-service-by-email':
+ command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\n\\nService: \$SERVICEDESC\$\\nHost: \$HOSTALIAS\$\\nAddress: \$HOSTADDRESS\$\\nState: \$SERVICESTATE\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\\nAdditional Info:\\n\\n\$SERVICEOUTPUT\$\" | ${mail_cmd_location} -s \"** \$NOTIFICATIONTYPE\$ Service Alert: \$HOSTALIAS\$/\$SERVICEDESC\$ is \$SERVICESTATE\$ **\" \$CONTACTEMAIL\$";
+ }
+ }
}
-
}
diff --git a/manifests/init.pp b/manifests/init.pp
index e80525e..c4d7725 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -5,7 +5,7 @@
# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
# Copyright 2008, admin(at)immerda.ch
# Copyright 2008, Puzzle ITC GmbH
-# Marcel Härry haerry+puppet(at)puzzle.ch
+# Marcel Haerry haerry+puppet(at)puzzle.ch
# Simon Josi josi+puppet(at)puzzle.ch
#
# This program is free software; you can redistribute
@@ -27,7 +27,12 @@ class nagios(
case $nagios::httpd {
'absent': { }
'lighttpd': { include ::lighttpd }
- 'apache': { include ::apache }
+ 'apache': {
+ include ::apache
+ if $::operatingsystem == 'Debian' {
+ include ::nagios::debian::apache
+ }
+ }
default: { include ::apache }
}
case $::operatingsystem {
@@ -39,7 +44,9 @@ class nagios(
$cfgdir = '/etc/nagios3'
include ::nagios::debian
}
- default: { fail("No such operatingsystem: ${::operatingsystem} yet defined") }
+ default: {
+ fail("No such operatingsystem: ${::operatingsystem} yet defined")
+ }
}
if $manage_munin {
include ::nagios::munin
diff --git a/manifests/nrpe.pp b/manifests/nrpe.pp
index 5c05ed4..ad7dbbb 100644
--- a/manifests/nrpe.pp
+++ b/manifests/nrpe.pp
@@ -1,22 +1,28 @@
+# setup nrpe stuff
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' }
+ 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' }
+ include ::nagios::nrpe::freebsd
+ }
+ 'Debian': {
+ if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/run/nagios/nrpe.pid' }
+ if $nagios_plugin_dir == '' { $nagios_plugin_dir = '/usr/lib/nagios/plugins' }
+ include ::nagios::nrpe::linux
+ }
+ 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 }
- }
- }
+ case $::kernel {
+ 'Linux': { include ::nagios::nrpe::linux }
+ default: { include ::nagios::nrpe::base }
+ }
}
+ }
}
diff --git a/manifests/plugin.pp b/manifests/plugin.pp
index d32606b..07938cd 100644
--- a/manifests/plugin.pp
+++ b/manifests/plugin.pp
@@ -1,19 +1,28 @@
+# a wrapper for syncing a plugin
define nagios::plugin(
- $source = 'absent',
- $ensure = present
+ $source = 'absent',
+ $ensure = present,
){
+ if $::hardwaremodel == 'x86_64' and $::operatingsystem != 'Debian' {
+ $real_path = "/usr/lib64/nagios/plugins/${name}"
+ }
+ else {
+ $real_path = "/usr/lib/nagios/plugins/${name}"
+ }
+
+ $real_source = $source ? {
+ 'absent' => "puppet:///modules/nagios/plugins/${name}",
+ default => "puppet:///modules/${source}"
+ }
+
file{$name:
- path => $::hardwaremodel ? {
- 'x86_64' => "/usr/lib64/nagios/plugins/${name}",
- default => "/usr/lib/nagios/plugins/${name}",
- },
- ensure => $ensure,
- source => $source ? {
- 'absent' => "puppet:///modules/nagios/plugins/${name}",
- default => "puppet:///modules/${source}"
- },
- tag => 'nagios_plugin',
+ ensure => $ensure,
+ path => $real_path,
+ source => $real_source,
+ tag => 'nagios_plugin',
require => Package['nagios-plugins'],
- owner => root, group => 0, mode => 0755;
+ owner => 'root',
+ group => 0,
+ mode => '0755';
}
}
diff --git a/manifests/target.pp b/manifests/target.pp
index 82cf6a1..2036e01 100644
--- a/manifests/target.pp
+++ b/manifests/target.pp
@@ -2,7 +2,7 @@
class nagios::target(
$parents = 'absent',
$address = $::ipaddress,
- $nagios_alias = $::hostname,
+ $nagios_alias = false,
$hostgroups = 'absent',
$use = 'generic-host',
){
@@ -11,15 +11,22 @@ class nagios::target(
alias => $nagios_alias,
use => $use,
}
+ # Watch out with using aliases: they need to be unique throughout *all*
+ # resources in a given host's catalogue.
+ if $nagios_alias {
+ Nagios_host[$::fqdn]{
+ alias => $nagios_alias
+ }
+ }
if ($parents != 'absent') {
- Nagios_host[$::fqdn] {
+ Nagios_host[$::fqdn]{
parents => $parents
}
}
if ($hostgroups != 'absent') {
- Nagios_host[$::fqdn] {
+ Nagios_host[$::fqdn]{
hostgroups => $hostgroups
}
}